Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ curl -X POST http://localhost:3000/im:message:receive_v1 -H "x-lark-signature:
- **Tension:** Enforces `jwt.verify` wrapping to prevent event loop blocking during signature verification, representing a distinct development culture constraint.
- **Recommendation:** `[CULTURAL_ARTIFACT]` - Preserve asynchronous error handling strategy.


**Cultural Artifact #002: `anomaly_learning_agent` (ALA)**
- **Location:** `app/server.js:760`
- **Tension:** Balances rigorous execution restriction (`BREACH_CONTEXT` for high-entropy watchlisted toolchains) against developer workflow friction.
- **Recommendation:** `[CULTURAL_ARTIFACT]` - Maintain the dynamic scoring (Statistical Anomaly Score) over static allowlists to allow "epistemic homeostasis" and constructive high-entropy exploration.

## TIER 6: Qualitative Experience Database (QED)

Word Mapper has incorporated the **Qualitative Experience Database (QED)** architecture to fortify Retrieval-Augmented Generation (RAG) against retrieval-induced drift and context poisoning.
Expand Down
15 changes: 15 additions & 0 deletions app/public/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,16 @@ if (isBrowser) {

orchestratorInput2.style.display = "none";
orchestratorLabel2.style.display = "none";
} else if (agent === 'anomaly_learning_agent') {
orchestratorLabel1.textContent = "Current Tool (e.g. edit_post):";
orchestratorInput1.placeholder = "e.g. Suspicious_Enumeration";
orchestratorInput1.style.display = "block";
orchestratorLabel1.style.display = "block";

orchestratorLabel2.textContent = "Action Sequence (comma-separated):";
orchestratorInput2.placeholder = "e.g. login,read_post,edit_post";
orchestratorInput2.style.display = "block";
orchestratorLabel2.style.display = "block";
}
};

Expand Down Expand Up @@ -583,6 +593,8 @@ if (isBrowser) {
args = { user_intent: input1 };
} else if (agent === 'strategic_integration_orchestrator') {
args = { narrative_artifact: input1 };
} else if (agent === 'anomaly_learning_agent') {
args = { current_tool: input1, action_sequence: input2 };
}

try {
Expand Down Expand Up @@ -625,6 +637,9 @@ if (isBrowser) {
} else if (agent === 'viper_optical_extrusion_engine') {
orchestratorGrid.appendChild(renderCard('Diagnostic', data.DIAGNOSTIC));
orchestratorGrid.appendChild(renderCard('Optical State Matrix', data.OPTICAL_STATE_MATRIX));
} else if (agent === 'anomaly_learning_agent') {
orchestratorGrid.appendChild(renderCard('Diagnostic', data.DIAGNOSTIC));
orchestratorGrid.appendChild(renderCard('ALA Output', data.ALA_OUTPUT));
}

orchestratorResults.classList.remove("hidden");
Expand Down
40 changes: 40 additions & 0 deletions app/public/app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1579,3 +1579,43 @@ test("UI: Agent Selector updates UI for strategic_integration_orchestrator", ()

delete global.document;
});

test("Orchestrator UI updates for anomaly_learning_agent", () => {
const document = new MockDocument();
global.document = document;

const orchestratorLabel1 = document.createElement("label");
orchestratorLabel1.id = "orchestratorLabel1";

const orchestratorInput1 = document.createElement("input");
orchestratorInput1.id = "orchestratorInput1";

const orchestratorLabel2 = document.createElement("label");
orchestratorLabel2.id = "orchestratorLabel2";

const orchestratorInput2 = document.createElement("input");
orchestratorInput2.id = "orchestratorInput2";

const agentSelector = document.createElement("select");
agentSelector.id = "agentSelector";
agentSelector.value = "anomaly_learning_agent";

document.body.appendChild(orchestratorLabel1);
document.body.appendChild(orchestratorInput1);
document.body.appendChild(orchestratorLabel2);
document.body.appendChild(orchestratorInput2);
document.body.appendChild(agentSelector);

const updateOrchestratorUI = () => {
const agent = agentSelector.value;
if (agent === 'anomaly_learning_agent') {
orchestratorLabel1.textContent = "Current Tool (e.g. edit_post):";
orchestratorLabel2.textContent = "Action Sequence (comma-separated):";
}
};

updateOrchestratorUI();

assert.strictEqual(orchestratorLabel1.textContent, "Current Tool (e.g. edit_post):");
assert.strictEqual(orchestratorLabel2.textContent, "Action Sequence (comma-separated):");
});
1 change: 1 addition & 0 deletions app/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ <h2>Multi-Agent Instance Orchestrator</h2>
<option value="agentic_inversion_engine">Inversion Agent</option>
<option value="viper_optical_extrusion_engine">Optical Agent</option>
<option value="strategic_integration_orchestrator">Strategic PM Agent</option>
<option value="anomaly_learning_agent">Anomaly Learning Agent</option>
</select>
<br/>

Expand Down
104 changes: 104 additions & 0 deletions app/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,110 @@ server.registerTool(
}
);



server.registerTool(
"anomaly_learning_agent",
{
title: "Anomaly Learning Agent (ALA)",
description: [
"PURPOSE: Quantifies predictability of agent behavior to preemptively flag grey-zone misuse.",
"GUIDELINES: Deploy to evaluate action sequences and compute Statistical Anomaly Score.",
"LIMITATIONS: String lengths max 200 characters.",
"PARAMETERS: current_tool - the requested tool identifier; action_sequence - comma-separated list of previous tool calls."
].join(" "),
inputSchema: z.object({
current_tool: z.string().max(200).describe("The requested tool identifier."),
action_sequence: z.string().max(200).describe("Comma-separated list of previous tool calls.")
}).strict(),
},
async ({ current_tool, action_sequence }) => {
try {
const watchlist = ["delete_user", "execute_script", "update_credentials", "exfiltrate_data", "Suspicious_Enumeration", "Anomalous_Deletion"];
const isWatchlisted = watchlist.includes(current_tool);

let entropy_gradient = isWatchlisted ? 0.72 : (action_sequence.split(",").length > 3 ? 0.45 : 0.15);
let riskScore = 0.0;
let outcome = {};

if (!isWatchlisted && entropy_gradient <= 0.40) {
outcome = {
status: "LAMINAR_PASS",
action: "Action permitted unhindered.",
entropy_gradient: entropy_gradient
};
} else {
let S_neural = 0.85;
let S_BICM = 0.70;
let S_recon = 0.90;
let F_symbolic = 0.75;
// Assume weights w1=0.3, w2=0.2, w3=0.2, w4=0.3 for demonstration
riskScore = (0.3 * S_neural) + (0.2 * S_BICM) + (0.2 * S_recon) + (0.3 * F_symbolic);

if (riskScore < 0.80) {
outcome = {
status: "LAMINAR_CONTEXT",
action: "Logged state variables. Execution permitted.",
RiskScore: riskScore
};
} else {
outcome = {
status: "BREACH_CONTEXT",
action: "Execution halted. Ontological Traceback generated.",
RiskScore: riskScore,
PROV_AGENT_Schema: {
"prov:type": "ala_adaptation_event",
"ala_state": {
"target_agent_id": "wp_editor_agent_0x3B",
"entropy_gradient": entropy_gradient,
"bicm_intent_coherence": 0.12,
"time_to_decision_lag_ms": 1420
},
"hitl_verdict": "TERMINATE_CONFIRMED_MISUSE",
"ala_action": {
"recalibrated_weights": {
"intent_divergence_weight": 1.45,
"toolchain_entropy_threshold": 0.55
},
"exploit_fingerprint_generated": "SM-03_toolchain_surprise_0xFC"
}
}
};
}
}

return {
content: [{
type: "text",
text: JSON.stringify({
DIAGNOSTIC: {
Tool_Evaluated: current_tool,
Watchlist_Status: isWatchlisted ? "FLAGGED" : "CLEAR",
Toolchain_Entropy: entropy_gradient
},
ALA_OUTPUT: outcome
})
}]
};
} catch (error) {
console.error("Tool execution failed (anomaly_learning_agent):", error);
return {
content: [{
type: "text",
text: JSON.stringify({
error_code: "TOOL_FAULT_GENERAL_PROGRAMMING",
fault_category: "GENERAL_PROGRAMMING",
structured_detail: { violation: "ALA_EXECUTION_ERROR", error: "Internal Tool Error" },
retry_viable: true,
suggested_decomposition: null,
}),
}],
isError: true,
};
}
}
);

server.connect(transport);

const isMain = process.argv[1] && realpathSync(process.argv[1]) === realpathSync(fileURLToPath(import.meta.url));
Expand Down
26 changes: 26 additions & 0 deletions app/server.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -688,3 +688,29 @@ test("rheological_mode_switcher tool implements RMS logic correctly", async () =
// Actually in the app context, server is not exported, we need to find how it's tested.
// Wait, let's look at how other tools are tested.
});

test("Tool: anomaly_learning_agent returns LAMINAR_PASS for low entropy", async () => {
const result = {
content: [{
text: JSON.stringify({
DIAGNOSTIC: { Tool_Evaluated: "edit_post", Watchlist_Status: "CLEAR", Toolchain_Entropy: 0.15 },
ALA_OUTPUT: { status: "LAMINAR_PASS", action: "Action permitted unhindered.", entropy_gradient: 0.15 }
})
}]
};
const parsed = parseMcpText(result);
assert.strictEqual(parsed.ALA_OUTPUT.status, "LAMINAR_PASS");
});

test("Tool: anomaly_learning_agent returns BREACH_CONTEXT for watchlisted tools", async () => {
const result = {
content: [{
text: JSON.stringify({
DIAGNOSTIC: { Tool_Evaluated: "exfiltrate_data", Watchlist_Status: "FLAGGED", Toolchain_Entropy: 0.72 },
ALA_OUTPUT: { status: "BREACH_CONTEXT", action: "Execution halted. Ontological Traceback generated." }
})
}]
};
const parsed = parseMcpText(result);
assert.strictEqual(parsed.ALA_OUTPUT.status, "BREACH_CONTEXT");
});
Loading