Skip to content

feat: corpus-back rust practice loader + 3 coding-styles/error-handling practices#89

Merged
KailasMahavarkar merged 3 commits intomainfrom
feat/corpus-rust-practices
Apr 21, 2026
Merged

feat: corpus-back rust practice loader + 3 coding-styles/error-handling practices#89
KailasMahavarkar merged 3 commits intomainfrom
feat/corpus-rust-practices

Conversation

@KailasMahavarkar
Copy link
Copy Markdown
Collaborator

Summary

  • Adds corpus support to src/plugins/rust/tools/get-practice.ts with a generic per-practice loader (validates name/chapter/rule/reason) that falls back to the in-file BEST_PRACTICES registry when the slice is missing
  • Creates the backend.rust corpus namespace
  • Adds 3 corpus-backed practice slices: borrow-over-clone, result-not-panic, no-unwrap-in-prod
  • Registers backend.rust in corpus/index.yaml
  • New tests/rust-practice-corpus-backed-tools-behaviour.test.ts asserts corpus source for every migrated practice

Test plan

  • bun test tests/rust-practice-corpus-backed-tools-behaviour.test.ts - 4 pass
  • bun run build - typecheck exit 0

KailasMahavarkar and others added 3 commits April 22, 2026 02:40
Adds corpus support to `src/plugins/rust/tools/get-practice.ts`. Tool now reads per-practice slices from `corpus/backend/rust/<name>.yaml`, validates required fields (chapter, rule, reason), and falls back to the in-file BEST_PRACTICES registry when the corpus entry is missing or invalid.

Creates the rust corpus namespace:
- `corpus/backend/rust/index.yaml` registers the `backend.rust` namespace and practice files
- `corpus/backend/rust/borrow-over-clone.yaml` captures the coding-styles practice (prefer &T over clone; slice vs owned Vec example)
- `corpus/index.yaml` registers the new namespace

New `tests/rust-practice-corpus-backed-tools-behaviour.test.ts` asserts corpus source for borrow-over-clone and fallback for result-not-panic.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds corpus/backend/rust/result-not-panic.yaml with Result<T,E> pattern (? operator) and unwrap() anti-pattern.
Registers result-not-panic in namespace index.
Test asserts corpus source for result-not-panic; fallback check moves to no-unwrap-in-prod.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds corpus/backend/rust/no-unwrap-in-prod.yaml with ? operator pattern, unwrap() anti-pattern, and expect() nuance tip.
Registers no-unwrap-in-prod in namespace index.
Test asserts corpus source for no-unwrap-in-prod; fallback check moves to prefer-iterators.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@KailasMahavarkar KailasMahavarkar merged commit 53e67b9 into main Apr 21, 2026
4 checks passed
@KailasMahavarkar KailasMahavarkar deleted the feat/corpus-rust-practices branch April 21, 2026 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant