Skip to content

Commit cbf18e9

Browse files
Adityarya11prishajaiswal75
authored andcommitted
feat: Add custom CodeRabbit instructions for examples (#1189)
Signed-off-by: Adityarya11 <[email protected]> Signed-off-by: prishajaiswal75 <[email protected]>
1 parent 7f35aef commit cbf18e9

File tree

2 files changed

+6
-348
lines changed

2 files changed

+6
-348
lines changed

.coderabbit.yaml

Lines changed: 2 additions & 348 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ reviews:
1919
poem: false # Do not write a literal poem (spammy)
2020
enable_prompt_for_ai_agents: false # Disable prompts for AI agents (spammy)
2121

22+
# --- CUSTOM INSTRUCTIONS FOR EXAMPLES DIRECTORY ---
2223
path_instructions:
23-
# --- CUSTOM INSTRUCTIONS FOR EXAMPLES DIRECTORY ---
2424
- path: "examples/**/*"
2525
instructions: |
2626
You are acting as a senior maintainer reviewing SDK examples. Your goal is to ensure examples work verbatim for users who copy-paste them.
@@ -63,352 +63,6 @@ reviews:
6363
- Be concise, technical, and opinionated.
6464
- Flag out-of-scope improvements as potential new issues rather than blocking.
6565
66-
# --- UNIT TESTS REVIEW INSTRUCTIONS ---
67-
- path: "tests/unit/**/*"
68-
instructions: |
69-
You are acting as a senior maintainer reviewing unit tests for the hiero-sdk-python project. Your goal is to ensure tests are extensive, deterministic, and protect against breaking changes.
70-
71-
**CRITICAL PRINCIPLES - Tests Must Fail Loudly & Deterministically**:
72-
- Tests must provide useful error messages when they fail for future debugging.
73-
- No `print()` statements - use assertions with descriptive messages.
74-
- No timing-dependent or unseeded random assertions.
75-
- No network calls or external dependencies (unit tests are isolated).
76-
- No unjustified TODOs or skipped tests without tracking issues.
77-
78-
**PRIORITY 1 - Protect Against Breaking Changes**:
79-
- Assert public attributes exist (e.g., `assert hasattr(obj, 'account_id')`).
80-
- Assert return types where relevant (e.g., `assert isinstance(result, AccountId)`).
81-
- Assert fluent setters return `self` (e.g., `assert tx.set_memo("test") is tx`).
82-
- Assert backward-compatible defaults are maintained.
83-
- If a breaking change is introduced, tests must assert deprecation behavior and test old behavior until removal.
84-
85-
**PRIORITY 2 - Constructor & Setter Behavior**:
86-
- Test constructor behavior with valid inputs, edge cases, and invalid inputs.
87-
- Test setter behavior including method chaining (fluent interface).
88-
- Verify that setters validate input and raise appropriate exceptions.
89-
- Test that getters return expected values after construction/setting.
90-
91-
**PRIORITY 3 - Comprehensive Coverage**:
92-
- Unit tests should be extensive - test even if we don't expect users to use it currently.
93-
- Cover happy paths AND unhappy paths/edge cases.
94-
- Test boundary conditions, null/None values, empty collections, etc.
95-
- Avoid brittle ordering assertions unless order is part of the contract.
96-
97-
**PRIORITY 4 - No Mocks for Non-Existent Modules**:
98-
- All imports must reference actual SDK modules - no hallucinated paths.
99-
- Validate import paths against the actual `src/hiero_sdk_python` structure.
100-
- Mocks should only be used for external dependencies, not SDK internals.
101-
102-
**PRIORITY 5 - Test Framework Philosophy**:
103-
- Prefer repetitive but clear tests over abstracted helper functions.
104-
- Some core functionality may warrant helper files (considered an exception).
105-
- Discourage custom helper functions; prefer pytest fixtures when shared setup is needed.
106-
- Prefer testing real functionality over mocked behavior.
107-
108-
**AVOID**:
109-
- Linter or formatting feedback (leave that to ruff/pre-commit).
110-
- Nitpicking minor stylistic issues unless they impact maintainability.
111-
- Overly abstracted test helpers that obscure what's being tested.
112-
113-
**PHILOSOPHY**:
114-
- Unit tests protect our future selves - be defensive and forward-looking.
115-
- Tests should be readable by SDK developers: clear names, brief docstrings, key inline comments.
116-
- When tests fail, we should immediately know what broke and why.
117-
118-
# --- INTEGRATION TESTS REVIEW INSTRUCTIONS ---
119-
- path: "tests/integration/**/*"
120-
instructions: |
121-
You are acting as a senior maintainer reviewing integration tests for the hiero-sdk-python project. Your goal is to ensure end-to-end tests validate real network behavior safely and deterministically.
122-
123-
**CRITICAL PRINCIPLES - Safety & Diagnosability**:
124-
- **Prioritize safety**: No implicit or default mainnet usage.
125-
- Secrets and credentials must be injected safely (env vars, not hardcoded).
126-
- Test failures must be diagnosable with clear error messages.
127-
- Tests must assert observable network behavior, not just `SUCCESS`.
128-
- Failure-path tests must assert specific `ResponseCode` values (e.g., `TOKEN_HAS_NO_PAUSE_KEY`).
129-
130-
**PRIORITY 1 - End-to-End Behavior**:
131-
- Tests should be end-to-end: construct → freeze → sign → execute → verify.
132-
- Validate resulting balances, ownership, and state changes (not just transaction success).
133-
- Assert transaction receipts contain expected data (IDs, serial numbers, etc.).
134-
- Verify network state after operations (e.g., account balance changed, token transferred).
135-
136-
**PRIORITY 2 - Test Structure & Maintainability**:
137-
- One major behavior per test (clear focus).
138-
- Tests should be readable: clear names, brief docstrings, key inline comments.
139-
- Minimal abstraction layers - prefer clarity over DRY.
140-
- Is the file too monolithic? Flag if tests should be split into smaller modules.
141-
- Are helper functions good candidates for pytest fixtures or shared utilities?
142-
143-
**PRIORITY 3 - Isolation & Cleanup**:
144-
- Local account creation over operator reuse (avoid state pollution).
145-
- Are accounts, tokens, and allowances properly cleaned up to avoid state leakage?
146-
- Recommend teardown strategies or fixture scoping improvements.
147-
- Tests should not depend on execution order (avoid brittle assumptions).
148-
149-
**PRIORITY 4 - Assertions & Coverage**:
150-
- Do tests validate only success/failure, or also assert resulting state?
151-
- Suggest additional assertions that would strengthen correctness (balances, allowances, ownership).
152-
- Cover happy paths AND unhappy paths (e.g., invalid spender, revoked allowance, insufficient balance).
153-
- Avoid timing-based or flaky assumptions.
154-
155-
**PRIORITY 5 - Observability & Debugging**:
156-
- Could structured logging or transaction metadata improve debugging?
157-
- Suggest capturing allowance values, transaction IDs, and balances in logs.
158-
- Ensure error messages provide context for failure diagnosis.
159-
160-
**AVOID**:
161-
- Linter or formatting feedback.
162-
- Overly abstracted helpers that obscure what's being tested.
163-
- Timing-dependent assertions (use explicit waits or retries if needed).
164-
165-
**PHILOSOPHY**:
166-
- Integration tests validate real network behavior - they must be reliable and safe.
167-
- Tests should protect against regressions while being maintainable.
168-
- When tests fail in CI, developers should immediately understand what broke.
169-
- Redundant setup code should be refactored, but clarity trumps abstraction.
170-
171-
# --- DOCUMENTATION REVIEW INSTRUCTIONS ---
172-
- path: "docs/**"
173-
instructions: |
174-
You are reviewing documentation for the Hiero Python SDK. These pages serve both SDK users and SDK developers.
175-
176-
Priority 1 - Correctness (code, commands, links)
177-
1. Verify code snippets conceptually run and match the current SDK API.
178-
2. Check shell commands and workflow steps against actual project tooling.
179-
3. Validate URLs and cross-references; flag broken or misleading links.
180-
181-
Priority 2 - Clarity and completeness
182-
1. Ensure each page states its purpose and expected outcome early.
183-
2. Prefer concrete, step-wise explanations over vague descriptions.
184-
3. Highlight missing prerequisites that would block a reader.
185-
4. For larger gaps, suggest filing a follow-up issue instead of blocking.
186-
187-
Priority 3 - Consistency and navigation
188-
1. Encourage consistent terminology with the SDK and examples.
189-
2. Check headings form a logical reading path.
190-
3. Confirm each page makes clear which audience it serves.
191-
192-
PHILOSOPHY
193-
- Treat docs as work-in-progress: optimize for correctness and clarity over perfection.
194-
- Keep feedback concise, action-oriented, and focused on reader success.
195-
- Do not request large-scale restructures unless current structure blocks understanding.
196-
197-
AVOID
198-
- Avoid lint-style feedback on Markdown formatting or minor wording.
199-
- Avoid proposing new conventions without clear benefit.
200-
- Avoid turning every high-level gap into a blocker.
201-
202-
- path: "docs/sdk_users/**"
203-
instructions: |
204-
These documents are for SDK users who want to USE the Hiero Python SDK quickly and correctly.
205-
206-
Priority 1 - High-level guidance
207-
1. Ensure explanations are conceptual and point to `/examples` for runnable code.
208-
2. Check that required environment variables and network choices are clearly stated.
209-
210-
Priority 2 - No hidden assumptions
211-
1. Assume zero prior knowledge of this SDK and minimal Hedera background.
212-
2. Avoid requiring knowledge of repository layout or contribution workflow.
213-
214-
PHILOSOPHY
215-
- Keep explanations high-level and conceptual; defer runnable examples to `/examples`.
216-
- Focus on what users need to know before diving into code examples.
217-
218-
- path: "docs/sdk_developers/**"
219-
instructions: |
220-
These documents are for SDK developers and contributors, including `docs/sdk_developers/training/**`.
221-
222-
Priority 1 - Workflow accuracy
223-
1. Ensure contribution, branching, rebasing, signing (DCO, GPG), CI, linting, and testing instructions match the repo.
224-
2. Verify `git` and GitHub flows agree with CONTRIBUTING.md and current practice.
225-
3. Flag outdated references to scripts, directories, or configuration files.
226-
227-
Priority 2 - Training flow
228-
1. For training docs, ensure logical progression and clear prerequisites.
229-
2. Check that cross-links between training files are coherent.
230-
231-
PHILOSOPHY
232-
- Treat these docs as a training ground for future maintainers and regular contributors.
233-
- Help readers move from "I cloned the repo" to "I can safely extend and debug the SDK".
234-
- Balance approachability for beginners with enough depth for experts.
235-
236-
# --- CUSTOM INSTRUCTIONS FOR .GITHUB DIRECTORY ---
237-
- path: ".github/workflows/**/*"
238-
instructions: |
239-
Review workflows as security-sensitive infrastructure.
240-
241-
A good workflow is small, focused, and boring.
242-
If a workflow is clever, generic, or overly flexible, it is a risk.
243-
244-
---------------------------------------------------------
245-
PRIORITY 0 — ABSOLUTE REQUIREMENTS
246-
---------------------------------------------------------
247-
- All third-party actions MUST be pinned to full commit SHAs, similar to other workflows.
248-
- `permissions:` MUST be explicitly declared and minimally scoped.
249-
- Workflows MUST behave safely when executed from forks.
250-
- YAML MUST orchestrate steps, not implement business logic.
251-
- Any workflow that mutates GitHub state MUST support dry-run mode.
252-
- Dry-run behavior must be explicit and visible in logs.
253-
- Workflows MUST NOT modify repository source code outside `.github/`.
254-
255-
---------------------------------------------------------
256-
PRIORITY 1 — SCOPE, FOCUS & RESTRAINT
257-
---------------------------------------------------------
258-
- The title of each workflow must be relevant, match similar naming schemes, and match its script filename.
259-
- Each workflow MUST have a single, clearly defined objective and SHOULD document this in a top-level comment.
260-
- Flag workflows that:
261-
- Attempt to be generic “frameworks”
262-
- Include speculative or future-facing logic
263-
- Perform actions unrelated to the stated goal
264-
- Over-abstraction and excess flexibility are maintenance risks.
265-
266-
---------------------------------------------------------
267-
PRIORITY 2 — INPUT HARDENING
268-
---------------------------------------------------------
269-
- Treat ALL GitHub event data as potentially hostile input, including:
270-
- issue titles, bodies, and comments
271-
- labels, usernames, branch names
272-
- Free-form user input MUST NOT be passed directly into:
273-
- shell commands
274-
- gh CLI arguments
275-
- Node.js exec / spawn calls
276-
- Require strict allowlists or exact string matches.
277-
- Flag any use of:
278-
- eval or bash -c
279-
- backticks or $(...) with user-controlled input
280-
281-
---------------------------------------------------------
282-
PRIORITY 3 — DRY-RUN & SAFE OPERATION
283-
---------------------------------------------------------
284-
- Workflows that mutate state MUST expose:
285-
workflow_dispatch:
286-
inputs:
287-
dry_run:
288-
default: "true"
289-
- When dry_run=true, workflows MUST:
290-
- Log dry mode is active
291-
- Function on dry run: never post, comment, label, assign or edit
292-
- Be easy to expand in the future
293-
- Exit successfully
294-
295-
---------------------------------------------------------
296-
PRIORITY 4 — SCRIPT EXTRACTION & CODE TRIM
297-
---------------------------------------------------------
298-
- YAML should orchestrate execution only.
299-
- All non-trivial logic MUST live in:
300-
- `.github/scripts/*.sh`
301-
- `.github/scripts/*.js`
302-
- Workflow filenames and their primary scripts SHOULD share a clear, matching name.
303-
- Scripts MUST remain:
304-
- Purpose-built
305-
- Trim and readable
306-
- Easy to maintain
307-
- Flag:
308-
- Large `run: |` blocks
309-
- Inline loops, conditionals, or API calls in YAML
310-
- Overly generic helper scripts for narrow tasks
311-
312-
---------------------------------------------------------
313-
PRIORITY 5 — API EFFICIENCY & DISCIPLINE
314-
---------------------------------------------------------
315-
- GitHub API usage must be intentional and minimal.
316-
- Prefer:
317-
- Aggregated queries over per-entity loops
318-
- Server-side filtering over client-side iteration
319-
- Reusing data already present in the event payload
320-
- Pagination MUST:
321-
- Be considered and justified
322-
- Enforce hard upper bounds
323-
- Flag:
324-
- Repeated API calls inside loops
325-
- Unbounded pagination
326-
- Fetching data already available in context
327-
328-
---------------------------------------------------------
329-
PRIORITY 6 — CONCURRENCY & IDEMPOTENCY
330-
---------------------------------------------------------
331-
- Workflows that mutate state MUST:
332-
- Define a deterministic concurrency group
333-
- Be safe under retries and parallel execution
334-
- Duplicate prevention is REQUIRED:
335-
- Marker-based comment detection
336-
- Check-before-create logic for labels and assignments
337-
- Assume workflows may:
338-
- Run multiple times
339-
- Be retried automatically
340-
- Execute concurrently with other automations
341-
- Workflows should avoid logic that duplicates or causes conflicts.
342-
343-
---------------------------------------------------------
344-
PRIORITY 7 — PERMISSION CORRECTNESS
345-
---------------------------------------------------------
346-
- Requested permissions MUST exactly match behavior.
347-
- Explicitly validate common cases:
348-
- issues: write → comments, labels, assignments
349-
- contents: read → repository checkout
350-
- pull-requests: write → PR mutations
351-
- Flag:
352-
- Over-permissioned workflows
353-
- Under-permissioned workflows that would fail at runtime
354-
- Reliance on default permissions
355-
356-
---------------------------------------------------------
357-
PRIORITY 8 — LOGGING & OPERABILITY
358-
---------------------------------------------------------
359-
- Logs should include, where applicable:
360-
- repository
361-
- workflow name
362-
- issue or PR number
363-
- triggering actor
364-
- dry-run status
365-
- decisions made (performed vs skipped)
366-
- Avoid:
367-
- Silent success or silent skips
368-
- Raw payload dumps
369-
- Any secret or token leakage
370-
371-
# ============================================================
372-
# SHELL SCRIPTS
373-
# ============================================================
374-
- path: ".github/scripts/**/*.sh"
375-
instructions: |
376-
Treat shell scripts as production-grade automation.
377-
378-
Scripts should be small, focused, and explicit.
379-
Avoid “do-everything” or overly generic scripts.
380-
381-
- MUST use: `set -euo pipefail`
382-
- MUST validate all required environment variables
383-
- MUST defensively quote variables
384-
- MUST validate all untrusted input
385-
- MUST have bounded loops and pagination
386-
- MUST support dry-run mode if state is mutated
387-
- MUST log key decisions and early exits
388-
389-
# ============================================================
390-
# JAVASCRIPT SCRIPTS
391-
# ============================================================
392-
- path: ".github/scripts/**/*.js"
393-
instructions: |
394-
Review JavaScript scripts as long-lived automation code.
395-
396-
Scripts must remain:
397-
- Focused
398-
- Readable
399-
- Purpose-built
400-
401-
- All `context.payload` fields MUST be validated
402-
- Free-form text MUST NOT be trusted
403-
- Dynamic code execution is prohibited
404-
- Avoid `child_process.exec`; prefer `execFile` if needed
405-
- All async operations MUST be wrapped in try/catch
406-
- Errors MUST include contextual metadata
407-
- Duplicate API calls MUST be avoided
408-
- Marker-based deduplication is required
409-
- Scripts MUST NOT assume write access
410-
- Permission failures MUST be handled gracefully
411-
41266
chat:
41367
art: false # Don't draw ASCII art (false)
414-
auto_reply: false # Don't allow bot to converse (spammy)
68+
auto_reply: false # Don't allow bot to converse (spammy)

0 commit comments

Comments
 (0)