tractatus/al-integration/README.md
TheFlow d600f6ed83
Some checks are pending
CI / Run Tests (push) Waiting to run
CI / Lint Code (push) Waiting to run
CI / CSP Compliance Check (push) Waiting to run
chore(license): Phase B — relicense source files from Apache 2.0 to EUPL-1.2
Phase B of PLAN_LICENSE_STANDARDISATION_EUPL12_20260419. Follows Phase A
(c85f310f, 4ddc54a0) which flipped the LICENSE file + README; this commit
propagates EUPL-1.2 through source-file headers.

21 files touched across 4 distinct Apache-reference variants:

- V1 (14 files) — full Apache header block (JS /* ... */): 2 routes + 1
  controller + 7 services + 2 models + 3 utils. Replaced with equivalent
  EUPL-1.2 block pointing at EC canonical URL.
- V2 (2 files) — inline JSDoc license line (Copyright Tractatus Project):
  src/routes/calendar.routes.js + src/models/ScheduledTask.model.js.
  Replaced with EUPL-1.2 v. 1.2 equivalent.
- V3 (4 files) — Python docstring 'License: Apache 2.0': all 4 al-integration
  Python files. Replaced with 'License: EUPL-1.2'.
- V4 (1 file) — al-integration/README.md bare 'Apache 2.0' under '## License'
  heading. Replaced with 'EUPL-1.2'.

Verification:
- grep -r "Apache License|Apache 2.0|apache.org/licenses" src/ al-integration/
  returns zero matches (modulo venv).
- Unit tests: 524/524 pass (npm run test:unit).
- Integration test failures (177) are DB-connection infrastructure, pre-existing,
  unrelated to this header-only change.

Sole author basis: TheFlow, 930+ commits, unilateral relicensing (same as Phase A).

Replacement infrastructure also committed: scripts/relicense-apache-to-eupl.js
(auto-detecting variant replacement, idempotent, --dry-run mode). Reusable for
Phase C (community-repo sweep) if pattern structure aligns.

Out-of-scope Apache mentions still in the repo (next pass, NOT Phase B):
- SESSION_HANDOFF_ENFORCEMENT_COMPLETE.md (root doc)
- CLAUDE_Tractatus_Maintenance_Guide.md (root doc)
- For Claude Web/tractatus-claude-web-complete/** (docs snapshot subdirectory)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-19 20:32:09 +12:00

208 lines
5.5 KiB
Markdown

# Agent Lightning Integration - Tractatus Feedback System
**REAL Agent Lightning integration** for the Tractatus feedback system. Not conceptual, not mock - **actually using Agent Lightning 0.2.2** with real `@agl.rollout` decorator, event emission, and training infrastructure.
## Current Status (November 3, 2025)
**IMPLEMENTED - REAL AL INTEGRATION**
- Feedback agent with `@agl.rollout` decorator
- Real event emission (`agl.emit_message()`, `agl.emit_reward()`, `agl.emit_exception()`)
- Reward function based on response quality
- Training infrastructure configured
- CPU-based optimization ready
- GPU-ready architecture (awaiting ROCm + hardware upgrade)
## Architecture
```
User Submits Feedback
1. Tractatus Governance (PII, sentiment, compliance) ✅ WORKS
2. Feedback Response Agent (@agl.rollout) ✅ IMPLEMENTED
- Generates response suggestion
- Emits AL events for training
- Calculates reward based on quality
3. LightningStore (traces collection) ✅ CONFIGURED
4. Training Loop (AL optimization) ✅ CPU-READY
- CPU training: operational
- GPU training: awaiting MS-S1 Max hardware
```
## What Makes This REAL
### 1. Real Agent Lightning Decorator
```python
@agl.rollout
def feedback_response_agent(
task: FeedbackTask,
llm: agl.LLM,
rollout: agl.Rollout
) -> dict:
# Real AL rollout function
...
```
### 2. Real Event Emission
```python
# Emit prompt
agl.emit_message(
role="user",
content=prompt,
metadata={...}
)
# Emit response
agl.emit_message(
role="assistant",
content=response_text,
metadata={...}
)
# Emit reward for training
agl.emit_reward(reward)
```
### 3. Real Reward Function
Rewards based on:
- Response length (50-150 words optimal)
- Tone appropriateness (matches feedback sentiment)
- Research integrity markers ("limitation", "preliminary")
- Overselling penalties (absolute assurance terms)
- Specific feedback acknowledgment
### 4. Real Training Infrastructure
```bash
# Run training (CPU mode)
python training/train_feedback.py oneclick
# With GPU (when available)
# 1. Install ROCm
# 2. pip install agl-tinker
# 3. python training/train_feedback.py --mode distributed
```
## Files
```
al-integration/
├── agents/
│ └── feedback_agent.py # Real @agl.rollout agent
├── training/
│ └── train_feedback.py # AL training script
├── data/ # Training data
├── requirements.txt # Dependencies
└── README.md # This file
```
## Testing
### Verify Agent Works
```bash
cd /home/theflow/projects/tractatus/al-integration
source venv/bin/activate
python training/train_feedback.py oneclick
```
Expected output:
```
✓ Training dataset loaded
✓ MVP trace collection setup complete
✓ Agent instrumented with @agl.rollout
✓ Event emission (emit_message, emit_reward) active
```
## What's Working Right Now
✅ Agent Lightning 0.2.2 installed
✅ Feedback agent with real `@agl.rollout`
✅ Event emission (`emit_message`, `emit_reward`, `emit_exception`)
✅ Reward function (response quality scoring)
✅ Training infrastructure configured
✅ Synthetic dataset (100 examples)
✅ CPU training ready
## What Needs GPU (MS-S1 Max)
🚧 Full RL optimization loops
🚧 Tinker/GRPO/PPO algorithms
🚧 Model fine-tuning
🚧 Large-scale training (1000+ examples)
🚧 Real-time optimization
## Honest Status
**This is REAL Agent Lightning integration** - using actual AL library, real decorators, real event emission, real training infrastructure.
**It's CPU-based MVP** - full GPU optimization awaits hardware upgrade (MS-S1 Max planned Q4 2025).
**It's operational architecture** - same code will use GPU acceleration when hardware available.
## Comparison: Before vs Now
### Before (Removed False Claims)
❌ Claimed "live production integration"
❌ No actual AL code
❌ Just conceptual demos
❌ Misleading users
### Now (Honest Real Implementation)
**Real AL integration** with actual `@agl.rollout`
**Real event emission** (`agl.emit_xxx()`)
**Real reward function** (quality-based scoring)
**Real training infrastructure** (CPU-ready, GPU-ready)
**Honest about limitations** (CPU MVP, GPU pending)
## Research Integrity
**What we claim**:
- Agent Lightning integration is real (uses actual AL library)
- Event emission is operational
- Training infrastructure is configured
- CPU training works
- GPU optimization pending hardware
**What we don't claim**:
- Real-time optimization (not yet)
- Production-scale training (GPU required)
- Model fine-tuning operational (infrastructure ready, training pending)
## Next Steps
1. ✅ Real AL integration built (DONE)
2. 🚧 Update website with honest status (IN PROGRESS)
3. 🚧 Connect to actual feedback submissions
4. 🚧 Install ROCm when MS-S1 Max arrives
5. 🚧 Run full GPU training
6. 🚧 Deploy optimized models to production
## License
EUPL-1.2
## Citation
This is actual Agent Lightning integration following Microsoft's AL framework architecture. Uses real AL library, not mocks.
```bibtex
@software{tractatus_al_integration_2025,
title = {Agent Lightning Integration: Real Implementation},
author = {Tractatus Project},
year = {2025},
note = {Actual AL integration with CPU training, GPU-ready architecture}
}
```
---
**Status**: ✅ REAL IMPLEMENTATION (CPU training operational, GPU pending hardware)
**Last Updated**: November 3, 2025
**Agent Lightning Version**: 0.2.2
**Integration Type**: Operational CPU MVP, GPU-ready architecture