From rune
Protects complex business logic from accidental deletion or overwrite via manifest tracking, pre-edit gates, and post-edit diff validation. Use for payment systems, trading bots, state machines.
npx claudepluginhub rune-kit/rune --plugin @rune/analyticsThis skill uses the workspace's default tool permissions.
Complex projects (trading bots, payment systems, game engines, state machines) contain interconnected logic that AI agents routinely destroy by accident. The pattern is always the same: new session starts, agent doesn't know existing logic, rewrites or deletes working code, project regresses. `logic-guardian` breaks this cycle by maintaining a machine-readable logic manifest, enforcing a pre-ed...
Blocks Edit/Write/Bash actions until facts on file importers, public functions, data schemas, and user instructions are investigated via Grep/Read/Glob. For multi-module codebases.
Pre-commit quality gate that blocks commits on logic errors, missing error handling, regressions, or incomplete code. Auto-triggers before cook commits, on >100 LOC changes, or via /rune preflight.
Enforces validation rules for Claude Code tools (Edit, Write, Bash, NotebookEdit) to prevent errors like unread files before edits, non-unique old_strings, and missing directories. Useful before file changes or after failures.
Share bugs, ideas, or general feedback.
Complex projects (trading bots, payment systems, game engines, state machines) contain interconnected logic that AI agents routinely destroy by accident. The pattern is always the same: new session starts, agent doesn't know existing logic, rewrites or deletes working code, project regresses. logic-guardian breaks this cycle by maintaining a machine-readable logic manifest, enforcing a pre-edit gate on logic files, and validating that edits don't silently remove existing logic. It is the "institutional memory" for business logic.
/rune logic-guardian — manual invocation (scan project, generate/update manifest)cook or fix targets a file listed in .rune/logic-manifest.jsonsurgeon plans refactoring on logic-heavy modules.rune/logic-manifest.json exists in project rootscout (L2): scan project to discover logic files and extract function signaturesverification (L3): run tests after logic edits to confirm no regressionhallucination-guard (L3): verify that referenced functions/imports actually exist after editjournal (L3): record logic changes as ADRs for cross-session persistencesession-bridge (L3): save manifest state so next session loads it immediatelycook (L1): Phase 1.5 — when complex logic project detected, load manifest before planningfix (L2): pre-edit gate — before modifying any file in the manifestsurgeon (L2): pre-refactor — before restructuring logic modulesteam (L1): validate logic integrity across parallel workstreamsreview (L2): check if reviewed diff removes or modifies manifested logicRead on .rune/logic-manifest.jsononboard — see onboard Step 5.4):
invariants.loaded signal emitted by session-bridge at session start (contains pre-parsed rules[] + stats). No second file read needed.Read .rune/INVARIANTS.md directly and invoke skills/session-bridge/scripts/load-invariants.js to parse.## Danger Zones, ## Critical Invariants, ## State Machine Rules, ## Cross-File Consistency, and ## Auto-detected (new). Archived rules are automatically excluded by the loader.WHAT / WHERE / WHY contract from invariants-template.md.INVARIANTS.md as the primary source of cross-file rules — the JSON manifest covers component-level signatures; INVARIANTS.md covers rules that span files (shared constants, state transitions, mirrored schemas).rune onboard to seed baseline rules." Do not block.Ensure the manifest matches the actual code (detect drift):
Read on the component's file_pathSYNCED — manifest matches code perfectlyDRIFT_DETECTED — list specific discrepancies (missing functions, new unlisted functions, changed signatures)Before ANY edit to a manifested file:
COMPONENT: [name]
STATUS: ACTIVE | TESTING | DEPRECATED
FUNCTIONS: [list with one-line descriptions]
PARAMETERS: [configurable values with current settings]
DEPENDENCIES: [what other components depend on this]
LAST_MODIFIED: [date]
Read of the file first..rune/INVARIANTS.md in Phase 0:
WHERE glob, surface the rule to the agent before the edit proceeds:
INVARIANT (from .rune/INVARIANTS.md):
WHAT: <rule.what>
WHY: <rule.why>
## Archived.strict preset, WARN in gentle preset.Scan the project and build the manifest:
scout to find logic-heavy files:
**/logic/**, **/strategy/**, **/engine/**, **/core/**, **/scenarios/**, **/rules/**, **/pipeline/**, **/trailing/**, **/signals/**Read the file.rune/logic-manifest.jsonsession-bridgeAfter any edit to a manifested file:
verification to execute testsEnsure the next session can pick up where this one left off:
.rune/logic-manifest.json with:
journal as ADRs.rune/logic-manifest.json){
"version": "1.0",
"project": "project-name",
"last_validated": "2026-03-05T10:00:00Z",
"components": [
{
"name": "rsi-entry-detector",
"file_path": "src/scenarios/rsi_entry/detect.py",
"role": "ENTRY_LOGIC",
"status": "ACTIVE",
"functions": [
{
"name": "detect_entry_signal",
"signature": "(df: DataFrame, ticket: Ticket, config: Settings) -> Signal | None",
"description": "3-step RSI entry detection: challenge -> zone check -> entry point",
"critical": true
}
],
"parameters": [
{ "name": "rsi_period", "value": 7, "source": "settings.py" },
{ "name": "challenge_threshold_long", "value": 65, "source": "settings.py" }
],
"dependencies": ["trend-pass-tracker", "indicator-calculator"],
"dependents": ["production-worker", "backtest-engine"],
"last_modified": "2026-03-01",
"last_modifier": "human",
"checksum": "sha256:abc123..."
}
],
"co_change_groups": [
{
"name": "entry-pipeline",
"components": ["trend-pass-tracker", "rsi-entry-detector", "indicator-calculator"],
"reason": "These components share RSI parameters and must be modified together"
}
]
}
## Logic Guardian Report
### Manifest Status: SYNCED | DRIFT_DETECTED
- Components: N active, M testing, K deprecated
- Last validated: [timestamp]
### Pre-Edit Gate
- File: [path]
- Component: [name] (ACTIVE)
- Functions preserved: [list]
- Intended change: [description]
- Impact: [downstream effects]
### Post-Edit Validation
- Functions removed: [none | list]
- Signatures changed: [none | list]
- Parameters changed: [none | list]
- Tests: PASS | FAIL
- Manifest: UPDATED | NEEDS_REVIEW
| Gate | Requires | If Missing |
|---|---|---|
| PRE_EDIT | .rune/logic-manifest.json loaded + component spec displayed | BLOCK edit. Run Phase 0 + Phase 2 first. |
| POST_EDIT | All manifest functions still present OR removal explicitly acknowledged | ALERT + offer git restore |
| CROSS_SESSION | Manifest updated + summary saved to journal/nmem | WARN: next session will lack context |
| Failure Mode | Severity | Mitigation |
|---|---|---|
| Agent edits manifested file without loading manifest first | CRITICAL | Phase 2 gate: cook/fix MUST call logic-guardian before editing manifested files |
| Manifest drifts from actual code (manual edits not tracked) | HIGH | Phase 1 validation on every load — detect and reconcile drift |
| Agent acknowledges existing logic but still overwrites it | HIGH | Post-edit Phase 4 diff check catches removed functions regardless of agent claims |
| Manifest becomes too large (100+ components) | MEDIUM | Group related functions into composite components; track at module level not function level |
| False sense of security — manifest exists but is outdated | MEDIUM | Checksum comparison on every load; warn if file hash doesn't match manifest |
| Agent treats manifest generation as a one-time task | LOW | Phase 5 cross-session handoff ensures manifest stays alive across sessions |
.rune/logic-manifest.json exists and passes Phase 1 validation (SYNCED)| Artifact | Format | Location |
|---|---|---|
| Logic manifest | JSON | .rune/logic-manifest.json |
| Validation report (SYNCED / DRIFT) | Markdown | inline |
| Pre-edit gate summary | Structured text | inline |
| ADR entries for logic changes | Markdown | via journal L3 |
~1,000-2,000 tokens for manifest load + pre-edit gate. ~3,000-5,000 tokens for full project scan (Phase 3). Sonnet for code analysis; haiku for file scanning via scout.
Scope guardrail: logic-guardian protects existing logic — it does not implement new features or refactor code.