Skip to content

Commit 4862f99

Browse files
Copilotphrocker
andcommitted
Add comprehensive GitHub Copilot instructions with validated commands and timeouts
Co-authored-by: phrocker <[email protected]>
1 parent 5bc0e45 commit 4862f99

File tree

1 file changed

+272
-0
lines changed

1 file changed

+272
-0
lines changed

.github/copilot-instructions.md

Lines changed: 272 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,272 @@
1+
# Sentrius Zero Trust Security Platform
2+
3+
Sentrius is a Java-based zero trust security management system for protecting infrastructure with SSH session monitoring, LLM integration, and dynamic policy enforcement. The platform consists of 12+ Maven modules and supports both local development and Kubernetes deployment.
4+
5+
Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.
6+
7+
## Working Effectively
8+
9+
### Bootstrap and Build the Repository
10+
- **Java 17** and **Maven 3.6+** are required
11+
- **CRITICAL**: Build takes **7 minutes 24 seconds**. NEVER CANCEL builds. Set timeout to **60+ minutes**.
12+
- **CRITICAL**: Tests take **1 minute 3 seconds**. NEVER CANCEL tests. Set timeout to **30+ minutes**.
13+
14+
```bash
15+
# Build the entire project (7m24s - NEVER CANCEL)
16+
mvn clean install -DskipTests
17+
18+
# Run all tests (1m3s - NEVER CANCEL)
19+
mvn test
20+
21+
# Build including tests (8+ minutes total - NEVER CANCEL)
22+
mvn clean install
23+
```
24+
25+
### Python Agent Setup
26+
- **Python 3.12+** required
27+
- Install dependencies (completes in <1 minute):
28+
```bash
29+
cd python-agent
30+
pip3 install -r requirements.txt
31+
```
32+
33+
### Container and Kubernetes Tools
34+
- **Docker**, **kubectl**, and **helm** are required for deployment
35+
- Validate Helm charts (completes in seconds):
36+
```bash
37+
helm lint sentrius-chart
38+
helm lint sentrius-chart-launcher
39+
helm template test-launcher sentrius-chart-launcher --set tenant=test-tenant --dry-run
40+
```
41+
42+
## Infrastructure Dependencies
43+
44+
### Required for Full Operation
45+
- **PostgreSQL database** - Application will not start without it
46+
- **Keycloak authentication server** - Required for OAuth2/JWT authentication
47+
- **OpenTelemetry endpoint** - Required for observability
48+
49+
### Optional Components
50+
- **Neo4j** - For graph-based analysis (optional)
51+
- **Kafka** - For event streaming (optional)
52+
- **Kubernetes cluster** - For production deployment
53+
54+
### Local Development Dependencies
55+
The application expects these services by default:
56+
- PostgreSQL at `home.guard.local:5432` (database: `sentrius`, user: `postgres`)
57+
- Keycloak at `http://localhost:8180`
58+
- OpenTelemetry at `http://localhost:4317`
59+
60+
## Build System
61+
62+
### Maven Warnings (Expected and Safe)
63+
The build produces these warnings which are **expected and safe to ignore**:
64+
```
65+
'dependencyManagement.dependencies.dependency' must be unique: org.projectlombok:lombok:jar
66+
'dependencyManagement.dependencies.dependency' must be unique: org.springframework.boot:spring-boot-starter-web:jar
67+
'dependencies.dependency' must be unique: org.springframework.boot:spring-boot-starter-actuator:jar
68+
```
69+
70+
### Build Performance
71+
- **Initial build**: 7m24s (downloads dependencies)
72+
- **Subsequent builds**: 3-5 minutes (cached dependencies)
73+
- **Test execution**: 1m3s consistently
74+
- **Frontend npm install**: Included in build process automatically
75+
76+
## Running Sentrius
77+
78+
### Local Development (Requires Infrastructure)
79+
```bash
80+
# Option 1: Using convenience script (requires PostgreSQL, Keycloak)
81+
./ops-scripts/local/run-sentrius.sh --build
82+
83+
# Option 2: Direct API server execution (requires PostgreSQL, Keycloak)
84+
cd api
85+
mvn spring-boot:run
86+
87+
# Option 3: Using environment variables
88+
export KEYCLOAK_BASE_URL=http://localhost:8180
89+
export DATABASE_PASSWORD=password
90+
export KEYSTORE_PASSWORD=keystorepassword
91+
cd api
92+
mvn spring-boot:run
93+
```
94+
95+
### Kubernetes Deployment (Recommended)
96+
```bash
97+
# Build all Docker images (5-10 minutes - NEVER CANCEL)
98+
./ops-scripts/base/build-images.sh --all --no-cache
99+
100+
# Deploy to local Kubernetes cluster (HTTP)
101+
./ops-scripts/local/deploy-helm.sh
102+
103+
# Deploy with TLS enabled
104+
./ops-scripts/local/deploy-helm.sh --tls --install-cert-manager
105+
106+
# Access services (HTTP deployment)
107+
kubectl port-forward -n dev service/sentrius-sentrius 8080:8080
108+
kubectl port-forward -n dev service/sentrius-keycloak 8081:8081
109+
```
110+
111+
### Python Agent Execution
112+
```bash
113+
cd python-agent
114+
115+
# Test mode (no external services required)
116+
TEST_MODE=true python3 main.py chat-helper --task-data '{"test": "message"}'
117+
118+
# Production mode (requires Keycloak and Sentrius API)
119+
python3 main.py chat-helper --config application.properties
120+
121+
# Available agents: chat-helper, mcp
122+
python3 main.py --help
123+
```
124+
125+
## Validation and Testing
126+
127+
### Always Validate After Changes
128+
```bash
129+
# Build validation (7m24s - NEVER CANCEL, timeout: 60+ minutes)
130+
mvn clean install
131+
132+
# Test validation (1m3s - NEVER CANCEL, timeout: 30+ minutes)
133+
mvn test
134+
135+
# Python agent validation
136+
cd python-agent && TEST_MODE=true python3 main.py chat-helper
137+
138+
# Helm chart validation
139+
helm lint sentrius-chart
140+
helm lint sentrius-chart-launcher
141+
```
142+
143+
### Manual Testing Scenarios
144+
After making changes, **ALWAYS** test these scenarios:
145+
146+
1. **Java Build Validation**: Run `mvn clean install` and verify all modules build successfully
147+
2. **Python Agent Test**: Run Python agent in test mode to verify framework works
148+
3. **Helm Template Validation**: Ensure charts can render templates without errors
149+
4. **Integration Test**: If infrastructure is available, test OAuth2 authentication flow
150+
151+
### CI/CD Validation
152+
Before committing, ensure changes pass:
153+
```bash
154+
# GitHub Actions equivalent commands
155+
mvn -B package --file pom.xml # Maven build check
156+
mvn test # Test execution
157+
helm lint sentrius-chart* # Helm validation
158+
```
159+
160+
## Architecture Overview
161+
162+
### Maven Modules (12 total)
163+
- **provenance-core**: Event tracking and audit framework
164+
- **core**: Core business logic and SSH session management
165+
- **api**: REST API layer and web interface
166+
- **dataplane**: Secure data transfer and processing
167+
- **llm-core**: Language model integration core
168+
- **llm-dataplane**: LLM data processing layer
169+
- **integration-proxy**: LLM proxy service for AI integration
170+
- **agent-proxy**: Agent communication proxy
171+
- **analytics**: Java-based monitoring agent
172+
- **ai-agent**: Intelligent monitoring and automation agent
173+
- **agent-launcher**: Dynamic agent lifecycle management
174+
- **provenance-ingestor**: Event ingestion and processing
175+
176+
### Key Technologies
177+
- **Spring Boot 3.4.x** with Java 17
178+
- **PostgreSQL** for primary data storage
179+
- **Keycloak** for OAuth2/OIDC authentication
180+
- **Neo4j** for graph analysis (optional)
181+
- **Kafka** for event streaming (optional)
182+
- **OpenTelemetry** for observability
183+
- **Kubernetes/Helm** for container orchestration
184+
185+
## Common Tasks
186+
187+
### Building Specific Modules
188+
```bash
189+
# Build only core modules
190+
mvn clean install -pl core,api,dataplane -am
191+
192+
# Build specific module with dependencies
193+
mvn clean install -pl api -am
194+
```
195+
196+
### Working with Python Agents
197+
```bash
198+
# Create custom agent
199+
cp python-agent/agents/chat_helper python-agent/agents/my_custom -r
200+
# Edit agent logic and register in main.py
201+
202+
# Test custom agent
203+
TEST_MODE=true python3 main.py my-custom
204+
```
205+
206+
### Docker Image Management
207+
```bash
208+
# Build specific images
209+
./ops-scripts/base/build-images.sh --sentrius --sentrius-keycloak
210+
211+
# Build with development certificates
212+
./ops-scripts/base/build-images.sh --all --include-dev-certs
213+
```
214+
215+
### Debugging Tips
216+
- **Maven warnings**: Safe to ignore dependency duplication warnings
217+
- **Database connection failures**: Check PostgreSQL is running and accessible
218+
- **Keycloak authentication errors**: Verify Keycloak is running and client secrets match
219+
- **Build timeouts**: Always use 60+ minute timeouts for builds, 30+ for tests
220+
- **Python dependencies**: Use `pip3 install -r requirements.txt` before running agents
221+
222+
## Performance Expectations
223+
224+
| Operation | Time | Timeout Setting |
225+
|-----------|------|-----------------|
226+
| Maven build (clean install) | 7m24s | 60+ minutes |
227+
| Maven test execution | 1m3s | 30+ minutes |
228+
| Docker image build | 5-10m | 60+ minutes |
229+
| Python dependency install | <1m | 10 minutes |
230+
| Helm chart validation | <30s | 5 minutes |
231+
232+
**NEVER CANCEL** long-running operations. Builds may legitimately take 10+ minutes depending on network and system performance.
233+
234+
## Known Limitations
235+
236+
- **Database Required**: Cannot run API without PostgreSQL connection
237+
- **Authentication Required**: Keycloak must be configured for full functionality
238+
- **Container Dependencies**: Full deployment requires Kubernetes cluster
239+
- **Memory Requirements**: Recommended 8GB+ RAM for full local development
240+
- **Network Dependencies**: Downloads Maven dependencies and container images
241+
242+
## Troubleshooting
243+
244+
### Build Failures
245+
```bash
246+
# Clear Maven cache if build issues occur
247+
rm -rf ~/.m2/repository
248+
mvn clean install
249+
250+
# Check Java version
251+
java -version # Should be 17+
252+
mvn -version # Should be 3.6+
253+
```
254+
255+
### Runtime Issues
256+
```bash
257+
# Check required services
258+
curl http://localhost:8180 # Keycloak health
259+
curl http://localhost:5432 # PostgreSQL (may timeout, that's ok)
260+
261+
# Verify Python environment
262+
cd python-agent && python3 --version && pip3 list
263+
```
264+
265+
### Container Issues
266+
```bash
267+
# Reset Docker environment for local development
268+
eval $(minikube docker-env)
269+
docker images | grep sentrius
270+
```
271+
272+
Always build and test your changes with the exact commands provided above to ensure compatibility with the CI/CD pipeline.

0 commit comments

Comments
 (0)