Skip to content

Feat/cli personality#5

Merged
DevanshuNEU merged 3 commits into
mainfrom
feat/cli-personality
Apr 15, 2026
Merged

Feat/cli personality#5
DevanshuNEU merged 3 commits into
mainfrom
feat/cli-personality

Conversation

@DevanshuNEU

Copy link
Copy Markdown
Contributor

What does this PR do?

Why?

Type of change

  • Bug fix
  • New feature / command
  • Refactor (no behavior change)
  • Docs / chore
  • New extraction pattern (saar/extractors/)
  • Formatter change (saar/formatters/)

Module affected

  • saar/commands/ — CLI command logic
  • saar/extractors/ — Pattern extraction
  • saar/formatters/ — Output generation
  • saar/linter.py — AGENTS.md quality rules
  • saar/scorer.py — Quality scoring
  • saar/models.py⚠️ Core data contract (discuss before touching)

Verification

source venv/bin/activate

# 1. Lint
ruff check saar/ tests/

# 2. Tests — 548 must pass
pytest tests/ -q

# 3. Dogfood — saar must extract itself cleanly with no stale warnings
saar extract . --no-interview

# 4. If you changed a formatter, regenerate all context files
saar extract . --force --no-interview

Checklist

  • ruff check saar/ tests/ passes (no E/F violations)
  • pytest tests/ -q → 548 passed
  • saar extract . --no-interview runs clean (no stale fact warnings)
  • Did NOT modify saar/models.py without discussion
  • Did NOT add external dependencies (no Supabase, Redis, network calls in core path)
  • Version bumped in pyproject.toml + saar/__init__.py (if shipping a release)

…ning, 87 tests

RL implementation for adaptive extractor profile selection:

Core additions:
- EnsembleAgent: Thompson Sampling meta-agent over UCB + REINFORCE sub-agents
  Maintains Beta(α,β) beliefs per sub-agent; selects via argmax of sampled θᵢ
- Closed reward loop: RewardEngine now accepts depth_multipliers from the active
  profile — section coverage and diversity are profile-weighted so reward varies
  with action choice even for identical DNA (no DNAExtractor changes required)
- Online learning: saar extract --rl now computes reward + updates policy after
  every real extraction; persists updated policy atomically to ~/.saar/rl/

Statistical validation:
- eval_comparison.py: 2000-sample bootstrap 95% CI + Welch's t-test vs random
- Ensemble, UCB, and REINFORCE all p < 0.001 vs random baseline
- Bar chart with CI error bars + learning curve plots generated by training scripts

New files:
- saar/rl/agents/ensemble.py — Thompson Sampling two-level RL hierarchy
- tests/test_rl/test_ensemble.py — 20 tests for EnsembleAgent
- tests/test_rl/test_policy_store.py — 11 tests for PolicyStore (roundtrip, atomic write, versioning)
- tests/test_rl/test_simulator.py — 12 tests for SaarSimulator (oracle, reproducibility, distributions)
- tests/test_rl/test_action_space.py — 11 tests for action space (profiles, multiplier ranges)
- docs/rl_technical_report.md — comprehensive technical report with Mermaid architecture
  diagram, full mathematical formulation (UCB1, REINFORCE, Thompson Sampling), experimental
  design, statistical results, ethical considerations, and reproducibility instructions

Modified:
- saar/rl/reward.py — profile-weighted _section_coverage and _diversity_score
- saar/rl/environment.py — passes depth_multipliers to RewardEngine.compute()
- saar/rl/policy_store.py — adds EnsembleAgent save/load_ensemble/stats
- saar/commands/extract.py — full online learning loop in _apply_rl_profile()
- saar/commands/rl_commands.py — builds + saves ensemble after training both
- experiments/train_ucb.py — learning curve data + matplotlib PNG
- experiments/train_reinforce.py — reward + baseline convergence curves
- README.md — RL module section with architecture diagram, profile table, quickstart

Test count: 593 passing (548 original + 45 new RL tests)
Ruff: zero violations

Made-with: Cursor
Auto-updated AGENTS.md, CLAUDE.md, and .cursorrules to reflect the new
RL module (saar/rl/, 87 tests, EnsembleAgent, online learning). Generated
by running `saar extract . --no-interview` on the repo itself.

Made-with: Cursor
- docs/rl_technical_report.md — full report source (Mermaid diagrams,
  math formulations, results tables, ethical considerations)
- docs/rl_technical_report.html — print-to-PDF ready, styled with
  cover page, syntax-highlighted code blocks, architecture diagram
- docs/generate_pdf.py — regenerates HTML from markdown (no deps)

To produce the final PDF: open rl_technical_report.html in Chrome → Cmd+P → Save as PDF

Made-with: Cursor
@vercel

vercel Bot commented Apr 15, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
saar Ready Ready Preview, Comment Apr 15, 2026 0:10am

@DevanshuNEU DevanshuNEU merged commit 6266966 into main Apr 15, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant