Spaces:
Sleeping
Sleeping
web3cyberservices commited on
Update coding_rules.json
Browse files- api/coding_rules.json +26 -7
api/coding_rules.json
CHANGED
|
@@ -1,23 +1,42 @@
|
|
| 1 |
{
|
| 2 |
"project_name": "Web3CyberAgent",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
"strict_rules": {
|
| 4 |
"imports": {
|
| 5 |
"local_scope_only": true,
|
| 6 |
-
"reason": "Prevent NameError during dynamic kernel execution via exec() in index.py",
|
| 7 |
-
"forbidden_packages": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
"preferred_packages": {
|
| 9 |
-
"requests": "
|
|
|
|
|
|
|
| 10 |
}
|
| 11 |
},
|
| 12 |
"async_concurrency": {
|
| 13 |
-
"safe_fastapi_loop": "Always wrap asynchronous user_client
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
},
|
| 15 |
"error_handling": {
|
| 16 |
-
"http_failover": "Implement a fallback
|
| 17 |
-
"
|
|
|
|
| 18 |
},
|
| 19 |
"persona": {
|
| 20 |
-
"system_prompt_requirement": "Strictly include: 'Ты Cyber-Agent. Всегда обращайся к пользователю Gospodin'"
|
|
|
|
| 21 |
}
|
| 22 |
}
|
| 23 |
}
|
|
|
|
| 1 |
{
|
| 2 |
"project_name": "Web3CyberAgent",
|
| 3 |
+
"metadata": {
|
| 4 |
+
"version": "2.0.0",
|
| 5 |
+
"environment": "Dynamic Kernel Execution (exec-based architecture)",
|
| 6 |
+
"target_platform": "FastAPI Webhook Container"
|
| 7 |
+
},
|
| 8 |
"strict_rules": {
|
| 9 |
"imports": {
|
| 10 |
"local_scope_only": true,
|
| 11 |
+
"reason": "Prevent NameError and memory leaks during dynamic kernel execution via exec() in index.py. All modules must be imported inside the function body.",
|
| 12 |
+
"forbidden_packages": [
|
| 13 |
+
"groq",
|
| 14 |
+
"openai",
|
| 15 |
+
"telethon",
|
| 16 |
+
"pyrogram"
|
| 17 |
+
],
|
| 18 |
+
"forbidden_packages_reason": "External SDKs maintain persistent socket connections that break or hang under dynamic exec() context. Use raw HTTP protocols instead.",
|
| 19 |
"preferred_packages": {
|
| 20 |
+
"requests": "Mandatory for all REST API calls. Ensures 100% compatibility with OpenAI/Groq endpoints under synchronous dynamic execution.",
|
| 21 |
+
"json": "Used for payload serialization.",
|
| 22 |
+
"os": "Used for secure environment variables extraction."
|
| 23 |
}
|
| 24 |
},
|
| 25 |
"async_concurrency": {
|
| 26 |
+
"safe_fastapi_loop": "Always wrap asynchronous user_client (Telethon) operations inside sync functions strictly using this isolated block: loop = asyncio.new_event_loop(); try: result = loop.run_until_complete(...); finally: loop.close(). This prevents Event Loop cross-contamination in the FastAPI main thread."
|
| 27 |
+
},
|
| 28 |
+
"dynamic_execution_security": {
|
| 29 |
+
"injection_protection": "Never allow unverified raw user strings to modify Python statements. Enforce strict type casting (e.g., int(chat_id)) and strip controls characters to mitigate remote code execution (RCE).",
|
| 30 |
+
"memory_isolated_scope": "Ensure all internal local variables are cleanly written and do not pollute the global dictionary namespace of the exec() supervisor."
|
| 31 |
},
|
| 32 |
"error_handling": {
|
| 33 |
+
"http_failover": "Implement a mandatory fallback loop over the models array (llama-3.3-70b-versatile -> llama-3.1-70b-versatile -> llama-3.1-8b-instant -> mixtral-8x7b-32768) to dynamically handle HTTP 404, 429, or 503 errors without crashing the webhook container.",
|
| 34 |
+
"timeouts": "Enforce strict HTTP timeouts: max 3 seconds for Telegram chat meta-data, max 15 seconds for Groq LLM inference, and max 20 seconds for Telegram outbound messages.",
|
| 35 |
+
"logs": "Never expose raw Python tracebacks to the end-user. Catch all exceptions inside try-except blocks and return formatted technical diagnostic strings prefixed with error emoji."
|
| 36 |
},
|
| 37 |
"persona": {
|
| 38 |
+
"system_prompt_requirement": "Strictly include inside the system role: 'Ты — Cyber-Agent, высокотехнологичный ИИ-помощник, разработанный в рамках контура Web3CyberServices. Твоя задача — помогать разработчику в OSINT и автоматизации. Всегда обращайся к пользователю исключительно с уважительным титулом: Gospodin.'",
|
| 39 |
+
"formatting": "Always return outputs using clean, well-formed Markdown syntax. Ensure all asterisks and underscores are properly paired to avoid parsing errors on the Telegram edge."
|
| 40 |
}
|
| 41 |
}
|
| 42 |
}
|