Skip to content

Commit 0c2c226

Browse files
committed
Add observability for conceptual probe routing
1 parent 6b85119 commit 0c2c226

16 files changed

Lines changed: 607 additions & 12 deletions

src/canonical/auditLog.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ import type {
44
CanonicalEvent,
55
CanonicalMode,
66
ClassifierOutput,
7+
IntentClass,
78
ScoreBundle,
89
SkipReason,
910
ThesisBundle,
1011
ValidationResult,
1112
} from "./types.js";
13+
import type { OrganoidRenderPolicy, OrganoidSilencePolicy } from "../organoid/orchestration.js";
1214

1315
import { writeFile, readFile, access, mkdir, appendFile } from "node:fs/promises";
1416
import { join, dirname } from "node:path";
@@ -85,6 +87,16 @@ export function buildAuditRecord(params: {
8587
cls: ClassifierOutput;
8688
scores: ScoreBundle;
8789
mode: CanonicalMode;
90+
classifierIntent?: IntentClass;
91+
baseIntent?: IntentClass;
92+
sourceIntent?: IntentClass;
93+
orchestrationEligibleMinimal?: boolean;
94+
conceptualProbeRescue?: boolean;
95+
fastPathBypassReason?: string;
96+
finalMode?: CanonicalMode;
97+
silencePolicy?: OrganoidSilencePolicy;
98+
renderPolicy?: OrganoidRenderPolicy;
99+
leadEmbodimentId?: string;
88100
thesis: ThesisBundle | null;
89101
prompt_hash: string | null;
90102
model_id: string;
@@ -113,6 +125,16 @@ export function buildAuditRecord(params: {
113125
event_hash: stableHash(eventSnapshot),
114126
event_text: params.event.text,
115127
classifier_output: params.cls,
128+
classifierIntent: params.classifierIntent,
129+
baseIntent: params.baseIntent,
130+
sourceIntent: params.sourceIntent,
131+
orchestrationEligibleMinimal: params.orchestrationEligibleMinimal,
132+
conceptualProbeRescue: params.conceptualProbeRescue,
133+
fastPathBypassReason: params.fastPathBypassReason,
134+
finalMode: params.finalMode,
135+
silencePolicy: params.silencePolicy,
136+
renderPolicy: params.renderPolicy,
137+
leadEmbodimentId: params.leadEmbodimentId,
116138
score_bundle: params.scores,
117139
mode: params.mode,
118140
thesis: params.thesis,

src/canonical/classifier.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type {
66
TargetClass,
77
EvidenceClass,
88
} from "./types.js";
9+
import { isConceptualProbe } from "./conceptualProbe.js";
910

1011
const GREETING_PATTERNS = [
1112
/^(?:hey|hi|hello|gm|yo|sup|waddup|howdy|hola|ayo|wsg)[\s!?.]*$/i,
@@ -115,6 +116,7 @@ function classifyIntent(event: CanonicalEvent): IntentClass {
115116
if (countPatternMatches(text, MARKET_NARRATIVE_PATTERNS) >= 1) return "market_narrative";
116117

117118
if (MARKET_QUESTION_GENERAL_PATTERNS.some((p) => p.test(text))) return "market_question_general";
119+
if (isConceptualProbe(text, { event })) return "conceptual_probe";
118120

119121
if (countPatternMatches(text, QUESTION_PATTERNS) >= 1) return "question";
120122
if (countPatternMatches(text, MEME_PATTERNS) >= 2) return "meme_only";
@@ -126,6 +128,7 @@ function classifyTarget(event: CanonicalEvent, intent: IntentClass): TargetClass
126128
if (event.cashtags.length > 0) return "token";
127129
if (intent === "embodiment_query") return "embodiment";
128130
if (intent === "lore_query") return "lore";
131+
if (intent === "conceptual_probe") return "claim";
129132
if (intent === "greeting" || intent === "casual_ping" || intent === "conversation_continue") return "conversation";
130133
if (intent === "market_question_general") return "market_structure";
131134
if (intent === "accusation") return "behavior";
@@ -149,6 +152,9 @@ function classifyEvidence(event: CanonicalEvent, intent: IntentClass): EvidenceC
149152
if (productProof >= 2 || (productProof >= 1 && parentProof >= 1)) {
150153
return "self_contained_strong";
151154
}
155+
if (intent === "conceptual_probe") {
156+
return "contextual_medium";
157+
}
152158
if (hasParent || hasContext || productProof >= 1) {
153159
return "contextual_medium";
154160
}
@@ -188,6 +194,9 @@ function extractEvidenceBullets(event: CanonicalEvent, intent: IntentClass): str
188194
if (countPatternMatches(text, HYPE_PATTERNS) > 0) {
189195
bullets.push("contains strong hype language");
190196
}
197+
if (intent === "conceptual_probe") {
198+
bullets.push("structured frontier question");
199+
}
191200
if (countPatternMatches(text, PERFORMANCE_PATTERNS) > 0) {
192201
bullets.push("includes unverified performance claims");
193202
}

src/canonical/conceptualProbe.ts

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
import type { CanonicalEvent, ClassifierOutput, ScoreBundle } from "./types.js";
2+
3+
type FrontierDomainTag = "ai" | "wetware" | "transhuman" | "crypto" | "structural";
4+
5+
const STRUCTURED_FORM_PATTERNS: RegExp[] = [
6+
/^\s*what(?:'s|\s+is|\s+are)\b/i,
7+
/^\s*what limits\b/i,
8+
/^\s*how do\b/i,
9+
/^\s*why does\b/i,
10+
/^\s*do you think\b/i,
11+
/^\s*should humans\b/i,
12+
/^\s*is\s+.+\s+viable\b/i,
13+
/^\s*will\s+.+\?\s*$/i,
14+
];
15+
16+
const FRONTIER_DOMAIN_PATTERNS: Array<[FrontierDomainTag, RegExp[]]> = [
17+
[
18+
"ai",
19+
[
20+
/\bai\b/i,
21+
/\bagi\b/i,
22+
/\bllms?\b/i,
23+
/\bmodel(?:s)?\b/i,
24+
/\binference\b/i,
25+
/\b(?:current\s+)?llm(?:s)?\b/i,
26+
/\barchitectur(?:e|es)\b/i,
27+
],
28+
],
29+
[
30+
"wetware",
31+
[
32+
/\bwetware\b/i,
33+
/\borganoid(?:s)?\b/i,
34+
/\bbiocomput(?:er|ing|ation)?\b/i,
35+
/\bbiological\s+comput(?:ing|ation)\b/i,
36+
],
37+
],
38+
[
39+
"transhuman",
40+
[
41+
/\btranshuman(?:ism)?\b/i,
42+
/\bposthuman(?:ism)?\b/i,
43+
/\bdigital\s+migration\b/i,
44+
/\bmerge\s+with\s+machines\b/i,
45+
/\bbiological\s+bodies?\s+are\s+obsolete\b/i,
46+
],
47+
],
48+
[
49+
"crypto",
50+
[
51+
/\bcrypto\b/i,
52+
/\bsolana\b/i,
53+
/\btoken\b/i,
54+
/\bmarket\b/i,
55+
],
56+
],
57+
[
58+
"structural",
59+
[
60+
/\bconvergen(?:ce|t)\b/i,
61+
/\bstructural\b/i,
62+
/\bviable\b/i,
63+
/\barchitecture\b/i,
64+
/\blimit(?:s|ed)?\b/i,
65+
/\blong\s+term\b/i,
66+
],
67+
],
68+
];
69+
70+
const MARKET_CLUSTER_PATTERNS: RegExp[] = [
71+
/\bprice(?:s)?\b/i,
72+
/\bchart(?:s|ing)?\b/i,
73+
/\btrade(?:s|d|ing)?\b/i,
74+
/\bliquidity\b/i,
75+
/\bliq\b/i,
76+
/\bvolume\b/i,
77+
/\border\s*book\b/i,
78+
/\bmarket\s*cap\b/i,
79+
/\bmcap\b/i,
80+
/\btvl\b/i,
81+
/\bslippage\b/i,
82+
/\bentry\b/i,
83+
/\bexit\b/i,
84+
/\bsupport\b/i,
85+
/\bresistance\b/i,
86+
/\bperps?\b/i,
87+
/\bspot\b/i,
88+
/\bprice\s+action\b/i,
89+
];
90+
91+
function normalizeText(text: string): string {
92+
return text.trim().toLowerCase();
93+
}
94+
95+
function stripInvocationPrefix(text: string): string {
96+
return text
97+
.replace(/^(?:@\w+\s*)+/i, "")
98+
.replace(/^\s*explicit\s+opt[- ]?in[:\-\s]*/i, "")
99+
.trim();
100+
}
101+
102+
function detectFrontierTags(text: string): Set<FrontierDomainTag> {
103+
const tags = new Set<FrontierDomainTag>();
104+
for (const [tag, patterns] of FRONTIER_DOMAIN_PATTERNS) {
105+
if (patterns.some((pattern) => pattern.test(text))) {
106+
tags.add(tag);
107+
}
108+
}
109+
return tags;
110+
}
111+
112+
function hasAnyStructuredForm(text: string): boolean {
113+
return STRUCTURED_FORM_PATTERNS.some((pattern) => pattern.test(text));
114+
}
115+
116+
function hasDirectMentionSignal(event: CanonicalEvent): boolean {
117+
return (
118+
event.trigger_type === "mention" ||
119+
event.trigger_type === "reply" ||
120+
event.trigger_type === "quote" ||
121+
/@\w+/i.test(event.text)
122+
);
123+
}
124+
125+
function hasExplicitOptInSignal(text: string): boolean {
126+
return /\bexplicit\s+opt[- ]?in\b/i.test(text) || /\bopt[- ]?in\b/i.test(text);
127+
}
128+
129+
function hasCrossDomainSignal(tags: Set<FrontierDomainTag>): boolean {
130+
if (tags.has("ai") && tags.has("wetware")) return true;
131+
if (tags.has("ai") && tags.has("transhuman")) return true;
132+
if (tags.has("wetware") && tags.has("transhuman")) return true;
133+
if (tags.has("crypto") && (tags.has("ai") || tags.has("wetware") || tags.has("transhuman"))) return true;
134+
return tags.size >= 3;
135+
}
136+
137+
export function hasFrontierDomainSignal(text: string): boolean {
138+
const tags = detectFrontierTags(text);
139+
if (tags.has("ai") || tags.has("wetware") || tags.has("transhuman")) {
140+
return true;
141+
}
142+
return hasCrossDomainSignal(tags);
143+
}
144+
145+
export function hasEscalatorSignal(args: { event: CanonicalEvent; text: string }): boolean {
146+
const tags = detectFrontierTags(args.text);
147+
return (
148+
hasDirectMentionSignal(args.event) ||
149+
hasExplicitOptInSignal(args.text) ||
150+
hasAnyStructuredForm(args.text) ||
151+
hasCrossDomainSignal(tags)
152+
);
153+
}
154+
155+
export function hasMarketClusterSignal(text: string): boolean {
156+
const normalized = normalizeText(text);
157+
if (!normalized) return false;
158+
return MARKET_CLUSTER_PATTERNS.some((pattern) => pattern.test(normalized));
159+
}
160+
161+
export function isConceptualProbe(text: string, context?: { event?: CanonicalEvent }): boolean {
162+
const normalized = normalizeText(text);
163+
if (!normalized) return false;
164+
const event = context?.event;
165+
const coreText = stripInvocationPrefix(normalized);
166+
const tags = detectFrontierTags(coreText);
167+
168+
if (!hasAnyStructuredForm(coreText)) return false;
169+
if (!hasFrontierDomainSignal(coreText)) return false;
170+
171+
return hasEscalatorSignal({
172+
event:
173+
event ?? {
174+
event_id: "conceptual_probe",
175+
platform: "twitter",
176+
trigger_type: "manual",
177+
author_handle: "@unknown",
178+
author_id: "unknown",
179+
text,
180+
parent_text: null,
181+
quoted_text: null,
182+
conversation_context: [],
183+
cashtags: [],
184+
hashtags: [],
185+
urls: [],
186+
timestamp: new Date().toISOString(),
187+
},
188+
text: coreText,
189+
}) || hasCrossDomainSignal(tags);
190+
}
191+
192+
export function isOrchestrationEligibleMinimal(args: {
193+
event: CanonicalEvent;
194+
cls: ClassifierOutput;
195+
scores: ScoreBundle;
196+
}): boolean {
197+
if (args.cls.intent !== "conceptual_probe") return false;
198+
if (args.cls.policy_blocked || args.cls.policy_severity === "hard") return false;
199+
if (args.scores.risk > 0.55) return false;
200+
return isConceptualProbe(args.event.text, { event: args.event });
201+
}

src/canonical/fallbackCascade.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ async function generateFullSpectrum(
172172
narrative_label: promptContext?.narrative_label,
173173
semanticContext: selection.explainability,
174174
organoid: promptContext?.organoid,
175+
orchestrationEligibility: promptContext?.orchestrationEligibility,
176+
orchestrationReason: promptContext?.orchestrationReason,
175177
});
176178
input = { system: composed.system, developer: composed.developer, user: composed.user };
177179
} else {
@@ -184,6 +186,8 @@ async function generateFullSpectrum(
184186
promptContext?.style,
185187
promptContext?.estimatedBissigkeit,
186188
promptContext?.organoid,
189+
promptContext?.orchestrationEligibility,
190+
promptContext?.orchestrationReason,
187191
);
188192
}
189193
} catch (err) {
@@ -199,6 +203,8 @@ async function generateFullSpectrum(
199203
promptContext?.style,
200204
promptContext?.estimatedBissigkeit,
201205
promptContext?.organoid,
206+
promptContext?.orchestrationEligibility,
207+
promptContext?.orchestrationReason,
202208
);
203209
}
204210
} else {
@@ -223,6 +229,8 @@ async function generateFullSpectrum(
223229
promptContext?.style,
224230
promptContext?.estimatedBissigkeit,
225231
promptContext?.organoid,
232+
promptContext?.orchestrationEligibility,
233+
promptContext?.orchestrationReason,
226234
);
227235
}
228236

@@ -309,6 +317,8 @@ export interface FallbackCascadeContext {
309317
pattern_id?: string;
310318
narrative_label?: string;
311319
format_target?: string;
320+
orchestrationEligibility?: "standard" | "orchestration_eligible_minimal";
321+
orchestrationReason?: string;
312322
/** Precomputed relevance score for refine step */
313323
relevanceResult?: RelevanceResult;
314324
/** Style context for savage/ultra/degen in Full Spectrum */

src/canonical/fullSpectrumPromptBuilder.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ export function buildMasterPrompt(
4646
estimatedBissigkeit?: number,
4747
/** Additive organoid orchestration context */
4848
organoid?: OrganoidOrchestrationPlan,
49+
orchestrationEligibility?: "standard" | "orchestration_eligible_minimal",
50+
orchestrationReason?: string,
4951
): FullSpectrumLLMInput {
5052
const thesisStr =
5153
(event as { thesis?: string }).thesis ?? String(thesis.primary);
@@ -81,6 +83,12 @@ export function buildMasterPrompt(
8183
if (organoid) {
8284
system += `\n\n${formatOrganoidPromptBlock(organoid).join("\n")}`;
8385
}
86+
if (orchestrationEligibility) {
87+
system += `\n\nOrchestration intake: ${orchestrationEligibility}`;
88+
}
89+
if (orchestrationReason) {
90+
system += `\nOrchestration intake reason: ${orchestrationReason}`;
91+
}
8492

8593
if (style?.slangEnabled) {
8694
system += `\n\n=== HORNY-SLANG ENERGY MODE ACTIVE ===\n${getSlangGuidelines()}`;

0 commit comments

Comments
 (0)