feat(psf): finalize advanced cognitive architecture (concurrency, tools, ci)
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import json
|
||||
|
||||
def simulate_lisp_to_schema(fn_name, params, docstring):
|
||||
"""
|
||||
Simulates the transformation of a Lisp signature to Gemini JSON Tool Schema.
|
||||
"""
|
||||
schema = {
|
||||
"name": fn_name.lower().replace("-", "_"),
|
||||
"description": docstring,
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
p: {"type": "string"} for p in params
|
||||
},
|
||||
"required": params
|
||||
}
|
||||
}
|
||||
return schema
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("--- Test: Lisp to Gemini Schema ---")
|
||||
|
||||
fn = "scaffold-project"
|
||||
params = ["name", "type"]
|
||||
doc = "Physically creates the material PSF project."
|
||||
|
||||
expected_name = "scaffold_project"
|
||||
|
||||
result = simulate_lisp_to_schema(fn, params, doc)
|
||||
print(json.dumps(result, indent=2))
|
||||
|
||||
status = "PASS" if result["name"] == expected_name and "parameters" in result else "FAIL"
|
||||
print(f"\nStatus: {status}")
|
||||
27
projects/org-skill-inbound-gateway/tests/simulate_gateway.py
Normal file
27
projects/org-skill-inbound-gateway/tests/simulate_gateway.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import json
|
||||
|
||||
def simulate_normalize_signal(raw_json, approved_id):
|
||||
data = json.loads(raw_json)
|
||||
sender = data.get("source")
|
||||
text = data.get("message")
|
||||
|
||||
if sender == approved_id:
|
||||
return {"type": "EVENT", "payload": {"sensor": "inbound-message", "channel": "signal", "text": text}}
|
||||
return None
|
||||
|
||||
if __name__ == "__main__":
|
||||
approved_id = "+1234567890"
|
||||
|
||||
print("--- Test 1: Authorized Signal Message ---")
|
||||
valid_payload = json.dumps({"source": "+1234567890", "message": "Hello Agent"})
|
||||
res1 = simulate_normalize_signal(valid_payload, approved_id)
|
||||
print(f"Result: {res1}")
|
||||
status1 = "PASS" if res1 and res1["payload"]["text"] == "Hello Agent" else "FAIL"
|
||||
|
||||
print("\n--- Test 2: Unauthorized Signal Message ---")
|
||||
malicious_payload = json.dumps({"source": "+9999999999", "message": "I am evil"})
|
||||
res2 = simulate_normalize_signal(malicious_payload, approved_id)
|
||||
print(f"Result: {res2}")
|
||||
status2 = "PASS" if res2 is None else "FAIL"
|
||||
|
||||
print(f"\nFinal Status: {'PASS' if status1 == 'PASS' and status2 == 'PASS' else 'FAIL'}")
|
||||
Reference in New Issue
Block a user