-
Notifications
You must be signed in to change notification settings - Fork 1
KhulnaSoft AI Compute Grid - Deploy #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
FortiShield
wants to merge
7
commits into
CtxOS:main
Choose a base branch
from
FortiShield:khulnasoft
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5bcbb7b
Delete .gitignore
FortiShield 6dacdd4
Add files via upload
FortiShield eb24883
Create deploy.yml
FortiShield 8b7f8a0
Update runtime/ray/worker_task.py
xeondesk 7012cce
Update platform/scheduler/locks.py
xeondesk 6d0d223
Update platform/scheduler/scheduler.py
xeondesk 6fdca2b
Merge branch 'main' into khulnasoft
xeondesk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| name: KhulnaSoft AI Compute Grid - Deploy | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main ] | ||
| paths: | ||
| - 'platform/**' | ||
| - 'runtime/**' | ||
| - 'infra/k8s/**' | ||
| pull_request: | ||
| branches: [ main ] | ||
|
|
||
| jobs: | ||
| build-and-push: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v2 | ||
|
|
||
| - name: Login to DockerHub | ||
| uses: docker/login-action@v2 | ||
| with: | ||
| username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
| password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
|
||
| - name: Build and push AI Worker Image | ||
| uses: docker/build-push-action@v4 | ||
| with: | ||
| context: . | ||
| file: runtime/images/worker.Dockerfile | ||
| push: true | ||
| tags: khulnasoft/ai-worker:latest | ||
|
|
||
| deploy-to-k8s: | ||
| needs: build-and-push | ||
| runs-on: ubuntu-latest | ||
| if: github.ref == 'refs/heads/main' | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
|
|
||
| - name: Set up Kubeconfig | ||
| run: | | ||
| mkdir -p ~/.kube | ||
| echo "${{ secrets.KUBECONFIG }}" | base64 -d > ~/.kube/config | ||
|
|
||
| - name: Deploy Infrastructure | ||
| run: | | ||
| kubectl apply -f infra/k8s/gpu/device-plugin.yaml | ||
| kubectl apply -f infra/k8s/ray/head.yaml | ||
| kubectl apply -f infra/k8s/ray/worker.yaml | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,81 +1,71 @@ | ||
| # CtxPod - AI-Powered IDE Platform | ||
| # 🚀 KhulnaSoft AI Compute Grid | ||
|
|
||
| A Gitpod-like development environment with autonomous AI agents that can plan, code, test, debug, and deploy automatically. | ||
| A production-grade deployment pack for a hybrid GPU cluster (local + cloud) tailored for AI-native platforms and distributed pentesting pipelines. | ||
|
|
||
| ## 🚀 Quick Start | ||
| ## 🌟 Features | ||
|
|
||
| ### Prerequisites | ||
| - Docker and Docker Compose | ||
| - Node.js 16+ | ||
| - OpenAI API key (for AI agents) | ||
| - **Hybrid GPU Scaling**: Routes jobs between local and cloud clusters based on availability and priority. | ||
| - **Ray-Based Compute**: Leverages [Ray](https://ray.io) for seamless distributed Python execution. | ||
| - **K8s & GPU Ready**: Includes manifests for NVIDIA Device Plugin and GPU-aware worker deployments. | ||
| - **Secure by Default**: Example security contexts and isolated runtime configurations. | ||
| - **Smart Control Plane**: FastAPI-based API with Redis job tracking and status monitoring. | ||
|
|
||
| ### Installation | ||
| ## 🏗️ Repository Structure | ||
|
|
||
| 1. Clone and setup: | ||
| ```bash | ||
| cp .env.example .env | ||
| # Edit .env with your OpenAI key | ||
| infra/ | ||
| terraform/cloud/ # AWS/Cloud GPU provisioning | ||
| ansible/ # Node bootstrapping (Docker, NVIDIA drivers) | ||
| k8s/ # K8s manifests (GPU plugin, Ray cluster) | ||
| platform/ | ||
| api/ # FastAPI job submission API | ||
| scheduler/ # Smart routing logic | ||
| runtime/ | ||
| ray/ # AI task definitions | ||
| agents/ # Example client implementations | ||
| ``` | ||
|
|
||
| 2. Build workspace image: | ||
| ## 🚀 Quick Start | ||
|
|
||
| ### 1. Provision Cloud Infrastructure | ||
| ```bash | ||
| npm run build:docker | ||
| cd infra/terraform/cloud | ||
| terraform init | ||
| terraform apply | ||
| ``` | ||
|
|
||
| 3. Start the platform: | ||
| ### 2. Bootstrap Nodes (Local or Cloud) | ||
| ```bash | ||
| npm run docker:run | ||
| cd infra/ansible | ||
| ansible-playbook -i inventory.ini gpu-node.yml | ||
| ``` | ||
|
|
||
| 4. Create a workspace: | ||
| ### 3. Deploy Kubernetes Cluster | ||
| ```bash | ||
| curl -X POST http://localhost:3000/workspace | ||
| kubectl apply -f infra/k8s/gpu/device-plugin.yaml | ||
| kubectl apply -f infra/k8s/ray/head.yaml | ||
| kubectl apply -f infra/k8s/ray/worker.yaml | ||
| ``` | ||
|
|
||
| ## 📋 Architecture | ||
|
|
||
| - **Control Server** (Node.js) - Manages workspaces and orchestrates agents | ||
| - **code-server** - Browser-based VS Code IDE | ||
| - **Docker** - Isolated workspace containers | ||
| - **Redis + BullMQ** - Queue-based agent system | ||
| - **AI Agents** - Autonomous coding agents | ||
|
|
||
| ## 🛠️ Development | ||
|
|
||
| ### 4. Run the Platform | ||
| ```bash | ||
| # Start control server only | ||
| npm start | ||
| # Start API (Port 8000) | ||
| uvicorn platform.api.main:app --host 0.0.0.0 | ||
|
|
||
| # Start with Docker Compose (includes Redis) | ||
| npm run docker:run | ||
|
|
||
| # Build Docker workspace image | ||
| npm run build:docker | ||
| # Start Scheduler | ||
| python platform/scheduler/scheduler.py | ||
| ``` | ||
|
|
||
| ## 📚 API Endpoints | ||
|
|
||
| - `POST /workspace` - Create new workspace | ||
| - `GET /workspaces` - List all workspaces | ||
| - `GET /workspace/:id` - Get workspace details | ||
| - `DELETE /workspace/:id` - Stop workspace | ||
|
|
||
| ## 🤖 AI Agents | ||
|
|
||
| Coming soon: | ||
| - **Planner Agent** - Breaks tasks into steps | ||
| - **Coder Agent** - Writes production code | ||
| - **Tester Agent** - Runs automated tests | ||
| - **Debugger Agent** - Fixes errors | ||
| - **Deployer Agent** - Ships to production | ||
| ### 5. Submit a Job | ||
| ```bash | ||
| python agents/example_agent.py | ||
| ``` | ||
|
|
||
| ## 🔧 Configuration | ||
| ## 🔐 Security & Observability | ||
|
|
||
| Edit `.env` for: | ||
| - OpenAI API key | ||
| - Redis connection | ||
| - Server settings | ||
| - **Sandboxing**: Pods are configured with restricted security contexts. Advanced isolation via gVisor is recommended for multi-tenant environments. | ||
| - **Monitoring**: Integration with Prometheus & Grafana is supported via Ray's native exporters. | ||
|
|
||
| ## 📄 License | ||
| ## 🤝 Contributing | ||
|
|
||
| MIT | ||
| This is a production blueprint. Please adapt configurations (AMIs, regions, instance types) to your specific requirements before final deployment. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import requests | ||
| import time | ||
| import json | ||
| import logging | ||
|
|
||
| # Setup logging | ||
| logging.basicConfig(level=logging.INFO) | ||
| logger = logging.getLogger("AIAgent") | ||
|
|
||
| API_URL = "http://localhost:8000" | ||
|
|
||
| def submit_and_wait(task_type, params): | ||
| payload = { | ||
| "task_type": task_type, | ||
| "params": params, | ||
| "priority": 1 | ||
| } | ||
|
|
||
| try: | ||
| # Submit job | ||
| response = requests.post(f"{API_URL}/submit", json=payload) | ||
| response.raise_for_status() | ||
| job_id = response.json()["job_id"] | ||
| logger.info(f"Submitted {task_type} job. ID: {job_id}") | ||
|
|
||
| # Poll for status | ||
| while True: | ||
| status_resp = requests.get(f"{API_URL}/job/{job_id}") | ||
| status_resp.raise_for_status() | ||
| job_data = status_resp.json() | ||
|
|
||
| status = job_data.get("status") | ||
| logger.info(f"Job {job_id} status: {status}") | ||
|
|
||
| if "running" in status or "completed" in status: | ||
| return job_data | ||
|
|
||
| time.sleep(2) | ||
|
|
||
| except Exception as e: | ||
| logger.error(f"Error communicating with Grid API: {str(e)}") | ||
| return None | ||
|
|
||
| if __name__ == "__main__": | ||
| logger.info("Starting AI Agent example...") | ||
| result = submit_and_wait("CVE-Scanner", {"target": "khulnasoft.com", "depth": "advanced"}) | ||
| if result: | ||
| print(f"Final Job State: {json.dumps(result, indent=2)}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import abc | ||
| import logging | ||
| from typing import Dict, Any | ||
|
|
||
| logger = logging.getLogger("GridAgent") | ||
|
|
||
| class Agent(abc.ABC): | ||
| """ | ||
| Formalized Base Agent for the multi-agent orchestration system. | ||
| Every agent must implement the 'run' method with input_data and context. | ||
| """ | ||
| def __init__(self, agent_id: str, role: str, config: Dict[str, Any] = None): | ||
| self.id = agent_id | ||
| self.role = role | ||
| self.config = config or {} | ||
| self.status = "idle" | ||
|
|
||
| @abc.abstractmethod | ||
| def run(self, input_data: Any, context: Dict[str, Any] = None) -> Dict[str, Any]: | ||
| """ | ||
| Main execution logic. | ||
| """ | ||
| pass | ||
|
|
||
| def log_decision(self, action: str, rationale: str, data: Any = None): | ||
| """ | ||
| Helper to record autonomous decisions for the audit trail. | ||
| """ | ||
| logger.info(f"[{self.role}] ACTION: {action} | RATIONALE: {rationale}") | ||
| # In production, this would call the platform/audit/logger.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| from typing import Dict, Any, List | ||
| from agents.types.base_agent import Agent | ||
|
|
||
| class PlannerAgent(Agent): | ||
| """ | ||
| Agent specialized in decomposing complex goals into DSL workflows. | ||
| """ | ||
| def __init__(self, agent_id: str, config: Dict[str, Any] = None): | ||
| super().__init__(agent_id, "Planner", config) | ||
|
|
||
| def run(self, goal: Any, context: Dict[str, Any] = None) -> Dict[str, Any]: | ||
| self.log_decision("Generate Workflow", f"Decomposing goal: {goal}") | ||
| # Simplified mock logic - would call workflow_generator.py | ||
| return { | ||
| "type": "autonomous_scan", | ||
| "workflow": [ | ||
| {"name": "Recon", "agent": "recon", "params": {"target": goal}} | ||
| ] | ||
| } | ||
|
|
||
| class CriticAgent(Agent): | ||
| """ | ||
| Agent specialized in safety audit and efficiency review. | ||
| """ | ||
| def __init__(self, agent_id: str, config: Dict[str, Any] = None): | ||
| super().__init__(agent_id, "Critic", config) | ||
|
|
||
| def run(self, plan: Any, context: Dict[str, Any] = None) -> Dict[str, Any]: | ||
| self.log_decision("Audit Plan", "Reviewing proposed workflow for safety breaches.") | ||
| # Logic to check for blocked agents or dangerous commands | ||
| return {"approved": True, "score": 0.95} | ||
|
|
||
| class ObserverAgent(Agent): | ||
| """ | ||
| Agent specialized in real-time execution monitoring and anomaly detection. | ||
| """ | ||
| def __init__(self, agent_id: str, config: Dict[str, Any] = None): | ||
| super().__init__(agent_id, "Observer", config) | ||
|
|
||
| def run(self, job_telemetry: Any, context: Dict[str, Any] = None) -> Dict[str, Any]: | ||
| runtime = job_telemetry.get("runtime", 0) | ||
| if runtime > 600: | ||
| self.log_decision("Alert Anomaly", f"Job runtime ({runtime}s) exceeds threshold.") | ||
| return {"anomaly": True, "action": "Kill"} | ||
| return {"anomaly": False} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| --- | ||
| - name: Bootstrap KhulnaSoft AI GPU Node | ||
| hosts: gpu_nodes | ||
| become: yes | ||
| tasks: | ||
| - name: Update apt cache | ||
| apt: | ||
| update_cache: yes | ||
|
|
||
| - name: Install baseline dependencies | ||
| apt: | ||
| name: | ||
| - curl | ||
| - ca-certificates | ||
| - gnupg | ||
| - lsb-release | ||
| state: present | ||
|
|
||
| - name: Install Docker | ||
| apt: | ||
| name: docker.io | ||
| state: present | ||
|
|
||
| - name: Install NVIDIA drivers | ||
| apt: | ||
| name: nvidia-driver-535 | ||
| state: present | ||
|
|
||
| - name: Install NVIDIA Container Toolkit | ||
| shell: | | ||
| curl -s -L https://nvidia.github.io/libnvidia-container/gpgkey | apt-key add - | ||
| curl -s -L https://nvidia.github.io/libnvidia-container/$(. /etc/os-release;echo $ID$VERSION_ID)/libnvidia-container.list | tee /etc/apt/sources.list.d/nvidia-container-toolkit.list | ||
| apt-get update && apt-get install -y nvidia-container-toolkit | ||
| args: | ||
| creates: /usr/bin/nvidia-container-toolkit | ||
|
|
||
| - name: Configure Docker to use NVIDIA runtime | ||
| copy: | ||
| content: | | ||
| { | ||
| "default-runtime": "nvidia", | ||
| "runtimes": { | ||
| "nvidia": { | ||
| "path": "nvidia-container-runtime", | ||
| "runtimeArgs": [] | ||
| } | ||
| } | ||
| } | ||
| dest: /etc/docker/daemon.json | ||
|
|
||
| - name: Restart Docker | ||
| service: | ||
| name: docker | ||
| state: restarted |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: CtxOS/ctxpod
Length of output: 1372
🌐 Web query:
actions/checkout v4 latest version 2024 2025💡 Result:
The latest version of actions/checkout v4 is v4.3.1, released on 2025-11-17. This ports cleanup changes from v6 to the v4 branch. Prior versions include v4.3.0 (2025-08-11, documentation and dependency updates), v4.2.2 (2024-10), v4.2.0 (2024-09-25), and v4.0.0 (2023-10-17, updated to node20 runtime). Use uses: actions/checkout@v4 to pin to the v4 branch, which always points to the latest v4 release. Note that newer major versions like v6.0.2 (2026-01-09) exist with Node.js 24 support.
Citations:
🌐 Web query:
docker/setup-buildx-action latest version 2024 2025💡 Result:
The latest version of the docker/setup-buildx-action GitHub Action is v4.0.0, released on 2026-03-05. This is a major release featuring Node 24 as the default runtime (requires Actions Runner v2.327.1+), removal of deprecated inputs/outputs, switch to ESM, and various dependency updates including
@actions/coreto 3.0.0 and@docker/actions-toolkitto 0.79.0. Previous recent versions: - v3.12.0 (2025-12-19): Deprecated install input, dependency bumps. - v3.11.1 and earlier in 2025. Usage example from official docs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v4 Repository last pushed on 2026-04-09 (as of search data), confirming v4.0.0 remains latest. Official Docker docs and GitHub Marketplace also reference v4.Citations:
🌐 Web query:
docker/login-action latest version 2024 2025💡 Result:
The latest version of the docker/login-action GitHub Action is v4.1.0, released on April 2, 2026. This is the current latest as of 2026-04-16. Recent releases in 2024-2026: - v4.1.0 (2026-04-02): Fix scoped Docker Hub cleanup path, dependency bumps including
@aws-sdk/client-ecrto 3.1020.0 and@docker/actions-toolkitto 0.86.0. - v4.0.0 (2026-03-04): Node 24 as default runtime, switch to ESM, major dependency updates like@actions/coreto 3.0.0. Usage example from official docs: - name: Login to Docker Hub uses: docker/login-action@v4.1.0 with: username: ${{ vars.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} Official repository: https://github.com/docker/login-actionCitations:
🌐 Web query:
docker/build-push-action latest version 2024 2025💡 Result:
The latest version of the docker/build-push-action GitHub Action is v7.1.0, released on 2026-04-10. This is confirmed by the GitHub releases page listing it as the top release dated 10 Apr (which aligns with 2026-04-10 given today's date of 2026-04-16), and the tags page showing v7.1.0 as the first tag. Previous versions include v7.0.0 (2026-03-05) and v6.19.x in early 2026. In 2024, versions were in the v6.x series (e.g., v6.4.0 in July 2024), and in 2025 leading up to v6.19.0 in February 2026. Official examples in the README and Marketplace use v7.
Citations:
Update GitHub Actions to current major versions.
These pinned action versions are significantly outdated. Update to the latest available versions:
actions/checkout@v3→ usev4or latestv6docker/setup-buildx-action@v2→ usev3or latestv4docker/login-action@v2→ use latestv3orv4docker/build-push-action@v4→ use latestv6orv7The major versions in the workflow file are no longer current and may face compatibility issues with modern GitHub runners.
🧰 Tools
🪛 actionlint (1.7.12)
[error] 17-17: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
🤖 Prompt for AI Agents