Skip to content

docs(inspection): surface existing brain.rules/explain/export API per sim20+sim22 demand#56

Merged
Gradata merged 1 commit into
mainfrom
wt-surface-inspection-api
Apr 15, 2026
Merged

docs(inspection): surface existing brain.rules/explain/export API per sim20+sim22 demand#56
Gradata merged 1 commit into
mainfrom
wt-surface-inspection-api

Conversation

@Gradata

@Gradata Gradata commented Apr 15, 2026

Copy link
Copy Markdown
Owner

Summary

  • README gets a discoverable "Inspection & Transparency API" section between Features and CLI.
  • docs/sdk/brain.md gets a dedicated section with signatures and return shapes; fills four missing Export entries.
  • Docs note distinguishing pre-graduation (approve_lesson) vs post-graduation (approve_promotion) approval APIs.

Motivation

Rule transparency + inspectability was the #1 user demand across sim20 (30+ mentions) and sim22 (highest-liked comment at 30 likes: "Git diff for AI preferences"). The API already existed in src/gradata/brain_inspection.py and src/gradata/brain.py — users just couldn't find it.

Changes

  • README.md: +36/-4
  • docs/sdk/brain.md: +70/-1
  • No code changes.

Follow-ups noted (out of scope for this PR)

  1. Two parallel approval APIs is a UX hazard; rename candidate.
  2. docs/api/brain.md is orphaned (not in mkdocs.yml nav); deletion candidate.
  3. brain.explain(), rules(), trace(), export_data() docstrings are one-liners; thin.

Test plan

  • uv run pytest tests/ -q → 2221 passed, 23 skipped

Co-Authored-By: Gradata noreply@gradata.ai

… sim20+sim22 demand

Users consistently asked for "git diff for AI preferences" and a way
to inspect/export graduated rules (30+ mentions across sim20 and sim22).
The API already exists in brain_inspection.py and brain.py — this commit
just makes it discoverable.

- README.md: new "Inspection & Transparency API" section with one-line
  description and example for each method (rules, explain, trace,
  export_data, export_rules, export_rules_json, export_skill, export_tree,
  pending_promotions, approve_promotion, reject_promotion).
- docs/sdk/brain.md: dedicated Inspection & Transparency section with
  full signatures and return shapes; added the missing export_rules_json,
  export_skill, export_skills, and export_tree entries; clarified the
  pre- vs post-graduation distinction between review_pending/approve_lesson
  and pending_promotions/approve_promotion.

No code changes. No new methods. Tests: 2221 passed, 23 skipped.

Co-Authored-By: Gradata <noreply@gradata.ai>

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gradata has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@coderabbitai

coderabbitai Bot commented Apr 15, 2026

Copy link
Copy Markdown
📝 Walkthrough
  • Documentation-only PR: surfaces previously undocumented inspection and transparency APIs that already exist in the codebase
  • New public APIs documented in docs/sdk/brain.md:
    • Rule inspection: brain.rules(), brain.explain(rule_id), brain.trace(rule_id)
    • Rule export: brain.export_data(), brain.export_rules_json(), brain.export_skill(), brain.export_skills(), brain.export_tree()
    • Promotion workflow: brain.pending_promotions(), brain.approve_promotion(), brain.reject_promotion()
  • README updated with new "Inspection & Transparency API" section (moved from Features) including usage examples and links to full documentation
  • Distinguishes between pre-graduation (approve_lesson) and post-graduation (approve_promotion) approval workflows
  • No code changes — documentation additions only (+36 lines in README, +70 in brain.md)
  • No breaking changes or security fixes
  • All existing tests pass (2221 passed, 23 skipped)

Walkthrough

Documentation updates to introduce and elaborate on rule inspection, traceability, and promotion workflows in the Brain SDK. README reorganizes existing API references to point to a new dedicated section; docs/sdk/brain.md provides comprehensive method signatures and return shapes for rule listing, explanation, tracing, export, and promotion approval/rejection endpoints.

Changes

Cohort / File(s) Summary
README documentation reorganization
README.md
Removed explicit method list from Features section and added new "Inspection & Transparency API" section with example Python snippets demonstrating rule listing, tracing, explanation, data export, and promotion workflows, plus reference link to full API documentation.
Brain SDK API documentation
docs/sdk/brain.md
Added "Inspection & Transparency" section documenting rule introspection methods (rules(), explain(), trace(), export_data(), pending_promotions(), approve_promotion(), reject_promotion()) and "Export and share" section detailing export variants (export_rules_json(), export_skill(), export_skills(), export_tree()) with signatures, parameters, and return types.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

docs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title directly describes the primary change: documenting and surfacing existing brain inspection/export APIs in response to user demand from sim20/sim22.
Description check ✅ Passed The description is clearly related to the changeset, providing motivation, summary of changes, and context for the documentation updates across README and docs/sdk/brain.md.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch wt-surface-inspection-api

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot added the docs label Apr 15, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/sdk/brain.md`:
- Around line 371-373: Update the docs to match the actual implementation of
brain.export_skill: change the signature to export_skill(self, rule_id: str,
output_file: str = "skill.json", skill_name: str = "") -> str, replace
parameters output_dir/min_state with rule_id and output_file, update the return
type to str, and change the description to "Export a single rule as a skill
definition (JSON)" (reference the export_skill implementation in brain.py).
- Around line 375-377: Update the docs for brain.export_skills to match the
implementation: change the description to state that export_skills (in
brain.export_skills) writes one JSON file per graduated rule (not one SKILL.md
per category), include that files are JSON skill files per rule, and keep that
the method returns the list of written file paths; also update any
signature/parameter notes (output_dir, min_state) to reflect current behavior
and file naming/format (JSON) instead of "SKILL.md".

In `@README.md`:
- Line 234: The README example calls export_skill with output_dir but the actual
method signature is export_skill(self, rule_id: str, output_file: str =
"skill.json", skill_name: str = ""), so update the example to pass a rule_id as
the first argument and optionally output_file/skill_name, or change the example
to use export_skills when demonstrating exporting all rules; reference the
export_skill function and export_skills helper to ensure the example matches the
implementation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: c7585a4c-1f52-480c-bf30-28bf33e44588

📥 Commits

Reviewing files that changed from the base of the PR and between 52a735e and dbf45c0.

📒 Files selected for processing (2)
  • README.md
  • docs/sdk/brain.md
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: test (3.13)
  • GitHub Check: test (3.12)
  • GitHub Check: test (3.11)
  • GitHub Check: Cloudflare Pages

Comment thread docs/sdk/brain.md
Comment on lines +371 to +373
### `brain.export_skill(output_dir=None, min_state="PATTERN", skill_name="")` → Path

Export graduated rules as a full [skill directory](https://github.com/openspace-ai/skills) (SKILL.md + metadata). Returns the path to the created directory.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Critical: export_skill signature and description are incorrect.

The documented signature export_skill(output_dir=None, min_state="PATTERN", skill_name="") does not match the actual implementation. According to the source code in brain.py:1234-1238, the actual signature is:

def export_skill(
    self, rule_id: str, output_file: str = "skill.json", skill_name: str = ""
) -> str:
    """Export a single rule as a skill definition (JSON)."""

Issues:

  • Parameters: Should be rule_id, output_file, skill_name (not output_dir, min_state, skill_name)
  • Return type: Returns str (not Path)
  • Description: Exports "a single rule as a skill definition (JSON)" (not "a full skill directory")
📝 Proposed fix
-### `brain.export_skill(output_dir=None, min_state="PATTERN", skill_name="")` → Path
+### `brain.export_skill(rule_id, output_file="skill.json", skill_name="")` → str

-Export graduated rules as a full [skill directory](https://github.com/openspace-ai/skills) (SKILL.md + metadata). Returns the path to the created directory.
+Export a single rule as a skill definition (JSON file). Returns the path to the created file.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/sdk/brain.md` around lines 371 - 373, Update the docs to match the
actual implementation of brain.export_skill: change the signature to
export_skill(self, rule_id: str, output_file: str = "skill.json", skill_name:
str = "") -> str, replace parameters output_dir/min_state with rule_id and
output_file, update the return type to str, and change the description to
"Export a single rule as a skill definition (JSON)" (reference the export_skill
implementation in brain.py).

Comment thread docs/sdk/brain.md
Comment on lines +375 to +377
### `brain.export_skills(output_dir=None, min_state="PATTERN")` → list[str]

Export graduated rules as one SKILL.md per category. Returns the list of files written.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Minor: export_skills description is inconsistent with implementation.

The documentation states "Export graduated rules as one SKILL.md per category", but the actual implementation in brain.py:1240-1245 exports "individual skill JSON files" — one JSON file per rule (not per category, and not SKILL.md format).

📝 Proposed fix
-Export graduated rules as one SKILL.md per category. Returns the list of files written.
+Export all graduated rules as individual skill JSON files (one per rule). Returns the list of file paths written.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
### `brain.export_skills(output_dir=None, min_state="PATTERN")` → list[str]
Export graduated rules as one SKILL.md per category. Returns the list of files written.
### `brain.export_skills(output_dir=None, min_state="PATTERN")` → list[str]
Export all graduated rules as individual skill JSON files (one per rule). Returns the list of file paths written.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/sdk/brain.md` around lines 375 - 377, Update the docs for
brain.export_skills to match the implementation: change the description to state
that export_skills (in brain.export_skills) writes one JSON file per graduated
rule (not one SKILL.md per category), include that files are JSON skill files
per rule, and keep that the method returns the list of written file paths; also
update any signature/parameter notes (output_dir, min_state) to reflect current
behavior and file naming/format (JSON) instead of "SKILL.md".

Comment thread README.md
brain.export_data(output_format="json") # or "yaml"
brain.export_rules(min_state="PATTERN") # OpenSpace-compatible SKILL.md
brain.export_rules_json(min_state="RULE") # flat sorted JSON array
brain.export_skill(output_dir="./skills") # full skill directory

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Critical: export_skill example uses incorrect signature.

This example call is inconsistent with the actual implementation. According to brain.py:1234-1238, export_skill requires a rule_id as the first parameter, not output_dir:

def export_skill(
    self, rule_id: str, output_file: str = "skill.json", skill_name: str = ""
) -> str:

The current example will fail at runtime.

🐛 Proposed fix
-brain.export_skill(output_dir="./skills") # full skill directory
+brain.export_skill("rule_abc123", output_file="./skills/rule.json")  # single rule as JSON

Or if you want to export all rules as individual files, use export_skills:

-brain.export_skill(output_dir="./skills") # full skill directory
+brain.export_skills(output_dir="./skills")  # all rules as individual JSON files
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@README.md` at line 234, The README example calls export_skill with output_dir
but the actual method signature is export_skill(self, rule_id: str, output_file:
str = "skill.json", skill_name: str = ""), so update the example to pass a
rule_id as the first argument and optionally output_file/skill_name, or change
the example to use export_skills when demonstrating exporting all rules;
reference the export_skill function and export_skills helper to ensure the
example matches the implementation.

@Gradata Gradata merged commit 3506295 into main Apr 15, 2026
6 checks passed
Gradata added a commit that referenced this pull request Apr 15, 2026
…gin/

README:
- Lead with problem framing ("Your AI keeps making the same mistakes")
- 30-second pitch table moved up with vs Mem0 / vs fine-tuning / vs system prompts
- Kept ablation v4 data + Min 2022 random-label control
- Merged new JS/TS (@gradata/cli) and Docker install paths from #80
- Preserved Inspection & Transparency API section from #56
- Tightened features into scannable single-line blocks
- Repo layout + intellectual lineage kept but demoted below primary CTA

.gitignore:
- Add gradata-plugin/ (orphaned clone of separate plugin repo, superseded by
  .claude-plugin/ in this repo via #53; can't be rm'd due to OneDrive lock)

Co-Authored-By: Gradata <noreply@gradata.ai>
Gradata added a commit that referenced this pull request Apr 15, 2026
…gin/ (#84)

README:
- Lead with problem framing ("Your AI keeps making the same mistakes")
- 30-second pitch table moved up with vs Mem0 / vs fine-tuning / vs system prompts
- Kept ablation v4 data + Min 2022 random-label control
- Merged new JS/TS (@gradata/cli) and Docker install paths from #80
- Preserved Inspection & Transparency API section from #56
- Tightened features into scannable single-line blocks
- Repo layout + intellectual lineage kept but demoted below primary CTA

.gitignore:
- Add gradata-plugin/ (orphaned clone of separate plugin repo, superseded by
  .claude-plugin/ in this repo via #53; can't be rm'd due to OneDrive lock)

Co-authored-by: Gradata <noreply@gradata.ai>
@Gradata Gradata deleted the wt-surface-inspection-api branch April 17, 2026 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant