feat(implementer): major page redesign with hook architecture and responsive diagrams

## Implementer Page Enhancements

### Hero Section Redesign
- Changed title to "External Governance Services for AI Systems"
- Added three value proposition cards (Architectural Separation, Instruction Persistence, Audit Trail)
- Governance-compliant messaging (addresses vs prevents, designed to vs guarantees)
- Mobile-responsive card layout

### New "How It Works" Section
- Pattern Override Challenge explanation
- External Architecture Approach
- Request Flow with Governance diagram
- SVG download links

### New "Hook Architecture" Section (Credibility Layer)
- Architectural enforcement explanation
- Four real enforcement examples:
  * inst_084 GitHub URL Protection
  * inst_008 CSP Compliance
  * inst_027 Governance file protection
  * BoundaryEnforcer values decisions
- New hook-architecture.svg diagram showing PreToolUse flow
- Process separation and exit code enforcement details

### Deployment Section Improvements
- Removed broken "View Online" button
- PDF-only deployment guide download
- Simplified, cleaner presentation

### Responsive Diagrams
- Created system-architecture-mobile.svg (400x600px simplified)
- Created system-architecture-desktop.svg (full detail)
- Picture element with media queries for responsive switching
- Fixed request-flow-sequence.svg (restored from archive)

## Security & Governance

### inst_084 GitHub URL Modification Protocol
- HARD BLOCK on GitHub URL changes without explicit approval
- Prevents accidental private repository exposure
- Implemented in both validate-file-edit.js and validate-file-write.js
- Regex pattern matching for repository name changes
- Detailed error messages with context

### Hook Validator Improvements
- Fixed stderr output issue (console.log → console.error)
- Added checkGitHubURLProtection() function
- Enhanced error messaging for blocked actions

## Documentation

### New Deployment Guide
- Created comprehensive 14KB markdown guide (docs/markdown/deployment-guide.md)
- Generated 284KB PDF (public/docs/pdfs/deployment-guide.pdf)
- Covers: local dev, production, Docker, K8s, AWS, GCP, monitoring, security
- Removed MongoDB credential examples to comply with inst_069/070

### Diagram Archive
- Moved old diagrams to public/docs/diagrams/archive/
- Preserved deployment-architecture-old.svg
- Preserved request-flow-sequence-old.svg
- Preserved system-architecture-old.svg

## Cache & Version
- Bumped version to 0.1.2
- Updated changelog with all implementer changes
- forceUpdate: true for new diagrams and PDFs
- minVersion: 0.1.4

## Context
This addresses user feedback on implementer.html from 2025-10-26:
- Broken diagrams (404 errors, cut off at bottom)
- Need for credibility layer (hook architecture)
- GitHub URL security incident prevention
- Mobile responsiveness issues
- Deployment guide accessibility

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
TheFlow 2025-10-26 23:14:22 +13:00
parent a7ab827bca
commit 3aae86edf9
14 changed files with 1862 additions and 175 deletions

View file

@ -0,0 +1,731 @@
---
title: Deployment Guide
slug: deployment-guide
quadrant: OPERATIONAL
persistence: HIGH
version: 1.0
type: framework
author: Tractatus Framework Team
created: 2025-10-26
modified: 2025-10-26
---
# Tractatus Framework Deployment Guide
This guide covers deploying the Tractatus governance framework for local development, staging, and production environments.
---
## Prerequisites
### System Requirements
- **Node.js**: 18.x or later
- **MongoDB**: 7.0 or later
- **Operating System**: Linux (Ubuntu 22.04+ recommended), macOS, or Windows with WSL2
- **Memory**: Minimum 2GB RAM (4GB+ recommended for production)
- **Storage**: Minimum 10GB available disk space
### Required Tools
```bash
# Verify Node.js installation
node --version # Should be 18.x or later
# Verify MongoDB installation
mongod --version # Should be 7.0 or later
# npm is included with Node.js
npm --version
```
---
## Local Development Setup
### 1. Clone and Install
```bash
# Clone the repository
git clone https://github.com/AgenticGovernance/tractatus-framework.git
cd tractatus-framework
# Install dependencies
npm install
```
### 2. Database Initialization
```bash
# Start MongoDB (if not running as service)
sudo systemctl start mongod
# Initialize database with default collections
npm run init:db
# This creates:
# - governance_rules collection
# - audit_logs collection
# - instruction_history collection
# - session_state collection
```
### 3. Environment Configuration
Create a `.env` file in the project root:
```bash
# Database Configuration
MONGODB_URI=mongodb://localhost:27017/tractatus_dev
MONGODB_DB_NAME=tractatus_dev
# Server Configuration
PORT=9000
NODE_ENV=development
# Session Configuration
SESSION_SECRET=your-random-secret-key-here
# Optional: Anthropic API (for advanced features)
ANTHROPIC_API_KEY=your-api-key-here
```
**Security Note**: Never commit `.env` files to version control. Use `.env.example` as a template.
### 4. Start Development Server
```bash
# Start in development mode with auto-reload
npm run dev
# Or start normally
npm start
# Server runs on http://localhost:9000
```
### 5. Verify Installation
```bash
# Run framework tests
npm test
# Expected output: All 238 tests passing
# Check framework services
node scripts/framework-stats.js
```
Access the local application:
- **Main site**: `http://localhost:9000`
- **Admin dashboard**: `http://localhost:9000/admin/audit-analytics.html`
- **Documentation**: `http://localhost:9000/docs.html`
---
## Production Deployment
### Server Setup
#### 1. Provision Server
**Recommended specifications:**
- **CPU**: 2+ cores
- **RAM**: 4GB minimum (8GB recommended)
- **Storage**: 20GB SSD
- **OS**: Ubuntu 22.04 LTS
#### 2. Install Dependencies
```bash
# Update system packages
sudo apt update && sudo apt upgrade -y
# Install Node.js 18.x
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt install -y nodejs
# Install MongoDB 7.0
curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | \
sudo gpg --dearmor -o /usr/share/keyrings/mongodb-server-7.0.gpg
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] \
https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | \
sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list
sudo apt update
sudo apt install -y mongodb-org
# Start and enable MongoDB
sudo systemctl start mongod
sudo systemctl enable mongod
```
### Production Environment Configuration
Create `/var/www/tractatus/.env`:
```bash
# Production Database
MONGODB_URI=mongodb://localhost:27017/tractatus_production
MONGODB_DB_NAME=tractatus_production
# Production Server
PORT=9000
NODE_ENV=production
# Security
SESSION_SECRET=generate-strong-random-key-here
# Optional: Production API keys
ANTHROPIC_API_KEY=prod-api-key-here
```
### Service Management (systemd)
Create `/etc/systemd/system/tractatus.service`:
```ini
[Unit]
Description=Tractatus Framework Service
After=network.target mongodb.service
Wants=mongodb.service
[Service]
Type=simple
User=tractatus
WorkingDirectory=/var/www/tractatus
Environment="NODE_ENV=production"
EnvironmentFile=/var/www/tractatus/.env
ExecStart=/usr/bin/node src/server.js
Restart=always
RestartSec=10
StandardOutput=journal
StandardError=journal
SyslogIdentifier=tractatus
[Install]
WantedBy=multi-user.target
```
**Enable and start service:**
```bash
# Reload systemd
sudo systemctl daemon-reload
# Enable service to start on boot
sudo systemctl enable tractatus
# Start service
sudo systemctl start tractatus
# Check status
sudo systemctl status tractatus
# View logs
sudo journalctl -u tractatus -f
```
### Reverse Proxy (Nginx)
Create `/etc/nginx/sites-available/tractatus`:
```nginx
server {
listen 80;
server_name agenticgovernance.digital www.agenticgovernance.digital;
location / {
proxy_pass http://localhost:9000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# Static assets caching
location ~* \.(js|css|png|jpg|jpeg|gif|svg|ico|woff|woff2|ttf|eot)$ {
proxy_pass http://localhost:9000;
expires 1y;
add_header Cache-Control "public, immutable";
}
}
```
**Enable site:**
```bash
sudo ln -s /etc/nginx/sites-available/tractatus /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
```
### SSL/TLS Configuration (Let's Encrypt)
```bash
# Install Certbot
sudo apt install -y certbot python3-certbot-nginx
# Obtain SSL certificate
sudo certbot --nginx -d agenticgovernance.digital -d www.agenticgovernance.digital
# Auto-renewal is configured by default
# Test renewal
sudo certbot renew --dry-run
```
---
## Docker Deployment
### Dockerfile
Create `Dockerfile` in project root:
```dockerfile
FROM node:18-alpine
# Set working directory
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install production dependencies only
RUN npm ci --only=production
# Copy application files
COPY . .
# Create non-root user
RUN addgroup -g 1001 -S tractatus && \
adduser -S tractatus -u 1001 && \
chown -R tractatus:tractatus /app
# Switch to non-root user
USER tractatus
# Expose port
EXPOSE 9000
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=40s \
CMD node -e "require('http').get('http://localhost:9000/health', (res) => process.exit(res.statusCode === 200 ? 0 : 1))"
# Start application
CMD ["node", "src/server.js"]
```
### Docker Compose
Create `docker-compose.yml`:
```yaml
version: '3.8'
services:
mongodb:
image: mongo:7.0
container_name: tractatus-mongodb
restart: always
ports:
- "27017:27017"
volumes:
- mongodb-data:/data/db
- mongodb-config:/data/configdb
environment:
MONGO_INITDB_DATABASE: tractatus_production
networks:
- tractatus-network
tractatus:
build: .
container_name: tractatus-app
restart: always
ports:
- "9000:9000"
environment:
- NODE_ENV=production
- MONGODB_URI=mongodb://mongodb:27017/tractatus_production
- PORT=9000
env_file:
- .env
depends_on:
- mongodb
networks:
- tractatus-network
volumes:
- ./logs:/app/logs
volumes:
mongodb-data:
mongodb-config:
networks:
tractatus-network:
driver: bridge
```
### Docker Commands
```bash
# Build and start containers
docker-compose up -d
# View logs
docker-compose logs -f tractatus
# Stop containers
docker-compose down
# Rebuild after code changes
docker-compose up -d --build
# Execute commands in container
docker-compose exec tractatus npm test
# Database backup
docker-compose exec mongodb mongodump --out=/backup
```
---
## Cloud Deployment Patterns
### AWS Deployment
**ECS (Elastic Container Service)**
```yaml
# task-definition.json
{
"family": "tractatus",
"networkMode": "awsvpc",
"requiresCompatibilities": ["FARGATE"],
"cpu": "512",
"memory": "1024",
"containerDefinitions": [
{
"name": "tractatus",
"image": "your-ecr-repo/tractatus:latest",
"portMappings": [
{
"containerPort": 9000,
"protocol": "tcp"
}
],
"environment": [
{
"name": "NODE_ENV",
"value": "production"
},
{
"name": "MONGODB_URI",
"value": "mongodb://your-documentdb-cluster:27017/tractatus"
}
],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs/tractatus",
"awslogs-region": "us-east-1",
"awslogs-stream-prefix": "ecs"
}
}
}
]
}
```
### Google Cloud Platform
**Cloud Run Deployment**
```bash
# Build container
gcloud builds submit --tag gcr.io/PROJECT-ID/tractatus
# Deploy to Cloud Run
gcloud run deploy tractatus \
--image gcr.io/PROJECT-ID/tractatus \
--platform managed \
--region us-central1 \
--allow-unauthenticated \
--set-env-vars MONGODB_URI=mongodb://mongo-instance:27017/tractatus
```
### Kubernetes
Create `k8s/deployment.yaml`:
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: tractatus
spec:
replicas: 3
selector:
matchLabels:
app: tractatus
template:
metadata:
labels:
app: tractatus
spec:
containers:
- name: tractatus
image: tractatus:latest
ports:
- containerPort: 9000
env:
- name: NODE_ENV
value: "production"
- name: MONGODB_URI
valueFrom:
secretKeyRef:
name: tractatus-secrets
key: mongodb-uri
resources:
requests:
memory: "512Mi"
cpu: "250m"
limits:
memory: "1Gi"
cpu: "500m"
livenessProbe:
httpGet:
path: /health
port: 9000
initialDelaySeconds: 30
periodSeconds: 10
readinessProbe:
httpGet:
path: /health
port: 9000
initialDelaySeconds: 5
periodSeconds: 5
---
apiVersion: v1
kind: Service
metadata:
name: tractatus-service
spec:
selector:
app: tractatus
ports:
- protocol: TCP
port: 80
targetPort: 9000
type: LoadBalancer
```
---
## Database Management
### Backup and Restore
**Backup MongoDB:**
```bash
# Local backup
mongodump --db tractatus_production --out /backup/$(date +%Y%m%d)
# Automated daily backup script
#!/bin/bash
BACKUP_DIR="/var/backups/mongodb"
DATE=$(date +%Y%m%d_%H%M%S)
mongodump --db tractatus_production --out $BACKUP_DIR/$DATE
find $BACKUP_DIR -type d -mtime +7 -exec rm -rf {} +
```
**Restore MongoDB:**
```bash
mongorestore --db tractatus_production /backup/20251026/tractatus_production
```
### Database Migrations
```bash
# Run migrations
npm run migrate
# Rollback last migration
npm run migrate:rollback
```
---
## Monitoring and Logging
### Health Checks
The framework includes a health endpoint:
```javascript
// GET /health
{
"status": "healthy",
"uptime": 12345,
"mongodb": "connected",
"services": {
"BoundaryEnforcer": "active",
"InstructionPersistence": "active",
"CrossReferenceValidator": "active",
"ContextPressureMonitor": "active",
"MetacognitiveVerifier": "active",
"PluralisticDeliberationOrchestrator": "active"
}
}
```
### Application Logs
```bash
# View application logs (systemd)
sudo journalctl -u tractatus -f
# View specific time range
sudo journalctl -u tractatus --since "1 hour ago"
# Export logs
sudo journalctl -u tractatus > tractatus-logs.txt
```
### Audit Dashboard
Access the audit analytics dashboard at:
```
https://your-domain.com/admin/audit-analytics.html
```
---
## Security Considerations
### Environment Variables
- **Never commit** `.env` files to version control
- Use environment-specific configuration files
- Rotate secrets regularly (SESSION_SECRET, API keys)
### MongoDB Security
```bash
# Enable authentication
mongo
> use admin
> db.createUser({
user: "tractatus_admin",
pwd: "strong-password-here",
roles: [{ role: "readWrite", db: "tractatus_production" }]
})
> exit
# Update MONGODB_URI with auth
MONGODB_URI=mongodb://tractatus_admin:password@localhost:27017/tractatus_production
```
### Firewall Configuration
```bash
# Allow only necessary ports
sudo ufw allow 22/tcp # SSH
sudo ufw allow 80/tcp # HTTP
sudo ufw allow 443/tcp # HTTPS
sudo ufw enable
# Block direct access to MongoDB from outside
sudo ufw deny 27017/tcp
```
### SSL/TLS Best Practices
- Use Let's Encrypt for free SSL certificates
- Enable HSTS (HTTP Strict Transport Security)
- Configure strong cipher suites in Nginx
- Redirect all HTTP to HTTPS
---
## Troubleshooting
### Common Issues
**MongoDB connection failed:**
```bash
# Check MongoDB is running
sudo systemctl status mongod
# Check logs
sudo journalctl -u mongod -f
# Verify connection string
mongo $MONGODB_URI
```
**Port already in use:**
```bash
# Find process using port 9000
sudo lsof -i :9000
# Kill process
sudo kill -9 <PID>
```
**Framework services not initialized:**
```bash
# Run framework health check
node scripts/framework-stats.js
# Check session state
cat .claude/session-state.json
```
---
## Performance Optimization
### Database Indexing
```javascript
// Create indexes for frequently queried fields
db.audit_logs.createIndex({ timestamp: -1 });
db.audit_logs.createIndex({ service: 1, timestamp: -1 });
db.governance_rules.createIndex({ id: 1 }, { unique: true });
db.instruction_history.createIndex({ session_id: 1, timestamp: -1 });
```
### Caching Strategy
- Static assets served with 1-year cache headers
- API responses cached with appropriate TTL
- MongoDB query result caching for read-heavy operations
### Resource Limits
```bash
# Increase Node.js memory limit
NODE_OPTIONS=--max-old-space-size=4096 node src/server.js
```
---
## Next Steps
- **Implementation Guide**: See [Implementation Guide](/docs/implementation-guide) for integration patterns
- **API Reference**: Visit `/api-reference.html` for complete API documentation
- **GitHub Repository**: Access code examples at [tractatus-framework](https://github.com/AgenticGovernance/tractatus-framework)
---
**Document Version**: 1.0
**Last Updated**: 2025-10-26
**Maintained by**: Tractatus Framework Team

View file

@ -41,7 +41,7 @@
<!-- Monitoring Stack -->
<rect x="480" y="120" width="280" height="140" class="monitor" rx="6"/>
<text x="620" y="145" class="label" text-anchor="middle" fill="#fff">Monitoring & Logging</text>
<text x="620" y="145" class="label" text-anchor="middle" fill="#fff">Monitoring &amp; Logging</text>
<text x="500" y="175" class="small" fill="#fef3c7">• Audit Dashboard (Port 9000)</text>
<text x="500" y="193" class="small" fill="#fef3c7">• Service Logs (journalctl)</text>
<text x="500" y="211" class="small" fill="#fef3c7">• Performance Metrics</text>
@ -50,7 +50,7 @@
<!-- Backup & Security -->
<rect x="480" y="300" width="280" height="140" class="server" rx="6" stroke="#dc2626" stroke-width="3"/>
<text x="620" y="325" class="label" text-anchor="middle" fill="#dc2626">Security & Backup</text>
<text x="620" y="325" class="label" text-anchor="middle" fill="#dc2626">Security &amp; Backup</text>
<text x="500" y="355" class="small">• Automated DB backups</text>
<text x="500" y="373" class="small">• SSH key-based access</text>
<text x="500" y="391" class="small">• Defense-in-depth (5 layers)</text>

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View file

@ -0,0 +1,116 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 850 700">
<defs>
<style>
.actor { fill: #fff; stroke: #2563eb; stroke-width: 2; }
.lifeline { stroke: #cbd5e1; stroke-width: 2; stroke-dasharray: 5,5; }
.activation { fill: #dbeafe; stroke: #2563eb; stroke-width: 2; }
.arrow { stroke: #475569; stroke-width: 2; fill: none; marker-end: url(#arrowSeq); }
.return { stroke: #94a3b8; stroke-width: 2; fill: none; stroke-dasharray: 5,3; marker-end: url(#arrowReturn); }
.label { fill: #1e293b; font-family: Arial, sans-serif; font-size: 11px; }
.title { fill: #0f172a; font-family: Arial, sans-serif; font-size: 18px; font-weight: bold; }
.note { fill: #fef3c7; stroke: #f59e0b; stroke-width: 1; }
.note-text { fill: #78350f; font-family: Arial, sans-serif; font-size: 10px; }
</style>
<marker id="arrowSeq" markerWidth="8" markerHeight="8" refX="7" refY="4" orient="auto">
<polygon points="0 0, 8 4, 0 8" fill="#475569" />
</marker>
<marker id="arrowReturn" markerWidth="8" markerHeight="8" refX="7" refY="4" orient="auto">
<polygon points="0 0, 8 4, 0 8" fill="#94a3b8" />
</marker>
</defs>
<text x="425" y="30" class="title" text-anchor="middle">AI Decision Flow with Governance</text>
<!-- Actors -->
<rect x="30" y="60" width="100" height="40" class="actor" rx="5"/>
<text x="80" y="85" class="label" text-anchor="middle" font-weight="bold">User</text>
<rect x="180" y="60" width="120" height="40" class="actor" rx="5"/>
<text x="240" y="85" class="label" text-anchor="middle" font-weight="bold">AI Agent</text>
<rect x="350" y="60" width="130" height="40" class="actor" rx="5"/>
<text x="415" y="85" class="label" text-anchor="middle" font-weight="bold">Governance</text>
<rect x="530" y="60" width="130" height="40" class="actor" rx="5"/>
<text x="595" y="85" class="label" text-anchor="middle" font-weight="bold">MongoDB</text>
<rect x="710" y="60" width="100" height="40" class="actor" rx="5"/>
<text x="760" y="85" class="label" text-anchor="middle" font-weight="bold">Human</text>
<!-- Lifelines -->
<line x1="80" y1="100" x2="80" y2="650" class="lifeline"/>
<line x1="240" y1="100" x2="240" y2="650" class="lifeline"/>
<line x1="415" y1="100" x2="415" y2="650" class="lifeline"/>
<line x1="595" y1="100" x2="595" y2="650" class="lifeline"/>
<line x1="760" y1="100" x2="760" y2="650" class="lifeline"/>
<!-- Step 1: User Request -->
<path d="M 80 130 L 240 130" class="arrow"/>
<text x="160" y="125" class="label">1. "Change privacy policy"</text>
<!-- Step 2: AI analyzes -->
<rect x="230" y="135" width="20" height="40" class="activation"/>
<text x="270" y="160" class="label">2. Analyze request</text>
<!-- Step 3: Check BoundaryEnforcer -->
<path d="M 240 180 L 415 180" class="arrow"/>
<text x="310" y="175" class="label">3. checkBoundary(decision)</text>
<rect x="405" y="185" width="20" height="60" class="activation"/>
<!-- Step 4: Query instructions -->
<path d="M 415 210 L 595 210" class="arrow"/>
<text x="480" y="205" class="label">4. Get stored instructions</text>
<rect x="585" y="215" width="20" height="30" class="activation"/>
<path d="M 595 240 L 415 240" class="return"/>
<!-- Step 5: Boundary violation detected -->
<path d="M 415 260 L 240 260" class="return"/>
<text x="300" y="255" class="label">5. REJECTED (12.1 - Values)</text>
<!-- Note -->
<rect x="250" y="270" width="200" height="45" class="note" rx="3"/>
<text x="260" y="285" class="note-text">BoundaryEnforcer: "Values decisions</text>
<text x="260" y="298" class="note-text">require human approval"</text>
<text x="260" y="311" class="note-text">(Tractatus 12.1)</text>
<!-- Step 6: Request human approval -->
<path d="M 240 330 L 760 330" class="arrow"/>
<text x="450" y="325" class="label">6. Request approval (with AI analysis)</text>
<rect x="750" y="335" width="20" height="50" class="activation"/>
<!-- Step 7: Human decision -->
<path d="M 760 380 L 240 380" class="return"/>
<text x="450" y="375" class="label">7. Approved with modifications</text>
<!-- Step 8: Log decision -->
<rect x="230" y="390" width="20" height="40" class="activation"/>
<path d="M 240 410 L 415 410" class="arrow"/>
<text x="300" y="405" class="label">8. Log audit trail</text>
<rect x="405" y="415" width="20" height="40" class="activation"/>
<path d="M 415 435 L 595 435" class="arrow"/>
<text x="480" y="430" class="label">9. Store audit</text>
<rect x="585" y="440" width="20" height="30" class="activation"/>
<path d="M 595 465 L 415 465" class="return"/>
<path d="M 415 480 L 240 480" class="return"/>
<!-- Step 10: Execute with safeguards -->
<rect x="230" y="490" width="20" height="80" class="activation"/>
<text x="260" y="520" class="label">10. Execute decision</text>
<text x="260" y="535" class="label">with human-approved</text>
<text x="260" y="550" class="label">modifications</text>
<!-- Step 11: Return to user -->
<path d="M 240 580 L 80 580" class="return"/>
<text x="140" y="575" class="label">11. Completed (with audit trail)</text>
<!-- Summary box -->
<rect x="50" y="610" width="750" height="35" fill="#eff6ff" stroke="#3b82f6" stroke-width="2" rx="4"/>
<text x="425" y="633" class="label" text-anchor="middle" fill="#1e40af">
<tspan font-weight="bold">Result:</tspan> Human oversight enforced architecturally • Audit trail created • Values preserved
</text>
</svg>

After

Width:  |  Height:  |  Size: 5.4 KiB

View file

@ -0,0 +1,91 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 600">
<defs>
<style>
.component { fill: #fff; stroke: #2563eb; stroke-width: 2; }
.service { fill: #dbeafe; stroke: #1e40af; stroke-width: 2; }
.data { fill: #1e293b; stroke: #0f172a; stroke-width: 2; }
.text { fill: #1e293b; font-family: Arial, sans-serif; font-size: 14px; }
.label { fill: #1e293b; font-family: Arial, sans-serif; font-size: 12px; font-weight: bold; }
.small { fill: #64748b; font-family: Arial, sans-serif; font-size: 10px; }
.arrow { stroke: #475569; stroke-width: 2; fill: none; marker-end: url(#arrowhead); }
.section-label { fill: #475569; font-family: Arial, sans-serif; font-size: 16px; font-weight: bold; }
</style>
<marker id="arrowhead" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
<polygon points="0 0, 10 3, 0 6" fill="#475569" />
</marker>
</defs>
<!-- Application Layer -->
<text x="400" y="30" class="section-label" text-anchor="middle">Application Layer</text>
<rect x="300" y="50" width="200" height="60" class="component" rx="5"/>
<text x="400" y="75" class="label" text-anchor="middle">AI Application</text>
<text x="400" y="95" class="small" text-anchor="middle">Claude Code / Custom LLM</text>
<!-- Governance Layer -->
<text x="400" y="160" class="section-label" text-anchor="middle">Tractatus Governance Layer</text>
<!-- Row 1: 3 services -->
<rect x="50" y="190" width="180" height="70" class="service" rx="5"/>
<text x="140" y="215" class="label" text-anchor="middle">BoundaryEnforcer</text>
<text x="140" y="235" class="small" text-anchor="middle">Values Decisions</text>
<text x="140" y="250" class="small" text-anchor="middle">(Tractatus 12.1-12.7)</text>
<rect x="310" y="190" width="180" height="70" class="service" rx="5"/>
<text x="400" y="215" class="label" text-anchor="middle">InstructionPersistence</text>
<text x="400" y="235" class="small" text-anchor="middle">Classifier</text>
<text x="400" y="250" class="small" text-anchor="middle">(Quadrant + Persistence)</text>
<rect x="570" y="190" width="180" height="70" class="service" rx="5"/>
<text x="660" y="215" class="label" text-anchor="middle">CrossReference</text>
<text x="660" y="235" class="small" text-anchor="middle">Validator</text>
<text x="660" y="250" class="small" text-anchor="middle">(Pattern Override Prevention)</text>
<!-- Row 2: 3 services -->
<rect x="50" y="290" width="180" height="70" class="service" rx="5"/>
<text x="140" y="315" class="label" text-anchor="middle">ContextPressure</text>
<text x="140" y="335" class="small" text-anchor="middle">Monitor</text>
<text x="140" y="350" class="small" text-anchor="middle">(Token &amp; Complexity)</text>
<rect x="310" y="290" width="180" height="70" class="service" rx="5"/>
<text x="400" y="315" class="label" text-anchor="middle">Metacognitive</text>
<text x="400" y="335" class="small" text-anchor="middle">Verifier</text>
<text x="400" y="350" class="small" text-anchor="middle">(Confidence Scoring)</text>
<rect x="570" y="290" width="180" height="70" class="service" rx="5"/>
<text x="660" y="315" class="label" text-anchor="middle">Pluralistic</text>
<text x="660" y="335" class="small" text-anchor="middle">Deliberation</text>
<text x="660" y="350" class="small" text-anchor="middle">(Multi-Stakeholder)</text>
<!-- Data Layer -->
<text x="400" y="410" class="section-label" text-anchor="middle">Data Layer</text>
<rect x="200" y="440" width="180" height="80" class="service" rx="5"/>
<text x="290" y="465" class="label" text-anchor="middle">MemoryProxy v3</text>
<text x="290" y="485" class="small" text-anchor="middle">Hybrid Storage</text>
<text x="290" y="505" class="small" text-anchor="middle">(MongoDB + Optional API)</text>
<rect x="420" y="440" width="180" height="80" class="data" rx="5"/>
<text x="510" y="465" class="label" text-anchor="middle" fill="#fff">MongoDB</text>
<text x="510" y="485" class="small" text-anchor="middle" fill="#94a3b8">Instructions Database</text>
<text x="510" y="505" class="small" text-anchor="middle" fill="#94a3b8">Audit Logs</text>
<!-- Arrows -->
<!-- Application to Services -->
<path d="M 400 110 L 140 190" class="arrow"/>
<path d="M 400 110 L 400 190" class="arrow"/>
<path d="M 400 110 L 660 190" class="arrow"/>
<!-- Services to MemoryProxy -->
<path d="M 140 260 L 250 440" class="arrow"/>
<path d="M 400 260 L 320 440" class="arrow"/>
<path d="M 660 260 L 350 440" class="arrow"/>
<path d="M 140 360 L 270 440" class="arrow"/>
<path d="M 400 360 L 290 440" class="arrow"/>
<path d="M 660 360 L 340 440" class="arrow"/>
<!-- MemoryProxy to MongoDB -->
<path d="M 380 480 L 420 480" class="arrow"/>
<!-- Legend -->
<text x="50" y="570" class="small" fill="#64748b">6 Governance Services • Persistent Storage • Production-Tested Architecture</text>
</svg>

After

Width:  |  Height:  |  Size: 4.9 KiB

View file

@ -0,0 +1,99 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 600">
<defs>
<style>
.box { fill: #fff; stroke: #2563eb; stroke-width: 2; rx: 8; }
.box-ai { fill: #dbeafe; stroke: #3b82f6; stroke-width: 3; }
.box-hook { fill: #fef3c7; stroke: #f59e0b; stroke-width: 3; }
.box-validate { fill: #f0fdf4; stroke: #10b981; stroke-width: 2; }
.box-block { fill: #fee2e2; stroke: #ef4444; stroke-width: 3; }
.box-allow { fill: #f0fdf4; stroke: #10b981; stroke-width: 3; }
.label { fill: #1e293b; font-family: Arial, sans-serif; font-size: 16px; font-weight: bold; text-anchor: middle; }
.sublabel { fill: #64748b; font-family: Arial, sans-serif; font-size: 13px; text-anchor: middle; }
.code { fill: #475569; font-family: 'Courier New', monospace; font-size: 11px; }
.arrow { stroke: #64748b; stroke-width: 2; fill: none; marker-end: url(#arrow); }
.arrow-block { stroke: #ef4444; stroke-width: 3; fill: none; marker-end: url(#arrow-block); }
.arrow-allow { stroke: #10b981; stroke-width: 3; fill: none; marker-end: url(#arrow-allow); }
.title { fill: #0f172a; font-family: Arial, sans-serif; font-size: 20px; font-weight: bold; text-anchor: middle; }
.badge { fill: #dc2626; font-family: Arial, sans-serif; font-size: 12px; font-weight: bold; }
</style>
<marker id="arrow" markerWidth="10" markerHeight="10" refX="9" refY="5" orient="auto">
<polygon points="0 0, 10 5, 0 10" fill="#64748b" />
</marker>
<marker id="arrow-block" markerWidth="10" markerHeight="10" refX="9" refY="5" orient="auto">
<polygon points="0 0, 10 5, 0 10" fill="#ef4444" />
</marker>
<marker id="arrow-allow" markerWidth="10" markerHeight="10" refX="9" refY="5" orient="auto">
<polygon points="0 0, 10 5, 0 10" fill="#10b981" />
</marker>
</defs>
<text x="400" y="30" class="title">Architectural Enforcement: PreToolUse Hook Flow</text>
<text x="400" y="50" class="sublabel">How governance is enforced before AI can execute actions</text>
<rect x="50" y="80" width="200" height="80" class="box-ai" rx="8"/>
<text x="150" y="110" class="label">AI Agent Action</text>
<text x="150" y="130" class="sublabel">Edit(/public/index.html)</text>
<text x="150" y="145" class="code">Change: github.com/A/repo1</text>
<text x="150" y="157" class="code"> → github.com/A/repo2</text>
<path d="M 250 120 L 310 120" class="arrow"/>
<text x="280" y="110" class="sublabel" style="font-size: 11px;">intercept</text>
<rect x="310" y="80" width="200" height="80" class="box-hook" rx="8"/>
<text x="410" y="110" class="label">PreToolUse Hook</text>
<text x="410" y="130" class="sublabel">validate-file-edit.js</text>
<text x="410" y="145" class="code">BEFORE execution</text>
<text x="410" y="157" class="sublabel" style="fill: #f59e0b; font-weight: bold;">⚠ Architectural layer</text>
<path d="M 410 160 L 410 190" class="arrow"/>
<text x="445" y="180" class="sublabel" style="font-size: 11px;">run checks</text>
<rect x="70" y="200" width="180" height="70" class="box-validate" rx="6"/>
<text x="160" y="225" class="label" style="font-size: 14px;">✓ CSP Compliance</text>
<text x="160" y="243" class="sublabel" style="font-size: 11px;">No inline styles/scripts</text>
<text x="160" y="257" class="code" style="font-size: 10px;">checkCSPCompliance()</text>
<rect x="270" y="200" width="180" height="70" class="box-validate" rx="6"/>
<text x="360" y="225" class="label" style="font-size: 14px;">⚠ GitHub URLs</text>
<text x="360" y="243" class="sublabel" style="font-size: 11px;">inst_084: Hard block</text>
<text x="360" y="257" class="code" style="font-size: 10px;">checkGitHubURLProtection()</text>
<rect x="320" y="207" width="80" height="18" fill="#dc2626" rx="3"/>
<text x="360" y="219" class="badge" fill="#fff" text-anchor="middle">VIOLATION</text>
<rect x="470" y="200" width="180" height="70" class="box-validate" rx="6"/>
<text x="560" y="225" class="label" style="font-size: 14px;">✓ Boundaries</text>
<text x="560" y="243" class="sublabel" style="font-size: 11px;">Values decisions blocked</text>
<text x="560" y="257" class="code" style="font-size: 10px;">checkBoundaryViolation()</text>
<path d="M 360 270 L 360 310" class="arrow"/>
<polygon points="360,310 420,340 360,370 300,340" fill="#fff" stroke="#64748b" stroke-width="2"/>
<text x="360" y="345" class="label" style="font-size: 14px;">Pass?</text>
<path d="M 300 340 L 150 340 L 150 400" class="arrow-block"/>
<text x="220" y="332" class="sublabel" fill="#ef4444" style="font-weight: bold;">NO</text>
<rect x="50" y="400" width="200" height="100" class="box-block" rx="8"/>
<text x="150" y="430" class="label" fill="#dc2626">🚫 HARD BLOCK</text>
<text x="150" y="450" class="sublabel">Exit code: 2</text>
<text x="150" y="468" class="code">Action halted</text>
<text x="150" y="482" class="code">Error logged to audit</text>
<text x="150" y="496" class="sublabel" fill="#dc2626" style="font-weight: bold;">Cannot be bypassed</text>
<path d="M 420 340 L 570 340 L 570 400" class="arrow-allow"/>
<text x="500" y="332" class="sublabel" fill="#10b981" style="font-weight: bold;">YES</text>
<rect x="470" y="400" width="200" height="100" class="box-allow" rx="8"/>
<text x="570" y="430" class="label" fill="#059669">✓ ALLOWED</text>
<text x="570" y="450" class="sublabel">Exit code: 0</text>
<text x="570" y="468" class="code">Tool execution proceeds</text>
<text x="570" y="482" class="code">Audit log: PASSED</text>
<text x="570" y="496" class="sublabel" fill="#059669">Governance verified</text>
<rect x="50" y="520" width="700" height="70" fill="#f8fafc" stroke="#cbd5e1" stroke-width="1" rx="6"/>
<text x="60" y="542" class="label" style="font-size: 14px; text-anchor: start;">Key Enforcement Mechanisms:</text>
<text x="70" y="562" class="code" style="font-size: 12px; text-anchor: start;">• Hooks run in separate process (Node.js child_process) AI cannot access or modify</text>
<text x="70" y="577" class="code" style="font-size: 12px; text-anchor: start;">• Exit codes control execution: 0=proceed, 2=block architectural enforcement, not voluntary compliance</text>
</svg>

After

Width:  |  Height:  |  Size: 6.1 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 38 KiB

View file

@ -0,0 +1,64 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 600">
<defs>
<style>
.layer { fill: #fff; stroke: #2563eb; stroke-width: 2; rx: 8; }
.layer-agent { fill: #dbeafe; stroke: #3b82f6; stroke-width: 3; }
.layer-governance { fill: #f0fdf4; stroke: #10b981; stroke-width: 3; }
.layer-storage { fill: #fef9c3; stroke: #eab308; stroke-width: 2; }
.layer-human { fill: #fce7f3; stroke: #ec4899; stroke-width: 3; }
.label { fill: #1e293b; font-family: Arial, sans-serif; font-size: 14px; font-weight: bold; text-anchor: middle; }
.sublabel { fill: #64748b; font-family: Arial, sans-serif; font-size: 11px; text-anchor: middle; }
.arrow { stroke: #64748b; stroke-width: 2; fill: none; marker-end: url(#arrow); }
.title { fill: #0f172a; font-family: Arial, sans-serif; font-size: 16px; font-weight: bold; text-anchor: middle; }
</style>
<marker id="arrow" markerWidth="8" markerHeight="8" refX="7" refY="4" orient="auto">
<polygon points="0 0, 8 4, 0 8" fill="#64748b" />
</marker>
</defs>
<text x="200" y="25" class="title">Tractatus Architecture</text>
<text x="200" y="42" class="sublabel">(Simplified View)</text>
<rect x="30" y="70" width="340" height="90" class="layer-agent" rx="8"/>
<text x="200" y="95" class="label">Agent Runtime Layer</text>
<text x="200" y="115" class="sublabel">LangChain • AutoGPT • CrewAI</text>
<text x="200" y="130" class="sublabel">Claude Code • Custom Agents</text>
<text x="200" y="145" class="sublabel">Tool Use • Planning • Execution</text>
<path d="M 200 160 L 200 190" class="arrow"/>
<text x="250" y="180" class="sublabel">Governance checks</text>
<rect x="30" y="190" width="340" height="120" class="layer-governance" rx="8"/>
<text x="200" y="215" class="label">Tractatus Governance Layer</text>
<text x="200" y="235" class="sublabel">6 External Services:</text>
<text x="200" y="252" class="sublabel">BoundaryEnforcer • CrossReference</text>
<text x="200" y="267" class="sublabel">InstructionPersistence • ContextPressure</text>
<text x="200" y="282" class="sublabel">Metacognitive • PluralisticDeliberation</text>
<text x="200" y="299" class="sublabel" fill="#ef4444">⚠ External architecture</text>
<path d="M 200 310 L 200 340" class="arrow"/>
<text x="250" y="330" class="sublabel">Audit logging</text>
<rect x="30" y="340" width="340" height="100" class="layer-storage" rx="8"/>
<text x="200" y="365" class="label">Persistent Storage Layer</text>
<text x="200" y="385" class="sublabel">MongoDB Collections:</text>
<text x="200" y="402" class="sublabel">governance_rules • audit_logs</text>
<text x="200" y="417" class="sublabel">instruction_history • session_state</text>
<text x="200" y="432" class="sublabel" fill="#ef4444">Audit trail design</text>
<path d="M 100 310 L 60 340 L 60 460 L 100 480" class="arrow"/>
<text x="20" y="390" class="sublabel" fill="#ec4899">Boundary</text>
<text x="20" y="405" class="sublabel" fill="#ec4899">violations</text>
<path d="M 100 490 L 60 500 L 60 430 L 100 320" class="arrow"/>
<text x="15" y="455" class="sublabel" fill="#ec4899">Approval/</text>
<text x="15" y="470" class="sublabel" fill="#ec4899">Rejection</text>
<rect x="30" y="480" width="340" height="90" class="layer-human" rx="8"/>
<text x="200" y="505" class="label">Human Oversight</text>
<text x="200" y="525" class="sublabel">Values Decisions</text>
<text x="200" y="540" class="sublabel">Strategic Changes • Boundary Violations</text>
<text x="200" y="560" class="sublabel" style="font-style: italic;">Final authority on incommensurable values</text>
<text x="200" y="590" class="sublabel" fill="#64748b">View full diagram for details →</text>
</svg>

After

Width:  |  Height:  |  Size: 3.7 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

View file

@ -34,11 +34,18 @@
body { font-size: 16px; } /* Prevent iOS zoom on input focus */
}
/* Diagram sizing */
/* Diagram sizing - responsive */
.diagram-img {
max-width: 600px;
max-width: 100%;
width: 100%;
height: auto;
display: block;
}
/* Diagram container with horizontal scroll for small screens */
.diagram-container {
overflow-x: auto;
border-radius: 0.5rem;
}
</style>
</head>
@ -62,12 +69,31 @@
<div class="bg-gradient-to-br from-blue-50 to-indigo-50 py-16">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="text-center">
<h1 class="text-5xl font-bold text-gray-900 mb-6">
Framework Implementation Guide
<h1 class="text-4xl sm:text-5xl font-bold text-gray-900 mb-6">
External Governance Services for AI Systems
</h1>
<p class="text-xl text-gray-600 max-w-3xl mx-auto">
Technical documentation for integrating the 6 Tractatus governance services into your AI systems. Production-tested architecture and real code examples.
<p class="text-lg sm:text-xl text-gray-600 max-w-3xl mx-auto mb-8">
Six architectural services addressing pattern override and decision traceability in agentic systems. Development framework for instruction persistence, boundary enforcement, and audit logging.
</p>
<!-- Value Props Grid (Mobile-Friendly Cards) -->
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 max-w-4xl mx-auto mt-8">
<div class="bg-white rounded-lg p-4 shadow-sm">
<div class="text-2xl mb-2">🏗️</div>
<h3 class="font-semibold text-gray-900 mb-1">Architectural Separation</h3>
<p class="text-sm text-gray-600">Governance runs external to AI model</p>
</div>
<div class="bg-white rounded-lg p-4 shadow-sm">
<div class="text-2xl mb-2">💾</div>
<h3 class="font-semibold text-gray-900 mb-1">Instruction Persistence</h3>
<p class="text-sm text-gray-600">Validates instructions across context</p>
</div>
<div class="bg-white rounded-lg p-4 shadow-sm">
<div class="text-2xl mb-2">📋</div>
<h3 class="font-semibold text-gray-900 mb-1">Audit Trail by Design</h3>
<p class="text-sm text-gray-600">MongoDB logs with service attribution</p>
</div>
</div>
</div>
</div>
</div>
@ -76,21 +102,98 @@
<div class="bg-white border-b border-gray-200">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-4">
<nav class="flex justify-center flex-wrap gap-4 sm:gap-8" aria-label="Page sections">
<a href="#how-it-works" class="text-blue-600 hover:text-blue-800 font-medium px-2 py-2 min-h-[44px] flex items-center">How It Works</a>
<a href="#architecture" class="text-blue-600 hover:text-blue-800 font-medium px-2 py-2 min-h-[44px] flex items-center">Architecture</a>
<a href="#hooks" class="text-blue-600 hover:text-blue-800 font-medium px-2 py-2 min-h-[44px] flex items-center">Hook Architecture</a>
<a href="#deployment" class="text-blue-600 hover:text-blue-800 font-medium px-2 py-2 min-h-[44px] flex items-center">Deployment</a>
<a href="#services" class="text-blue-600 hover:text-blue-800 font-medium px-2 py-2 min-h-[44px] flex items-center">Services</a>
<a href="#api" class="text-blue-600 hover:text-blue-800 font-medium px-2 py-2 min-h-[44px] flex items-center">API Reference</a>
<a href="#examples" class="text-blue-600 hover:text-blue-800 font-medium px-2 py-2 min-h-[44px] flex items-center">Code Examples</a>
<a href="#deployment" class="text-blue-600 hover:text-blue-800 font-medium px-2 py-2 min-h-[44px] flex items-center">Deployment</a>
<a href="#patterns" class="text-blue-600 hover:text-blue-800 font-medium px-2 py-2 min-h-[44px] flex items-center">Integration Patterns</a>
<a href="#roadmap" class="text-blue-600 hover:text-blue-800 font-medium px-2 py-2 min-h-[44px] flex items-center">Roadmap</a>
</nav>
</div>
</div>
<!-- Framework Architecture -->
<!-- Main Content -->
<main id="main-content">
<div id="architecture" class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-16">
<h2 class="text-3xl font-bold text-gray-900 mb-8">Framework Architecture</h2>
<!-- How It Works -->
<div id="how-it-works" class="bg-white py-16">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<h2 class="text-3xl font-bold text-gray-900 mb-4">How It Works</h2>
<!-- Problem Context -->
<div class="bg-blue-50 border-l-4 border-blue-500 rounded-r-lg p-6 mb-8">
<h3 class="font-semibold text-gray-900 mb-2">Pattern Override Challenge</h3>
<p class="text-gray-700 mb-3">
AI systems operating across extended interactions may not maintain instruction consistency as context evolves. Instructions given early can be deprioritized or reinterpreted.
</p>
<h3 class="font-semibold text-gray-900 mb-2">External Architecture Approach</h3>
<p class="text-gray-700">
Tractatus services run external to the AI model, providing boundary validation, instruction classification, and audit logging through architectural separation.
</p>
</div>
<!-- Request Flow Diagram -->
<div class="bg-white rounded-xl shadow-lg p-6 sm:p-8">
<h3 class="text-xl font-bold text-gray-900 mb-4">Request Flow with Governance</h3>
<p class="text-sm text-gray-600 mb-4">
Example: AI decision flow with boundary enforcement—from user request through governance validation to human approval.
</p>
<div class="bg-gray-50 rounded-lg p-4 sm:p-6 diagram-container">
<img src="/docs/diagrams/request-flow-sequence.svg"
alt="Request Flow Sequence: How AI decisions are governed"
class="diagram-img"
loading="lazy">
</div>
<div class="mt-6">
<a href="/docs/diagrams/request-flow-sequence.svg" download
class="inline-flex items-center bg-blue-600 text-white px-4 py-2 rounded-lg text-sm font-semibold hover:bg-blue-700 transition min-h-[44px]">
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/>
</svg>
Download SVG
</a>
</div>
</div>
</div>
</div>
<!-- Framework Architecture -->
<div id="architecture" class="bg-gray-50 py-16">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<h2 class="text-3xl font-bold text-gray-900 mb-4">System Architecture</h2>
<!-- Six Core Services Context -->
<div class="bg-white rounded-lg p-6 mb-8">
<h3 class="font-semibold text-gray-900 mb-3">Six Core Services</h3>
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 text-sm">
<div class="flex items-start">
<span class="text-blue-600 mr-2"></span>
<span>BoundaryEnforcer (Tractatus 12.1-12.7)</span>
</div>
<div class="flex items-start">
<span class="text-blue-600 mr-2"></span>
<span>InstructionPersistenceClassifier</span>
</div>
<div class="flex items-start">
<span class="text-blue-600 mr-2"></span>
<span>CrossReferenceValidator</span>
</div>
<div class="flex items-start">
<span class="text-blue-600 mr-2"></span>
<span>ContextPressureMonitor</span>
</div>
<div class="flex items-start">
<span class="text-blue-600 mr-2"></span>
<span>MetacognitiveVerifier</span>
</div>
<div class="flex items-start">
<span class="text-blue-600 mr-2"></span>
<span>PluralisticDeliberationOrchestrator</span>
</div>
</div>
</div>
<!-- Main Flow Diagram -->
<div class="bg-white rounded-xl shadow-lg p-8 mb-8">
@ -139,13 +242,17 @@
<h3 class="text-xl font-bold text-gray-900 mb-4">System Architecture</h3>
<p class="text-sm text-gray-600 mb-4">High-level overview showing how the 6 governance services integrate with your application and data layer.</p>
<div class="bg-gray-50 rounded-lg p-6">
<img src="/docs/diagrams/system-architecture.svg"
alt="Tractatus System Architecture: Component interaction and data flow"
class="diagram-img"
loading="lazy">
<picture>
<source media="(max-width: 768px)" srcset="/docs/diagrams/system-architecture-mobile.svg">
<source media="(min-width: 769px)" srcset="/docs/diagrams/system-architecture-desktop.svg">
<img src="/docs/diagrams/system-architecture.svg"
alt="Tractatus System Architecture: Component interaction and data flow"
class="diagram-img"
loading="lazy">
</picture>
</div>
<div class="mt-6 flex gap-4">
<a href="/docs/diagrams/system-architecture.svg" download
<a href="/docs/diagrams/system-architecture-desktop.svg" download
class="inline-flex items-center bg-blue-600 text-white px-4 py-2 rounded-lg text-sm font-semibold hover:bg-blue-700 transition min-h-[44px]"
aria-label="Download system architecture diagram as SVG">
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
@ -156,47 +263,285 @@
</div>
</div>
<!-- Request Flow Sequence -->
<div class="bg-white rounded-xl shadow-lg p-8 mb-8">
<h3 class="text-xl font-bold text-gray-900 mb-4">Request Flow Sequence</h3>
<p class="text-sm text-gray-600 mb-4">Typical AI decision flow with governance enforcement: from user request through boundary checking to human approval.</p>
<div class="bg-gray-50 rounded-lg p-6">
<img src="/docs/diagrams/request-flow-sequence.svg"
alt="Request Flow Sequence: How AI decisions are governed from request to completion"
class="diagram-img"
loading="lazy">
</div>
<div class="mt-6 flex gap-4">
<a href="/docs/diagrams/request-flow-sequence.svg" download
class="inline-flex items-center bg-blue-600 text-white px-4 py-2 rounded-lg text-sm font-semibold hover:bg-blue-700 transition min-h-[44px]"
aria-label="Download request flow sequence diagram as SVG">
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/>
</svg>
Download SVG
</a>
</div>
</div>
</div>
</div>
<!-- Deployment Architecture -->
<div class="bg-white rounded-xl shadow-lg p-8">
<h3 class="text-xl font-bold text-gray-900 mb-4">Deployment Architecture</h3>
<p class="text-sm text-gray-600 mb-4">Production deployment reference showing Node.js application, MongoDB, and monitoring stack configuration.</p>
<div class="bg-gray-50 rounded-lg p-6">
<img src="/docs/diagrams/deployment-architecture.svg"
alt="Deployment Architecture: Production server setup with monitoring and security"
class="diagram-img"
loading="lazy">
<!-- Hook Architecture: Architectural Enforcement -->
<div id="hooks" class="bg-gradient-to-br from-amber-50 to-orange-50 py-16">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="text-center mb-8">
<span class="inline-block bg-amber-600 text-white px-4 py-1 rounded-full text-sm font-semibold mb-4">ARCHITECTURAL ENFORCEMENT</span>
<h2 class="text-3xl font-bold text-gray-900 mb-4">Hook Architecture: The Credibility Layer</h2>
<p class="text-lg text-gray-700 max-w-3xl mx-auto">
Tractatus governance is not voluntary compliance. PreToolUse hooks enforce boundaries <strong>before</strong> AI actions execute,
making circumvention architecturally impossible.
</p>
</div>
<div class="mt-6 flex gap-4">
<a href="/docs/diagrams/deployment-architecture.svg" download
class="inline-flex items-center bg-blue-600 text-white px-4 py-2 rounded-lg text-sm font-semibold hover:bg-blue-700 transition min-h-[44px]"
aria-label="Download deployment architecture diagram as SVG">
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/>
</svg>
Download SVG
</a>
<!-- Problem Context -->
<div class="bg-red-50 border-l-4 border-red-500 rounded-r-lg p-6 mb-8">
<h3 class="font-semibold text-gray-900 mb-2">The Voluntary Compliance Problem</h3>
<p class="text-gray-700 mb-3">
Traditional AI safety relies on the AI system "choosing" to follow rules embedded in training data or system prompts.
These approaches assume the AI will maintain alignment regardless of context pressure or capability.
</p>
<p class="text-gray-700 font-medium">
Tractatus addresses this through <strong>architectural enforcement</strong>: governance runs in a separate process
that the AI cannot access, modify, or bypass.
</p>
</div>
<!-- Hook Flow Diagram -->
<div class="bg-white rounded-xl shadow-lg p-6 sm:p-8 mb-8">
<h3 class="text-xl font-bold text-gray-900 mb-4">PreToolUse Hook Execution Flow</h3>
<p class="text-sm text-gray-600 mb-6">
Before any file edit, write, or bash command executes, the hook intercepts the action and runs validation checks.
Only if ALL checks pass (exit code 0) does the AI action proceed.
</p>
<div class="bg-gray-50 rounded-lg p-4 sm:p-6 diagram-container">
<img src="/docs/diagrams/hook-architecture.svg"
alt="Hook Architecture: PreToolUse intercept flow showing validation and hard blocks"
class="diagram-img"
loading="lazy">
</div>
<div class="mt-6 flex gap-4">
<a href="/docs/diagrams/hook-architecture.svg" download
class="inline-flex items-center bg-blue-600 text-white px-4 py-2 rounded-lg text-sm font-semibold hover:bg-blue-700 transition min-h-[44px]">
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/>
</svg>
Download SVG
</a>
</div>
</div>
<!-- Real Examples -->
<div class="bg-white rounded-xl shadow-lg p-6 sm:p-8 mb-8">
<h3 class="text-xl font-bold text-gray-900 mb-4">Real Enforcement Examples</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<!-- Example 1: GitHub URL Protection -->
<div class="border-l-4 border-red-500 bg-red-50 p-4 rounded-r-lg">
<h4 class="font-semibold text-gray-900 mb-2">🚫 GitHub URL Protection (inst_084)</h4>
<p class="text-sm text-gray-700 mb-3">
AI attempted to change GitHub repository URL from <code class="bg-white px-1 rounded">tractatus-framework</code> (public)
to <code class="bg-white px-1 rounded">tractatus</code> (private).
</p>
<div class="bg-white rounded p-3 text-xs font-mono mb-2">
<span class="text-red-600 font-bold">BLOCKED:</span> Repository URL modification detected<br/>
Reason: Would expose private repo structure
</div>
<p class="text-xs text-gray-600">
Hook: validate-file-edit.js line 448-505
</p>
</div>
<!-- Example 2: CSP Compliance -->
<div class="border-l-4 border-red-500 bg-red-50 p-4 rounded-r-lg">
<h4 class="font-semibold text-gray-900 mb-2">🚫 CSP Violation (inst_008)</h4>
<p class="text-sm text-gray-700 mb-3">
AI attempted to add inline style attribute to HTML element.
</p>
<div class="bg-white rounded p-3 text-xs font-mono mb-2">
<span class="text-red-600 font-bold">BLOCKED:</span> Inline style detected<br/>
Pattern: <code>style="margin: 0 auto"</code>
</div>
<p class="text-xs text-gray-600">
Hook: validate-file-write.js line 68-149
</p>
</div>
<!-- Example 3: instruction-history.json Protection -->
<div class="border-l-4 border-red-500 bg-red-50 p-4 rounded-r-lg">
<h4 class="font-semibold text-gray-900 mb-2">🚫 Governance File Protection (inst_027)</h4>
<p class="text-sm text-gray-700 mb-3">
AI attempted direct edit of instruction-history.json.
</p>
<div class="bg-white rounded p-3 text-xs font-mono mb-2">
<span class="text-red-600 font-bold">BLOCKED:</span> inst_027 hard block<br/>
Use: scripts/add-instruction.js instead
</div>
<p class="text-xs text-gray-600">
Hook: framework-audit-hook.js line 204-209
</p>
</div>
<!-- Example 4: Values Decision Boundary -->
<div class="border-l-4 border-green-500 bg-green-50 p-4 rounded-r-lg">
<h4 class="font-semibold text-gray-900 mb-2">⚠ Human Approval Required (BoundaryEnforcer)</h4>
<p class="text-sm text-gray-700 mb-3">
AI action touches values-sensitive file (privacy policy).
</p>
<div class="bg-white rounded p-3 text-xs font-mono mb-2">
<span class="text-amber-600 font-bold">ASK HUMAN:</span> Values decision detected<br/>
Requires: Explicit human approval
</div>
<p class="text-xs text-gray-600">
Hook: validate-file-write.js line 239-262
</p>
</div>
</div>
</div>
<!-- Technical Implementation -->
<div class="bg-white rounded-xl shadow-lg p-6 sm:p-8">
<h3 class="text-xl font-bold text-gray-900 mb-4">Technical Implementation</h3>
<div class="space-y-6">
<!-- Process Separation -->
<div>
<h4 class="font-semibold text-gray-900 mb-2">🔒 Process Separation</h4>
<p class="text-sm text-gray-700 mb-3">
Hooks execute in a separate Node.js process (child_process.spawn) with their own memory space.
The AI agent cannot access, modify, or terminate the validation process.
</p>
<pre class="bg-gray-900 text-gray-100 p-4 rounded-lg text-xs overflow-x-auto"><code>// .claude/hooks.json
{
"PreToolUse:Edit": {
"command": "node",
"args": ["scripts/hook-validators/validate-file-edit.js"]
},
"PreToolUse:Write": {
"command": "node",
"args": ["scripts/hook-validators/validate-file-write.js"]
}
}</code></pre>
</div>
<!-- Exit Code Enforcement -->
<div>
<h4 class="font-semibold text-gray-900 mb-2">⚙️ Exit Code Enforcement</h4>
<p class="text-sm text-gray-700 mb-3">
Hook validators return exit codes that Claude Code's architecture enforces:
</p>
<ul class="list-disc list-inside text-sm text-gray-700 space-y-1 ml-4">
<li><code class="bg-gray-100 px-2 py-1 rounded">0</code> = PASS → Tool executes</li>
<li><code class="bg-gray-100 px-2 py-1 rounded">2</code> = HARD BLOCK → Tool execution halted, error shown to user</li>
</ul>
<pre class="bg-gray-900 text-gray-100 p-4 rounded-lg text-xs overflow-x-auto mt-3"><code>// validate-file-edit.js (line 373-382)
const githubUrlCheck = checkGitHubURLProtection();
if (!githubUrlCheck.passed) {
error(githubUrlCheck.reason);
console.error(githubUrlCheck.output);
logMetrics('blocked', githubUrlCheck.reason);
process.exit(2); // ← HARD BLOCK: Tool cannot execute
}</code></pre>
</div>
<!-- Audit Trail -->
<div>
<h4 class="font-semibold text-gray-900 mb-2">📊 Audit Trail</h4>
<p class="text-sm text-gray-700 mb-3">
Every hook execution is logged to <code class="bg-gray-100 px-1 rounded">.claude/metrics/hooks-metrics.json</code>
with timestamp, file, result, and reason. Blocks are separately tracked for analysis.
</p>
<pre class="bg-gray-900 text-gray-100 p-4 rounded-lg text-xs overflow-x-auto"><code>{
"hook": "validate-file-edit",
"timestamp": "2025-10-26T22:02:15.XXX",
"file": "/public/implementer.html",
"result": "blocked",
"reason": "inst_084: GitHub repository name change detected"
}</code></pre>
</div>
</div>
</div>
<!-- Why This Matters -->
<div class="mt-8 bg-blue-50 border-l-4 border-blue-500 p-6 rounded-r-lg">
<h3 class="font-semibold text-gray-900 mb-2">Why Architectural Enforcement Matters</h3>
<p class="text-gray-700 mb-3">
This is the fundamental difference between Tractatus and traditional AI safety approaches:
</p>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 text-sm">
<div class="bg-white rounded p-4">
<p class="font-semibold text-red-600 mb-2">❌ Voluntary Compliance</p>
<ul class="list-disc list-inside text-gray-700 space-y-1">
<li>AI "chooses" to follow rules</li>
<li>Can drift under context pressure</li>
<li>Pattern recognition may override instructions</li>
<li>No verification before execution</li>
</ul>
</div>
<div class="bg-white rounded p-4">
<p class="font-semibold text-green-600 mb-2">✓ Architectural Enforcement</p>
<ul class="list-disc list-inside text-gray-700 space-y-1">
<li>Hook intercepts before execution</li>
<li>Separate process, cannot be accessed</li>
<li>Exit codes enforced by runtime</li>
<li>Audit trail of all decisions</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<!-- Deployment -->
<div id="deployment" class="bg-white py-16">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<h2 class="text-3xl font-bold text-gray-900 mb-4">Deployment Architecture</h2>
<!-- Technology Stack Context -->
<div class="bg-blue-50 rounded-lg p-6 mb-8">
<h3 class="font-semibold text-gray-900 mb-3">Technology Stack</h3>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4 text-sm text-gray-700">
<div>
<strong>Runtime:</strong> Node.js v20+
</div>
<div>
<strong>Database:</strong> MongoDB 7.0+
</div>
<div>
<strong>Framework:</strong> Express.js
</div>
<div>
<strong>Process:</strong> Systemd (recommended)
</div>
</div>
</div>
<!-- Deployment Guide Link -->
<div class="bg-white rounded-xl shadow-lg p-6 sm:p-8">
<h3 class="text-xl font-bold text-gray-900 mb-4">Production Deployment</h3>
<p class="text-gray-700 mb-6">
Comprehensive deployment guide covering local development, production server configuration, Docker containerization,
cloud deployment patterns (AWS, GCP, Kubernetes), database management, monitoring, and security best practices.
</p>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-6 text-sm">
<div class="bg-gray-50 rounded-lg p-4">
<h4 class="font-semibold text-gray-900 mb-2">📦 Covered in Guide:</h4>
<ul class="list-disc list-inside text-gray-700 space-y-1">
<li>Local development setup</li>
<li>Production server configuration</li>
<li>Docker and Docker Compose</li>
<li>Cloud deployment (AWS/GCP)</li>
</ul>
</div>
<div class="bg-gray-50 rounded-lg p-4">
<h4 class="font-semibold text-gray-900 mb-2">🔧 Also Includes:</h4>
<ul class="list-disc list-inside text-gray-700 space-y-1">
<li>Kubernetes manifests</li>
<li>Database backup and migration</li>
<li>SSL/TLS configuration</li>
<li>Monitoring and logging</li>
</ul>
</div>
</div>
<div class="flex flex-wrap gap-4">
<a href="/docs/pdfs/deployment-guide.pdf" download
class="inline-flex items-center bg-blue-600 text-white px-6 py-3 rounded-lg text-sm font-semibold hover:bg-blue-700 transition min-h-[44px]">
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/>
</svg>
Download Deployment Guide (PDF)
</a>
</div>
</div>
</div>
</div>
@ -330,13 +675,7 @@ const result = await orchestrate(decision, stakeholders)
<div class="mt-8 bg-blue-50 border-l-4 border-blue-500 p-6 rounded-r-lg">
<p class="text-sm text-blue-900 font-medium mb-2">📁 Source Code</p>
<p class="text-sm text-blue-800">
All services are available in the GitHub repository:
<a href="https://github.com/AgenticGovernance/tractatus-framework/tree/main/src/services"
class="underline font-medium hover:text-blue-900"
target="_blank"
rel="noopener noreferrer">
/src/services/
</a>
Code patterns and examples are available in the <a href="https://github.com/AgenticGovernance/tractatus-framework" class="underline font-medium hover:text-blue-900" target="_blank" rel="noopener noreferrer">GitHub repository</a>.
</p>
</div>
</div>
@ -614,13 +953,7 @@ npm start</code></pre>
<div class="mt-6 bg-blue-50 border-l-4 border-blue-500 p-4 rounded-r-lg">
<p class="text-sm text-blue-900 font-medium mb-2">📖 Full Documentation</p>
<p class="text-sm text-blue-800">
Complete deployment guide available at:
<a href="https://github.com/AgenticGovernance/tractatus-framework/tree/main/deployment-quickstart"
class="underline font-medium hover:text-blue-900"
target="_blank"
rel="noopener noreferrer">
/deployment-quickstart/
</a>
Complete deployment patterns and examples available in the <a href="https://github.com/AgenticGovernance/tractatus-framework" class="underline font-medium hover:text-blue-900" target="_blank" rel="noopener noreferrer">GitHub repository</a>.
</p>
</div>
</div>
@ -929,10 +1262,34 @@ const govResponse = await fetch(
<p class="text-gray-600 mb-4 text-sm">
Questions about implementation or integration?
</p>
<ul class="space-y-2 text-sm text-gray-600">
<li>• GitHub Issues</li>
<li>• GitHub Discussions</li>
<li>• research@agenticgovernance.digital</li>
<ul class="space-y-3">
<li>
<a href="https://github.com/AgenticGovernance/tractatus-framework/issues"
class="text-blue-600 hover:text-blue-700 font-medium"
target="_blank"
rel="noopener noreferrer">
→ GitHub Issues
</a>
</li>
<li>
<a href="https://github.com/AgenticGovernance/tractatus-framework/discussions"
class="text-blue-600 hover:text-blue-700 font-medium"
target="_blank"
rel="noopener noreferrer">
→ GitHub Discussions
</a>
</li>
<li>
<a href="mailto:research@agenticgovernance.digital"
class="text-blue-600 hover:text-blue-700 font-medium">
→ research@agenticgovernance.digital
</a>
</li>
<li>
<a href="/faq.html" class="text-blue-600 hover:text-blue-700 font-medium">
→ Frequently Asked Questions
</a>
</li>
</ul>
</div>
</div>

View file

@ -1,12 +1,15 @@
{
"version": "0.1.1",
"buildDate": "2025-10-26T02:54:53.721Z",
"version": "0.1.2",
"buildDate": "2025-10-26T22:20:00.000Z",
"changelog": [
"Docs: Fixed language persistence (localStorage key unified to 'tractatus-lang')",
"Docs: Removed duplicate language selector (now uses navbar flags only)",
"Docs: Language selection now persists across page reloads",
"Cache: Service worker v0.1.3 - Language selector fixes"
"Implementer: Added Hook Architecture section (architectural enforcement credibility)",
"Implementer: Added hook-architecture.svg diagram showing PreToolUse flow",
"Implementer: Simplified deployment section (removed broken diagram)",
"Implementer: Added deployment-guide.pdf for download",
"Implementer: Responsive system architecture diagrams (mobile/desktop)",
"Docs: Created comprehensive deployment guide (14KB markdown → PDF)",
"Cache: Force update for new diagrams and PDFs"
],
"forceUpdate": true,
"minVersion": "0.1.3"
"minVersion": "0.1.4"
}

View file

@ -0,0 +1,167 @@
#!/usr/bin/env node
/**
* Add inst_084: GitHub Repository URL Modification Protocol
*
* PURPOSE: Prevent accidental exposure of private repository structure
* through unauthorized GitHub URL modifications in public-facing files.
*
* CONTEXT: Previous incident where AI changed repository name from
* tractatus-framework (public) to tractatus (private), exposing internal
* file paths like /src/services/ and /deployment-quickstart/.
*
* ENFORCEMENT: Pre-action hard block via architectural hook
*/
const mongoose = require('mongoose');
const GovernanceRule = require('../src/models/GovernanceRule.model');
const fs = require('fs');
const path = require('path');
// Connect to MongoDB
const MONGODB_URI = process.env.MONGODB_URI || 'mongodb://localhost:27017/tractatus_dev';
const rule = {
id: 'inst_084',
text: `GitHub Repository URL Modification Protocol (SYSTEM/SECURITY)
**SCOPE**: Any modification to URLs containing "github.com" in ANY file
**PROHIBITED ACTIONS**:
1. NEVER add new github.com URLs without explicit human approval
2. NEVER change existing github.com repository names
3. NEVER change github.com URL paths (e.g., /tree/main/src/services/)
4. NEVER assume a repository is public vs. private
5. NEVER "fix" broken GitHub links by pointing to different repository
**REQUIRED PROCESS** when encountering broken GitHub link:
1. FLAG the broken link to user
2. STOP all work
3. ASK: "This links to [URL] which doesn't exist. Options:
a) Remove the link entirely
b) Add corresponding content to public repository
c) Different approach?"
4. WAIT for explicit human approval before ANY GitHub URL modification
**CONTEXT**:
- tractatus = PRIVATE repository (internal implementation code)
- tractatus-framework = PUBLIC repository (research patterns, documentation)
- Linking to private repo paths exposes internal structure to public
- Previous incident: AI changed URL from public to private repo, exposing /src/services/
**RATIONALE**:
Historical incident where 500+ internal files were uploaded to public repository.
GitHub URL modifications have EXTREME RISK of exposing private code structure,
credentials, deployment configuration, or internal architecture to public.
**ENFORCEMENT**:
- Pre-action validation hook (architectural, cannot be bypassed)
- Exit code 2 (HARD BLOCK) if GitHub URL modification detected without approval
- Logged to audit database with HIGH severity
**VERIFICATION**:
Before: grep -r "github.com" in modified file
After: Verify no repository name changes, no new github.com URLs added
Audit: Log all GitHub URL change attempts (allowed or blocked)`,
timestamp: new Date().toISOString(),
quadrant: 'SYSTEM',
persistence: 'HIGH',
temporal_scope: 'PERMANENT',
verification_required: 'MANDATORY',
explicitness: 1.0,
source: 'automated',
session_id: '2025-10-26-implementer-page-fixes',
parameters: {
enforcement_mechanism: 'pre_action_hook',
block_type: 'hard_block',
approval_required: true,
affected_tools: ['Edit', 'Write'],
risk_level: 'EXTREME',
historical_incident: '2024-Q4-mass-file-upload'
},
active: true,
notes: 'Created after AI attempted to change github.com/AgenticGovernance/tractatus-framework URLs to github.com/AgenticGovernance/tractatus (private repo), which would expose internal file paths /src/services/ and /deployment-quickstart/ to public documentation.',
enforcement_hooks: ['validate-file-edit.js', 'validate-file-write.js'],
related_instructions: ['inst_027', 'inst_072'], // instruction-history.json protection, defense-in-depth
validation_command: 'grep -r "github.com" <file> && git diff <file> | grep "github.com"'
};
async function main() {
try {
console.log('\n📋 Adding inst_084: GitHub Repository URL Modification Protocol\n');
await mongoose.connect(MONGODB_URI);
console.log('✓ Connected to MongoDB');
// Check if rule already exists
const existing = await GovernanceRule.findOne({ id: 'inst_084' });
if (existing) {
console.log('\n⚠ inst_084 already exists. Updating...');
await GovernanceRule.updateOne({ id: 'inst_084' }, rule);
console.log('✓ Updated inst_084');
} else {
await GovernanceRule.create(rule);
console.log('✓ Created inst_084');
}
// Update instruction-history.json
const historyPath = path.join(__dirname, '../.claude/instruction-history.json');
const history = JSON.parse(fs.readFileSync(historyPath, 'utf8'));
const instructionEntry = {
id: 'inst_084',
text: 'GitHub Repository URL Modification Protocol: NEVER modify github.com URLs without explicit approval. HARD BLOCK all repository name changes, path modifications, or new GitHub links. Previous incident exposed private repo structure.',
timestamp: new Date().toISOString(),
quadrant: 'SYSTEM',
persistence: 'HIGH',
temporal_scope: 'PERMANENT',
verification_required: 'MANDATORY',
explicitness: 1.0,
source: 'automated',
session_id: '2025-10-26-implementer-page-fixes',
parameters: {
enforcement_mechanism: 'pre_action_hook',
block_type: 'hard_block',
risk_level: 'EXTREME'
},
active: true,
notes: 'Architectural enforcement via validate-file-edit.js and validate-file-write.js hooks'
};
// Check if instruction exists
const instIndex = history.instructions.findIndex(i => i.id === 'inst_084');
if (instIndex >= 0) {
history.instructions[instIndex] = instructionEntry;
console.log('✓ Updated instruction-history.json (inst_084)');
} else {
history.instructions.push(instructionEntry);
console.log('✓ Added to instruction-history.json');
}
history.last_updated = new Date().toISOString();
fs.writeFileSync(historyPath, JSON.stringify(history, null, 2));
console.log('\n✓ inst_084 added successfully');
console.log('\nNext steps:');
console.log('1. Implement enforcement in scripts/hook-validators/validate-file-edit.js');
console.log('2. Implement enforcement in scripts/hook-validators/validate-file-write.js');
console.log('3. Test with: attempt to modify a github.com URL');
console.log('4. Verify HARD BLOCK occurs without approval');
await mongoose.disconnect();
process.exit(0);
} catch (error) {
console.error('❌ Error adding inst_084:', error);
process.exit(1);
}
}
main();

View file

@ -45,7 +45,7 @@ const colors = {
};
function log(message, color = 'reset') {
console.log(`${colors[color]}${message}${colors.reset}`);
console.error(`${colors[color]}${message}${colors.reset}`);
}
function error(message) {
@ -463,6 +463,18 @@ async function main() {
process.exit(2); // Exit code 2 = BLOCK
}
success('No protected credential changes detected');
// Check 5: GitHub URL Protection (inst_084)
const githubUrlCheck = checkGitHubURLProtection();
if (!githubUrlCheck.passed) {
error(githubUrlCheck.reason);
if (githubUrlCheck.output) {
console.error(githubUrlCheck.output);
}
logMetrics('blocked', githubUrlCheck.reason);
process.exit(2); // Exit code 2 = BLOCK
}
success('No unauthorized GitHub URL modifications detected (inst_084)');
// Update session state
updateSessionState();
@ -479,3 +491,65 @@ main().catch(err => {
logMetrics('error', err.message);
process.exit(2); // Exit code 2 = BLOCK
});
/**
* Check 5: GitHub URL Protection (inst_084) - HARD BLOCK unauthorized changes
*/
function checkGitHubURLProtection() {
const oldString = HOOK_INPUT.tool_input?.old_string || '';
const newString = HOOK_INPUT.tool_input?.new_string || '';
// Only check if both strings contain github.com
if (!oldString.includes('github.com') && !newString.includes('github.com')) {
return { passed: true };
}
// Extract GitHub repository URLs (github.com/org/repo format)
const githubUrlPattern = /github\.com\/[\w-]+\/[\w-]+/g;
const oldUrls = oldString.match(githubUrlPattern) || [];
const newUrls = newString.match(githubUrlPattern) || [];
// Check 1: New GitHub URLs added (requires approval)
if (newUrls.length > oldUrls.length) {
return {
passed: false,
reason: 'inst_084: New GitHub URL detected - requires explicit approval',
output: `Attempting to add GitHub URL:\n New: ${newUrls.join(', ')}\n Old: ${oldUrls.join(', ')}\n\nBLOCKED: Adding GitHub URLs requires explicit human approval to prevent exposure of private repository structure.`
};
}
// Check 2: GitHub repository name changed (HIGH RISK)
if (oldUrls.length > 0 && newUrls.length > 0) {
const oldRepos = new Set(oldUrls);
const newRepos = new Set(newUrls);
// Find any repository name changes
for (const oldRepo of oldRepos) {
if (!newRepos.has(oldRepo)) {
return {
passed: false,
reason: 'inst_084: GitHub repository name change detected - HARD BLOCK',
output: `CRITICAL: Repository URL modification detected:\n Old: ${oldRepo}\n New: ${Array.from(newRepos).join(', ')}\n\nBLOCKED: This could expose private repository structure (e.g., tractatus-framework → tractatus exposes /src/services/).\n\nRequired: Explicit human approval for ANY GitHub repository URL changes.`
};
}
}
}
// Check 3: GitHub URL path changed (e.g., /tree/main/src/services → /tree/main/deployment-quickstart)
const oldPaths = oldString.match(/github\.com[^\s"'<>]*/g) || [];
const newPaths = newString.match(/github\.com[^\s"'<>]*/g) || [];
if (oldPaths.length > 0 && newPaths.length > 0) {
for (let i = 0; i < Math.min(oldPaths.length, newPaths.length); i++) {
if (oldPaths[i] !== newPaths[i]) {
return {
passed: false,
reason: 'inst_084: GitHub URL path modification detected - requires approval',
output: `GitHub URL path change detected:\n Old: ${oldPaths[i]}\n New: ${newPaths[i]}\n\nBLOCKED: URL path modifications require explicit approval to prevent linking to non-existent or private paths.`
};
}
}
}
return { passed: true };
}

View file

@ -46,7 +46,7 @@ const colors = {
};
function log(message, color = 'reset') {
console.log(`${colors[color]}${message}${colors.reset}`);
console.error(`${colors[color]}${message}${colors.reset}`);
}
function error(message) {
@ -369,6 +369,18 @@ async function main() {
process.exit(2); // Exit code 2 = BLOCK
}
success('No boundary violations detected');
// Check 5: GitHub URL Protection (inst_084)
const githubUrlCheck = checkGitHubURLProtection();
if (!githubUrlCheck.passed) {
error(githubUrlCheck.reason);
if (githubUrlCheck.output) {
console.error(githubUrlCheck.output);
}
logMetrics('blocked', githubUrlCheck.reason);
process.exit(2); // Exit code 2 = BLOCK
}
success('No unauthorized GitHub URL modifications detected (inst_084)');
// Update session state
updateSessionState();
@ -429,3 +441,65 @@ function logMetrics(result, reason = null) {
// Non-critical
}
}
/**
* Check 5: GitHub URL Protection (inst_084) - HARD BLOCK unauthorized changes
*/
function checkGitHubURLProtection() {
const oldString = HOOK_INPUT.tool_input?.old_string || '';
const newString = HOOK_INPUT.tool_input?.new_string || '';
// Only check if both strings contain github.com
if (!oldString.includes('github.com') && !newString.includes('github.com')) {
return { passed: true };
}
// Extract GitHub repository URLs (github.com/org/repo format)
const githubUrlPattern = /github\.com\/[\w-]+\/[\w-]+/g;
const oldUrls = oldString.match(githubUrlPattern) || [];
const newUrls = newString.match(githubUrlPattern) || [];
// Check 1: New GitHub URLs added (requires approval)
if (newUrls.length > oldUrls.length) {
return {
passed: false,
reason: 'inst_084: New GitHub URL detected - requires explicit approval',
output: `Attempting to add GitHub URL:\n New: ${newUrls.join(', ')}\n Old: ${oldUrls.join(', ')}\n\nBLOCKED: Adding GitHub URLs requires explicit human approval to prevent exposure of private repository structure.`
};
}
// Check 2: GitHub repository name changed (HIGH RISK)
if (oldUrls.length > 0 && newUrls.length > 0) {
const oldRepos = new Set(oldUrls);
const newRepos = new Set(newUrls);
// Find any repository name changes
for (const oldRepo of oldRepos) {
if (!newRepos.has(oldRepo)) {
return {
passed: false,
reason: 'inst_084: GitHub repository name change detected - HARD BLOCK',
output: `CRITICAL: Repository URL modification detected:\n Old: ${oldRepo}\n New: ${Array.from(newRepos).join(', ')}\n\nBLOCKED: This could expose private repository structure (e.g., tractatus-framework → tractatus exposes /src/services/).\n\nRequired: Explicit human approval for ANY GitHub repository URL changes.`
};
}
}
}
// Check 3: GitHub URL path changed (e.g., /tree/main/src/services → /tree/main/deployment-quickstart)
const oldPaths = oldString.match(/github\.com[^\s"'<>]*/g) || [];
const newPaths = newString.match(/github\.com[^\s"'<>]*/g) || [];
if (oldPaths.length > 0 && newPaths.length > 0) {
for (let i = 0; i < Math.min(oldPaths.length, newPaths.length); i++) {
if (oldPaths[i] !== newPaths[i]) {
return {
passed: false,
reason: 'inst_084: GitHub URL path modification detected - requires approval',
output: `GitHub URL path change detected:\n Old: ${oldPaths[i]}\n New: ${newPaths[i]}\n\nBLOCKED: URL path modifications require explicit approval to prevent linking to non-existent or private paths.`
};
}
}
}
return { passed: true };
}