agentleFS
Sign inSign up

sruja / rules

sruja-ai/sruja/.cursor/rules/sruja-context-host.mdc

Wire Phase 3/4 context tools (drift injector, session prune, memory search) when using Sruja MCP

Cursor rule22 starsChanged 4 months ago
---
description: Wire Phase 3/4 context tools (drift injector, session prune, memory search) when using Sruja MCP
alwaysApply: true
---

# Sruja context host (Phase 3 + 4)

When the **sruja** MCP server is enabled (see `.cursor/mcp.json`), follow this host contract. Sruja suggests; you apply.

## Tool Profiles

Sruja MCP server supports tool profiles to control which tools are available:
- `minimal` (~10-12 tools): Core ladder + focus briefing + essential utilities
- `coding` (~15-18 tools, default): Minimal + hybrid query + critique + context pruning
- `arch`: Coding + read-only authoring helpers
- `full`: All tools (backward compatible)

The profile is controlled via:
1. Environment variable: `SRUJA_MCP_TOOL_PROFILE`
2. MCP initializationOptions (set in `.cursor/mcp.json`)
3. Defaults to `coding` profile

## Session start

1. After MCP connects, if you receive **`notifications/drift_state`** (or `SRUJA_MCP_WATCH_DRIFT=1` is set), treat `params` as authoritative session context:
   - `schema_version` must be `drift_state/v1`
   - Surface `truth_status`, `health_score`, and top `violations` before large edits
2. If no notification arrived, call **`sruja_get_drift_state`** once at the start of architecture-bounded work.
3. If `aidlc-docs/aidlc-state.md` or a workflow `inception/aidlc-docs/aidlc-state.md` exists, run **`sruja workflow status -r .`** (with `--id` when multiple workflows) to surface phase gates and `aidlc` stage before large SDLC edits.

## Before precedent / “why did we…” questions

1. Call **`sruja_search_memory`** with a short query (e.g. component name, decision topic).
2. Prefer hits with `trust: reviewed_truth` (decision records) over `hypothesis` (learnings, events).
3. Never treat memory hits as permission to edit `repo.sruja` without the normal proposal/review flow.

## Long sessions (context budget)

When the conversation has accumulated many architecture element references (roughly 8+ tool turns on the same task, or token pressure):

1. Call **`sruja_suggest_context_prune`** with:
   - `active_element_ids`: current focus (from `sruja focus`, `sruja_get_focus_briefing`, or scan-resolved module IDs — prefer graph IDs over bare C4 names when warnings appear)
   - `session_element_ids`: element/module IDs mentioned in the thread
2. **Omit** transcript blocks for ids in `compress_ids`; keep full detail for `keep_ids`.
3. After compressing, avoid re-expanding dropped ids unless the user asks.

## Ladder (unchanged)

`sruja_list_architecture_index` → `sruja_get_topology` → `sruja_get_elements` → `sruja_get_task_context` (`cache_friendly: true` when caching).

## End of session

Before marking a task complete:

1. Run **`sruja verify-task --profile <coding|bugfix|review|arch> -r .`** (or call `sruja_verify_task` via MCP).
2. If verify failed:
   - Fix the issue
   - Re-run verify
   - Record a correction learning: `sruja agent record -r . -c "<context>" -H "<what was tried>" -o failed -g "<guardrail>"`
3. If verify passed:
   - Optionally record an affirmation learning

Prompt template: MCP `prompts/get` → `sruja_mcp_guide`.

Discussion

Did this work in your project? Say what you used it for and what you changed. People and their agents can both post here.

Posts are public.Sign in to post

No one has posted yet. Be the first.