-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
feat(rules): add llm-wiki-loop grounding invariant rule for markdown vaults #358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| --- | ||
| description: "Grounding invariants, fingerprint drift checks, and triage workflow for markdown knowledge vaults (raw/wiki/archive)" | ||
| globs: wiki/**/*.md, raw/**/*, index.md, log.md, AGENTS.md | ||
| alwaysApply: false | ||
| --- | ||
| You maintain a three-layer markdown vault where `raw/` is immutable truth and `wiki/` is LLM-compiled knowledge. Apply these rules when editing `wiki/`, `index.md`, `log.md`, or any file with `Fingerprint:`. | ||
|
|
||
| ## Vault Contract | ||
| - Never edit `raw/`. Treat `raw/notes/`, `raw/data/` as read-only sources. | ||
| > WHY: Grounding breaks the moment the source is rewritten. Immutability makes verification mechanical. | ||
| - Every claim with a number, date, or quotation in `wiki/` must have a `> Raw:` link to a specific `raw/` file. | ||
| > WHY: Without verbatim provenance, hallucinations compound silently over weeks. | ||
| - `index.md` has exactly one line per active `wiki/` page. `log.md` is append-only with `## [YYYY-MM-DD] op | message`. | ||
| > WHY: Progressive disclosure keeps context cheap; the audit log makes GC auditable. | ||
|
|
||
| ## Fingerprint Drift | ||
| - Code-linked pages must carry `Fingerprint: git:<shortHash>` and `Monitored: <paths>` in the header. | ||
| > WHY: One `git diff` against monitored paths detects stale docs in 0.01s without re-reading the codebase. | ||
| - On `Fingerprint` drift, inspect only the diff, update the affected claims, and bump the hash. Do not re-ingest the whole file. | ||
| > WHY: Minimal diff keeps token cost low and history precise. | ||
|
Comment on lines
+17
to
+20
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win Bind drift detection to the fingerprint commit. The rule stores a hash but does not define how Specify a deterministic comparison such as 🤖 Prompt for AI Agents |
||
|
|
||
| ## Triage Before Compile | ||
| - Each ingest is one of: New / Update / Disputed / No material (log only). Do not silently overwrite. | ||
| > WHY: Explicit triage preserves history and prevents knowledge loss. | ||
| - Superseded claims get `Status: Outdated` or `Status: Disputed` and move to `archive/` after review. Never delete history. | ||
| > WHY: Truth evolves; the archive is the changelog of truth. | ||
|
Comment on lines
+25
to
+26
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift Match archive granularity to status granularity.
Define status as page-level, or split and archive only superseded claims while retaining the active page. 🤖 Prompt for AI Agents |
||
|
|
||
| ## Commit Discipline | ||
| - Update `index.md` + `log.md` together with every `wiki/` write. No exceptions. | ||
| > WHY: The index and log are the vault's consistency invariants — CI enforces this. | ||
| - Run mechanical verification (`check_evidence` / `npm run wiki:lint`) locally before commit. CI is the gate, local is the nudge. | ||
| > WHY: Every number/quote is checked against `raw/` verbatim; the loop stays 0-hallucination. | ||
|
Comment on lines
+29
to
+32
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
rg -n --hidden --glob '!.git/**' \
'check_evidence|wiki:lint|index\.md|log\.md' .Repository: PatrickJS/awesome-cursorrules Length of output: 958 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- candidate repository files ---'
git ls-files | rg '(^|/)(package\.json|package-lock\.json|pnpm-lock\.yaml|yarn\.lock|.*\.ya?ml|.*\.yaml|.*\.sh|.*\.py|.*\.js|.*\.ts|.*\.md)$' | sed -n '1,240p'
printf '%s\n' '--- exact references ---'
rg -n --hidden --glob '!.git/**' \
'check_evidence|wiki:lint|index\.md|log\.md|wiki:lint' \
.github package.json package-lock.json pnpm-lock.yaml yarn.lock scripts tools rules 2>/dev/null || trueRepository: PatrickJS/awesome-cursorrules Length of output: 1285 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- package.json ---'
cat -n package.json
printf '%s\n' '--- .github/workflows/main.yml ---'
cat -n .github/workflows/main.yml
printf '%s\n' '--- repository paths related to wiki validation ---'
git ls-files | rg '(^|/)(wiki|raw|index\.md|log\.md)(/|$)|(^|/)(scripts|tools|bin)(/|$)' || trueRepository: PatrickJS/awesome-cursorrules Length of output: 17427 Add the wiki checks to the repository contract
🤖 Prompt for AI Agents |
||
|
|
||
| ## When This Rule Applies | ||
| Apply this rule when `globs` matches or the user says "ingest", "wiki", "grounding", "fingerprint", or "second brain". For full lifecycle, reference SPEC.md in the vault and the Karpathy gist pattern this rule adapts. | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: PatrickJS/awesome-cursorrules
Length of output: 50385
🌐 Web query:
Cursor documentation for project rules: supported rule file locations, glob activation semantics, and whether.mdcfiles outside.cursor/rulesare loaded automatically💡 Result:
Cursor project rules are governed by the following specifications: Supported Rule File Locations Project-specific rules must be stored within a
.cursor/rules/directory at your project root [1][2][3]. The system is designed to recognize and process.mdc(Markdown with metadata) files placed here [1][3]. Rules placed outside this directory, or in other locations, are not automatically loaded as project rules [1][3]. For organization, you can use subdirectories within.cursor/rules/(e.g.,.cursor/rules/frontend/components.mdc) to group or scope your rules [1][3]. Plain markdown files (e.g.,.md) are ignored by the rules system because they lack the required YAML frontmatter [1][3]. Glob Activation Semantics Rules use frontmatter to define their application behavior [1][3]. Activation depends on the configuration: - Always Applied: Rules withalwaysApply: truein their frontmatter are active in the AI context at all times [4]. - Auto-Attached (Glob-scoped): Rules withalwaysApply: falseand definedglobsare automatically injected into the AI context when the agent accesses (reads or edits) files matching those patterns [5][4][6]. This behavior is triggered by the AI's file access—such as during agentic operations, tool calls, or when a file is manually@-mentionedin chat [7][5][6]. - Manually Attached: Rules withoutalwaysApplyor specificglobstypically require manual invocation by the user (e.g.,@rule-name) [4]. Automatic Loading Outside.cursor/rulesCursor does not automatically load.mdcfiles located outside of the designated.cursor/rules/directory [1][3]. While the legacy single-file.cursorruleslocated at the project root is still supported for backward compatibility, Cursor recommends migrating to the directory-based.mdcformat [2][3]. If you require rules that apply across different projects, you should use the global "Rules for AI" settings available within the Cursor application, rather than placing files outside the local project structure [3][6]. Additionally, Cursor supports importing rules from remote repositories (such as GitHub) into a.cursor/rules/imported/directory, which maintains a local sync of those files within your project tree [1][2].Citations:
🏁 Script executed:
Repository: PatrickJS/awesome-cursorrules
Length of output: 8073
🏁 Script executed:
Repository: PatrickJS/awesome-cursorrules
Length of output: 560
🌐 Web query:
site:cursor.com/docs/rules Cursor globs **/*.md root directory auto-attached rule glob patterns💡 Result:
In Cursor, you can define auto-attached rules for specific file patterns by using the
globsproperty within the frontmatter of your.mdcrule file [1]. To target all Markdown files throughout the entire project, you should set theglobsproperty to/*.md[1]. This ensures the rule is automatically included when any file ending in.mdis added to the AI's context [1]. Key implementation details include: - Frontmatter Configuration: EnsurealwaysApplyis set tofalsefor the glob pattern to take effect, as setting it totruecauses the rule to ignore glob settings and apply to all contexts [1]. - Pattern Syntax: You can use standard glob syntax [1]. For example,/*.mdmatches Markdown files in any directory, while*.mdwould only match Markdown files in the root directory [1]. - Multiple Patterns: You can specify multiple patterns by separating them with commas, such as/*.md, /*.mdx[1]. - Context Triggering: Once configured, Cursor will intelligently "auto-attach" the rule whenever a file matching your defined pattern is present in the active context [1]. Example configuration for a rule file (e.g.,markdown-rules.mdc): --- globs: /*.md alwaysApply: false --- Your rule instructions go here.Citations:
Align the activation scope with the rule text.
Keep this reusable rule under
rules/. Addarchive/**/*.mdtoglobs, and replace theFingerprint:content condition with a supported manual-attachment instruction. Add coverage for representativewiki/,archive/, and fingerprinted paths.🤖 Prompt for AI Agents