التوثيق

قابلية الإعادة - LeanCTX

قابلية الإعادة

كيفية جعل تشغيلات الوكلاء قابلة للإعادة: مدخلات مستقرة، سياسات صريحة، استمرار الجلسات وبوابات تحقق.

ما يجب أن يبقى مستقراً

تبدأ قابلية الإعادة بمدخلات مستقرة - رسم الأدوات البياني حتمي فقط بقدر حتمية البيئة.

  • نفس جذر المشروع + المسارات المسموحة
  • نفس التكوين وسياسة الذاكرة
  • نفس الكود + التبعيات (lockfiles)

السياسات كعقد

إعدادات الذاكرة والتحقق تحدد ما يُحفظ وأي فحوصات يجب أن تنجح.

# ~/.lean-ctx/config.toml
[memory]
policy = "balanced"

[verification]
enabled = true

نصيحة: اجعل تغييرات السياسات تحت التحكم بالإصدارات وراجعها.

منتجات الجلسة

الجلسات تسجل ما حدث: استدعاءات الأدوات، كتابات الذاكرة، العلاقات والمخرجات.

# Start a server with a fixed project root
lean-ctx serve --host 127.0.0.1 --port 8080 --project-root /path/to/repo
# Example tool calls that leave an audit trail
ctx_session("load", { id: "..." })
ctx_knowledge("remember", { category: "...", key: "...", value: "..." })

بوابات CI

عامل clippy/الاختبارات + فحوصات التحقق كبوابات جودة غير قابلة للتفاوض.

# CI gates / local checks
cd rust
cargo fmt -- --check
cargo clippy --all-features -- -D warnings

# SSOT drift gate (manifest must be up-to-date)
cargo run -q --bin gen_mcp_manifest
git diff --exit-code ../website/generated/mcp-tools.json

# Core tests (deterministic + bounded)
cargo test --all-features -- --test-threads=1

# Lightweight regression checks (stable thresholds)
cargo test -q --test savings_verification

# Proof artifact (machine-readable attestation, no secrets)
cargo run -q --bin lean-ctx -- proof --summary --no-write

Cookbook: أمثلة شاملة

شغّل تكاملات حقيقية ضد خادم قيد التشغيل (بدون بيانات وهمية).

cd cookbook
npm ci
npm run memory-playground
npm run graph-explorer