ドキュメント

再現性 - 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