-
Notifications
You must be signed in to change notification settings - Fork 0
feat: self-healing engine — rule failure detection + auto-patching #21
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
Changes from all commits
7680808
7d9034b
582abcc
409fa83
5c1656c
2edd465
bf9a57c
e9a31c3
d41eb64
8a95a21
29309e2
237c0f8
3422014
19162ee
30ea6fa
201469f
4fd7ad9
7c2c7af
f5353a0
4c2c27f
ef0f176
7181dfe
1f38105
ec5251c
3c9bf34
5aefb0b
5d27f03
7adea31
c84ac47
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,78 @@ | ||
| site_name: Gradata | ||
| site_description: AI behavioral adaptation engine. Corrections graduate into rules. | ||
| repo_url: https://github.com/gradata-systems/gradata | ||
| repo_name: gradata-systems/gradata | ||
|
|
||
| theme: | ||
| name: material | ||
| palette: | ||
| - scheme: slate | ||
| primary: deep purple | ||
| accent: amber | ||
| toggle: | ||
| icon: material/brightness-4 | ||
| name: Light mode | ||
| - scheme: default | ||
| primary: deep purple | ||
| accent: amber | ||
| toggle: | ||
| icon: material/brightness-7 | ||
| name: Dark mode | ||
| features: | ||
| - navigation.instant | ||
| - navigation.tracking | ||
| - navigation.sections | ||
| - navigation.expand | ||
| - content.code.copy | ||
| - content.code.annotate | ||
| - search.highlight | ||
|
|
||
| nav: | ||
| - Home: index.md | ||
| - Getting Started: | ||
| - Installation: getting-started/install.md | ||
| - Quick Start: getting-started/quickstart.md | ||
| - Core Concepts: getting-started/concepts.md | ||
| - Gradata Cloud: | ||
| - Overview: cloud/overview.md | ||
| - Getting Started: cloud/quickstart.md | ||
| - API Reference: cloud/api.md | ||
| - Marketplace: cloud/marketplace.md | ||
| - Guides: | ||
| - Training a Brain: guides/training.md | ||
| - Custom Domains: guides/custom-domains.md | ||
| - MCP Integration: guides/mcp.md | ||
| - API Reference: | ||
| - Brain Class: api/brain.md | ||
| - CLI: api/cli.md | ||
| - Contributing: | ||
| - Architecture: architecture/overview.md | ||
| - Patterns: architecture/patterns.md | ||
| - Enhancements: architecture/enhancements.md | ||
| - Brain Data: architecture/brain.md | ||
| - Agent Adaptation: architecture/agent-graduation.md | ||
| - Patterns API: api/patterns.md | ||
| - Enhancements API: api/enhancements.md | ||
| - Agent Adaptation Guide: guides/agent-graduation.md | ||
|
|
||
| plugins: | ||
| - search | ||
| - mkdocstrings: | ||
| handlers: | ||
| python: | ||
| paths: [src] | ||
| options: | ||
| show_source: false | ||
| show_root_heading: true | ||
| heading_level: 2 | ||
|
Comment on lines
+58
to
+67
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. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Description: Verify that Python source files exist at the configured path
if [[ -d "sdk/src" ]]; then
echo "✅ sdk/src directory exists"
echo ""
echo "Python files found:"
fd -e py . sdk/src -x echo " - {}"
# Check if there are any Python files
if [[ $(fd -e py . sdk/src | wc -l) -eq 0 ]]; then
echo ""
echo "⚠️ No Python files found in sdk/src"
exit 1
fi
else
echo "❌ sdk/src directory does not exist"
exit 1
fiRepository: Gradata/gradata Length of output: 93 🏁 Script executed: # Find Python files and directory structure in the sdk directory
find sdk -type f -name "*.py" | head -20Repository: Gradata/gradata Length of output: 41 🏁 Script executed: # Check the overall structure of the sdk directory
ls -la sdk/Repository: Gradata/gradata Length of output: 232 🏁 Script executed: # Search for common Python package locations
fd -t d "^(src|python|lib|packages)$" sdk/Repository: Gradata/gradata Length of output: 41 🏁 Script executed: # Search for Python files across the entire repository
find . -type f -name "*.py" -not -path "*/\.*" | head -20Repository: Gradata/gradata Length of output: 636 🏁 Script executed: # Check if there's a src directory at repository root
ls -la | grep -E "^d.*src$|^d.*python"Repository: Gradata/gradata Length of output: 112 🏁 Script executed: # Check the overall repository structure at root
ls -laRepository: Gradata/gradata Length of output: 1270 🏁 Script executed: # Check the root mkdocs.yml to understand the documentation structure
cat mkdocs.yml | head -30Repository: Gradata/gradata Length of output: 758 🏁 Script executed: # Check if there's a build script or CI configuration that runs mkdocs
find . -name "*.yml" -o -name "*.yaml" | xargs grep -l "mkdocs" 2>/dev/nullRepository: Gradata/gradata Length of output: 117 🏁 Script executed: # Check the GitHub workflow to see how mkdocs is executed
cat .github/workflows/docs.ymlRepository: Gradata/gradata Length of output: 1089 🏁 Script executed: # Search for any references to sdk/mkdocs.yml in the codebase
rg "sdk.*mkdocs|mkdocs.*sdk" --type yaml --type md --type txtRepository: Gradata/gradata Length of output: 150 🏁 Script executed: # Check if there's any build documentation or README about sdk
grep -r "sdk" README.md CONTRIBUTING.md 2>/dev/null | head -20Repository: Gradata/gradata Length of output: 41 🏁 Script executed: # Try a simpler search for sdk references
find . -type f \( -name "*.md" -o -name "*.txt" -o -name "*.yml" \) ! -path "*/.git/*" -exec grep -l "sdk" {} \;Repository: Gradata/gradata Length of output: 119 🏁 Script executed: # Check if there are any files inside the sdk directory beyond mkdocs.yml
find sdk -type fRepository: Gradata/gradata Length of output: 73 🏁 Script executed: # Check git status of sdk directory to understand its state
git ls-files sdk/Repository: Gradata/gradata Length of output: 73 🏁 Script executed: # Check the SDK CI workflow to see if it uses mkdocs
cat .github/workflows/sdk-ci.ymlRepository: Gradata/gradata Length of output: 1858 🏁 Script executed: # Check if there's a pyproject.toml in the sdk directory
cat sdk/pyproject.toml 2>/dev/null || echo "No pyproject.toml in sdk/"Repository: Gradata/gradata Length of output: 84 🏁 Script executed: # List all files in the sdk directory recursively
find sdk -type fRepository: Gradata/gradata Length of output: 73 Fix the SDK source path configuration — the mkdocstrings path is incorrect, and the broader SDK CI will fail. The Update 🤖 Prompt for AI Agents |
||
|
|
||
| markdown_extensions: | ||
| - admonition | ||
| - pymdownx.details | ||
| - pymdownx.superfences | ||
| - pymdownx.highlight: | ||
| anchor_linenums: true | ||
| - pymdownx.tabbed: | ||
| alternate_style: true | ||
| - toc: | ||
| permalink: true | ||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -78,6 +78,7 @@ def _get_db_path(ctx=None) -> Path: | |||||||||
| return p | ||||||||||
|
|
||||||||||
| # 3. Relative traversal (SDK installed alongside brain) | ||||||||||
| # Expects: src/gradata/enhancements/rule_canary.py -> 5 parents -> repo/brain/ | ||||||||||
| try: | ||||||||||
| scripts_dir = Path(__file__).resolve().parent.parent.parent.parent.parent / "brain" | ||||||||||
| p = scripts_dir / "system.db" | ||||||||||
|
|
@@ -148,8 +149,9 @@ def check_canary_health(rule_category: str, session: int, db_path: Path | None = | |||||||||
| try: | ||||||||||
| corr_row = conn.execute( | ||||||||||
| "SELECT COUNT(*) as cnt FROM events WHERE type = 'CORRECTION' " | ||||||||||
| "AND data_json LIKE ? AND CAST(session AS INTEGER) >= ?", | ||||||||||
| (f'%"{rule_category}"%', start_session), | ||||||||||
| "AND json_extract(data_json, '$.rule_category') = ? " | ||||||||||
| "AND CAST(session AS INTEGER) >= ?", | ||||||||||
| (rule_category, start_session), | ||||||||||
|
Comment on lines
+152
to
+154
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.
The fix correctly moves away from data = {
...
"category": category or "UNKNOWN",
...
}Because
Suggested change
Prompt To Fix With AIThis is a comment left during a code review.
Path: src/gradata/enhancements/rule_canary.py
Line: 152-154
Comment:
**Wrong JSON field name silently disables rollback detection**
The fix correctly moves away from `LIKE`, but uses the field name `$.rule_category`, which does not exist in `CORRECTION` event payloads. `_core.py` (line 166) stores the correction category under the key `"category"`:
```python
data = {
...
"category": category or "UNKNOWN",
...
}
```
Because `json_extract(data_json, '$.rule_category')` will always return `NULL` for every CORRECTION event, `correction_count` will permanently be 0, and no canary rule will ever be recommended for `ROLLBACK` — even when a new rule is actively causing regressions. The canary's entire protective function is silently defeated.
```suggestion
"AND json_extract(data_json, '$.category') = ? "
```
How can I resolve this? If you propose a fix, please make it concise. |
||||||||||
| ).fetchone() | ||||||||||
|
greptile-apps[bot] marked this conversation as resolved.
|
||||||||||
| if corr_row: | ||||||||||
| correction_count = corr_row["cnt"] | ||||||||||
|
|
||||||||||
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.
🧩 Analysis chain
🏁 Script executed:
Repository: Gradata/gradata
Length of output: 714
🏁 Script executed:
Repository: Gradata/gradata
Length of output: 383
Create missing documentation files referenced in the navigation.
All 21 markdown files referenced in the navigation (lines 30-56) do not exist. The
docs/directory is missing entirely, and the documentation build will fail without these files. Create the required directory structure and documentation files:docs/index.mddocs/getting-started/{install,quickstart,concepts}.mddocs/cloud/{overview,quickstart,api,marketplace}.mddocs/guides/{training,custom-domains,mcp,agent-graduation}.mddocs/api/{brain,cli,patterns}.mddocs/architecture/{overview,patterns,enhancements,brain,agent-graduation}.md🤖 Prompt for AI Agents