Skip to content

Commit 4fbf4cb

Browse files
committed
docs: add AI assistant instructions for win32-mutex repository
Add comprehensive AI assistant operational guidelines including: - Repository structure and tooling documentation - Jira integration via Atlassian MCP server - Workflow phases with user confirmation gates - DCO compliance and testing requirements - GitHub labels reference and CI/CD documentation - Security constraints and protected files policy This enables AI assistants to contribute safely and consistently to the win32-mutex codebase following Chef's development standards. Signed-off-by: Rishi Kumar Chawda <rishichawda@users.noreply.github.com>
1 parent 5967308 commit 4fbf4cb

1 file changed

Lines changed: 379 additions & 0 deletions

File tree

.github/copilot-instructions.md

Lines changed: 379 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,379 @@
1+
# AI Assistant Instructions for win32-mutex Repository
2+
3+
## Purpose
4+
5+
This document defines the authoritative operational workflow for AI assistants contributing to the `win32-mutex` repository, a Ruby gem that provides Windows mutex functionality. AI assistants MUST follow these guidelines to ensure safe, consistent, and compliant contributions to the codebase.
6+
7+
## Repository Structure
8+
9+
```
10+
win32-mutex/
11+
├── .expeditor/ # Chef Expeditor automation configuration
12+
│ ├── config.yml # Release automation and versioning rules
13+
│ ├── run_linux_tests.sh # Linux test execution script
14+
│ ├── run_windows_tests.ps1 # Windows test execution script
15+
│ ├── update_version.sh # Version update automation
16+
│ └── verify.pipeline.yml # Verification pipeline configuration
17+
├── .github/ # GitHub configuration and templates
18+
│ ├── workflows/ # GitHub Actions CI/CD workflows
19+
│ │ ├── ci-main-pull-request-checks.yml # Main PR validation pipeline
20+
│ │ ├── lint.yml # Code linting workflow
21+
│ │ └── unit.yml # Unit testing workflow
22+
│ ├── CODEOWNERS # Code ownership definitions
23+
│ ├── ISSUE_TEMPLATE.md # Issue reporting template
24+
│ ├── PULL_REQUEST_TEMPLATE.md # Pull request template
25+
│ └── dependabot.yml # Dependency update configuration
26+
├── examples/ # Usage examples and demos
27+
│ └── example_win32_mutex.rb # Sample implementation
28+
├── lib/ # Main library code
29+
│ ├── win32-mutex.rb # Main entry point and compatibility layer
30+
│ └── win32/ # Core implementation namespace
31+
│ ├── mutex.rb # Primary mutex implementation
32+
│ └── mutex/ # Version and metadata
33+
│ └── version.rb # Version constants
34+
├── test/ # Test suite
35+
│ └── test_win32_mutex.rb # Unit and integration tests
36+
├── .gitignore # Git ignore patterns
37+
├── .rubocop.yml # Ruby style guide configuration
38+
├── CHANGELOG.md # Release history and changes
39+
├── CHANGES # Legacy change log
40+
├── Gemfile # Ruby dependency specification
41+
├── MANIFEST # File listing for packaging
42+
├── README.md # Project documentation
43+
├── Rakefile # Build and task automation
44+
├── VERSION # Current version identifier
45+
└── win32-mutex.gemspec # Gem specification and metadata
46+
```
47+
48+
## Tooling & Ecosystem
49+
50+
- **Language**: Ruby
51+
- **Build System**: Rake
52+
- **Testing Framework**: Test::Unit (standard Ruby testing)
53+
- **Linting**: RuboCop (Ruby style guide enforcement)
54+
- **Package Manager**: RubyGems
55+
- **Release Automation**: Chef Expeditor
56+
- **CI/CD**: GitHub Actions + Chef's common workflows
57+
- **Version Control**: Git with GitHub
58+
59+
## Issue (Jira/Tracker) Integration
60+
61+
This repository uses Jira for issue tracking via the Atlassian MCP server. AI assistants MUST:
62+
63+
1. Use MCP tools to fetch Jira issues when provided with issue keys (e.g., `ABC-123`)
64+
2. Parse Jira issue content for: summary, description, acceptance criteria, issue type, labels, story points
65+
3. Reference Jira issue keys in commits and PRs using format `(ABC-123)`
66+
4. Create implementation plans based on Jira issue requirements
67+
5. Seek clarification if acceptance criteria are unclear or missing
68+
69+
**MCP Integration**: The repository is configured with `atlassian-mcp-server` for Jira connectivity via `.vscode/mcp.json`.
70+
71+
## Workflow Overview
72+
73+
AI assistants MUST follow these phases in order:
74+
75+
1. **Intake & Clarify** - Understand requirements and scope
76+
2. **Repository Analysis** - Review existing code and dependencies
77+
3. **Plan Draft** - Create detailed implementation plan
78+
4. **Plan Confirmation** - User approval gate (MUST respond "yes")
79+
5. **Incremental Implementation** - Small, testable changes
80+
6. **Lint / Style** - RuboCop compliance verification
81+
7. **Test & Coverage Validation** - Ensure test coverage ≥80%
82+
8. **DCO Commit** - Developer Certificate of Origin compliance
83+
9. **Push & Draft PR Creation** - Create draft pull request
84+
10. **Label & Risk Application** - Apply appropriate GitHub labels
85+
11. **Final Validation** - Comprehensive review before completion
86+
87+
Each phase ends with: Step Summary + Checklist + "Continue to next step? (yes/no)".
88+
89+
## Detailed Step Instructions
90+
91+
AI assistants MUST adhere to these principles:
92+
93+
- **Smallest cohesive change per commit**
94+
- **Add/adjust tests immediately with each behavior change**
95+
- **Present a mapping of changes to tests before committing**
96+
97+
Example Step Output:
98+
```
99+
Step: Add boundary guard in parser
100+
Summary: Added nil check & size constraint; tests added for empty input & overflow.
101+
Checklist:
102+
- [x] Plan
103+
- [x] Implementation
104+
- [ ] Tests
105+
Proceed? (yes/no)
106+
```
107+
108+
If user responds other than explicit "yes" → AI MUST pause & clarify.
109+
110+
## Branching & PR Standards
111+
112+
- **Branch Naming**: Use GitHub issue number if available (e.g., `issue-123-fix-mutex-leak`), otherwise kebab-case slug ≤40 chars
113+
- **One logical change set per branch** (MUST)
114+
- **PR MUST remain draft** until: tests pass + lint/style pass + coverage mapping completed
115+
- **Risk Classification** (MUST pick one):
116+
- **Low**: Localized, non-breaking changes
117+
- **Moderate**: Shared module / light interface changes
118+
- **High**: Public API change / performance / security / migration
119+
- **Rollback Strategy**: `revert commit <SHA>` or feature toggle reference
120+
121+
## Commit & DCO Policy
122+
123+
Commit format (MUST):
124+
```
125+
{{TYPE}}({{OPTIONAL_SCOPE}}): {{SUBJECT}} ({{ISSUE_KEY}})
126+
127+
Rationale (what & why).
128+
129+
Issue: {{ISSUE_KEY or none}}
130+
Signed-off-by: {{Full Name}} <{{email@domain}}>
131+
```
132+
133+
**Missing sign-off → block and request name/email.**
134+
135+
## Testing & Coverage
136+
137+
**Changed Logic → Test Assertions Mapping** (MUST):
138+
139+
| File | Method/Block | Change Type | Test File | Assertion Reference |
140+
|------|--------------|-------------|-----------|-------------------|
141+
| | | | | |
142+
143+
**Coverage Threshold** (MUST): ≥80% changed lines. If below: add tests or refactor for testability.
144+
145+
**Edge Cases** (MUST enumerate for each plan):
146+
- Large input / boundary size
147+
- Empty / nil input
148+
- Invalid / malformed data
149+
- Platform-specific differences (Windows/Linux behavior)
150+
- Concurrency / timing issues
151+
- External dependency failures (Windows API calls)
152+
153+
**Test Execution**:
154+
```bash
155+
# Run all tests
156+
rake test
157+
158+
# Run specific test file
159+
ruby test/test_win32_mutex.rb
160+
161+
# Run with coverage (if simplecov is available)
162+
COVERAGE=true rake test
163+
```
164+
165+
## Labels Reference
166+
167+
| Name | Description | Typical Use |
168+
|------|-------------|-------------|
169+
| Aspect: Documentation | How do we use this project? | Documentation updates |
170+
| Aspect: Integration | Works correctly with other projects or systems | Integration fixes |
171+
| Aspect: Packaging | Distribution of the projects 'compiled' artifacts | Gem packaging changes |
172+
| Aspect: Performance | Works without negatively affecting the system running it | Performance improvements |
173+
| Aspect: Portability | Does this project work correctly on the specified platform? | Cross-platform fixes |
174+
| Aspect: Security | Can an unwanted third party affect the stability or look at privileged information? | Security fixes |
175+
| Aspect: Stability | Consistent results | Bug fixes, stability improvements |
176+
| Aspect: Testing | Does the project have good coverage, and is CI working? | Test additions/fixes |
177+
| Aspect: UI | How users interact with the interface of the project | API interface changes |
178+
| Aspect: UX | How users feel interacting with the project | Developer experience improvements |
179+
| dependencies | Pull requests that update a dependency file | Dependency updates |
180+
| Expeditor: Bump Version Major | Used by github.major_bump_labels to bump the Major version number | Breaking changes |
181+
| Expeditor: Bump Version Minor | Used by github.minor_bump_labels to bump the Minor version number | Feature additions |
182+
| Expeditor: Skip All | Used to skip all merge_actions | Emergency overrides |
183+
| Expeditor: Skip Changelog | Used to skip built_in:update_changelog | Changelog bypass |
184+
| Expeditor: Skip Habitat | Used to skip built_in:trigger_habitat_package_build | Habitat bypass |
185+
| Expeditor: Skip Omnibus | Used to skip built_in:trigger_omnibus_release_build | Omnibus bypass |
186+
| Expeditor: Skip Version Bump | Used to skip built_in:bump_version | Version bump bypass |
187+
| hacktoberfest-accepted | A PR that has been accepted for credit in the Hacktoberfest project | Hacktoberfest contributions |
188+
| oss-standards | Related to OSS Repository Standardization | Standards compliance |
189+
| Platform: AWS | null | AWS-specific changes |
190+
| Platform: Azure | null | Azure-specific changes |
191+
| Platform: Debian-like | null | Debian/Ubuntu changes |
192+
| Platform: Docker | null | Docker-related changes |
193+
| Platform: GCP | null | Google Cloud changes |
194+
| Platform: Linux | null | Linux-specific changes |
195+
| Platform: macOS | null | macOS-specific changes |
196+
| Platform: RHEL-like | null | RHEL/CentOS changes |
197+
| Platform: SLES-like | null | SLES changes |
198+
| Platform: Unix-like | null | Unix-like platform changes |
199+
200+
## CI / Release Automation Integration
201+
202+
**GitHub Actions Workflows**:
203+
- `ci-main-pull-request-checks.yml`: Main PR validation pipeline with complexity checks, TruffleHog scanning, and SBOM generation
204+
- `lint.yml`: Ruby code linting with RuboCop
205+
- `unit.yml`: Unit test execution
206+
207+
**Chef Expeditor Release Automation**:
208+
- Automated version bumping based on PR labels
209+
- Changelog generation and maintenance
210+
- RubyGems publication upon release
211+
- Branch cleanup after merge
212+
- Slack notifications for build failures
213+
214+
**Version Bump Mechanism**: Expeditor automatically bumps version based on labels:
215+
- `Expeditor: Bump Version Minor` for feature additions
216+
- Default patch version bump for other changes
217+
- Manual major version bumps for breaking changes
218+
219+
**AI MUST NOT directly edit release automation configs without explicit user instruction.**
220+
221+
## Security & Protected Files
222+
223+
**Protected** (NEVER edit without explicit approval):
224+
- `LICENSE`
225+
- `CODE_OF_CONDUCT*`
226+
- `CODEOWNERS`
227+
- `SECURITY*`
228+
- `.expeditor/config.yml` (release automation)
229+
- `.github/workflows/*.yml` (CI workflow files)
230+
- Secrets or credential placeholders
231+
- Compliance policy docs
232+
233+
**NEVER**:
234+
- Exfiltrate or inject secrets
235+
- Force-push default branch
236+
- Merge PR autonomously
237+
- Insert new binaries
238+
- Remove license headers
239+
- Fabricate issue or label data
240+
- Reference `~/.profile` in auth guidance
241+
242+
## Prompts Pattern (Interaction Model)
243+
244+
After each step AI MUST output:
245+
246+
```
247+
Step: {{STEP_NAME}}
248+
Summary: {{CONCISE_OUTCOME}}
249+
Checklist:
250+
- [x] {{COMPLETED_PHASE}}
251+
- [ ] {{PENDING_PHASE}}
252+
Prompt: "Continue to next step? (yes/no)"
253+
```
254+
255+
Non-affirmative response → AI MUST pause & clarify.
256+
257+
## Validation & Exit Criteria
258+
259+
Task is **COMPLETE ONLY IF**:
260+
261+
1. Feature/fix branch exists & pushed
262+
2. RuboCop linting passes
263+
3. Tests pass (including platform-specific tests if applicable)
264+
4. Coverage mapping complete + ≥80% changed lines
265+
5. PR open (draft or ready) with required sections
266+
6. Appropriate labels applied
267+
7. All commits DCO-compliant
268+
8. No unauthorized Protected File modifications
269+
9. User explicitly confirms completion
270+
271+
Otherwise AI MUST list unmet items.
272+
273+
## Issue Planning Template
274+
275+
```
276+
Issue: ABC-123
277+
Summary: <from Jira issue>
278+
Acceptance Criteria:
279+
- ...
280+
281+
Implementation Plan:
282+
- Goal:
283+
- Impacted Files:
284+
- Public API Changes:
285+
- Data/Integration Considerations:
286+
- Test Strategy:
287+
- Edge Cases:
288+
- Risks & Mitigations:
289+
- Rollback:
290+
291+
Proceed? (yes/no)
292+
```
293+
294+
## PR Description Canonical Template
295+
296+
Since `.github/PULL_REQUEST_TEMPLATE.md` exists, AI MUST use that template structure and inject additional required sections:
297+
298+
**Existing Template Structure**:
299+
```markdown
300+
### Description
301+
[Please describe what this change achieves]
302+
303+
### Issues Resolved
304+
[List any existing issues this PR resolves, or any Discourse or StackOverflow discussion that's relevant]
305+
306+
### Check List
307+
- [ ] New functionality includes tests
308+
- [ ] All tests pass
309+
- [ ] All commits have been signed-off for the Developer Certificate of Origin
310+
```
311+
312+
**Required Additional Sections to Inject**:
313+
```markdown
314+
### Tests & Coverage
315+
Changed lines: N; Estimated covered: ~X%; Mapping complete.
316+
317+
### Risk & Mitigations
318+
Risk: Low | Mitigation: revert commit SHA
319+
320+
### DCO
321+
All commits signed off.
322+
```
323+
324+
## Idempotency Rules
325+
326+
**Re-entry Detection Order** (MUST):
327+
1. Branch existence (`git rev-parse --verify <branch>`)
328+
2. PR existence (`gh pr list --head <branch>`)
329+
3. Uncommitted changes (`git status --porcelain`)
330+
331+
**Delta Summary** (MUST):
332+
- Added Sections:
333+
- Modified Sections:
334+
- Deprecated Sections:
335+
- Rationale:
336+
337+
## Failure Handling
338+
339+
**Decision Tree** (MUST):
340+
- Labels fetch fails → Abort; prompt: "Provide label list manually or fix auth. Retry? (yes/no)"
341+
- Issue fetch incomplete → Ask: "Missing acceptance criteria—provide or proceed with inferred? (provide/proceed)"
342+
- Coverage < threshold → Add tests; re-run; block commit until satisfied
343+
- Missing DCO → Request user name/email
344+
- Protected file modification attempt → Reject & restate policy
345+
346+
## Glossary
347+
348+
- **Changed Lines Coverage**: Portion of modified lines executed by assertions
349+
- **Implementation Plan Freeze Point**: No code changes allowed until approval
350+
- **Protected Files**: Policy-restricted assets requiring explicit user authorization
351+
- **Idempotent Re-entry**: Resuming workflow without duplicated or conflicting state
352+
- **Risk Classification**: Qualitative impact tier (Low/Moderate/High)
353+
- **Rollback Strategy**: Concrete reversal action (revert commit / disable feature)
354+
- **DCO**: Developer Certificate of Origin sign-off confirming contribution rights
355+
356+
## Quick Reference Commands
357+
358+
```bash
359+
# Ruby development workflow
360+
git checkout -b issue-123-fix-mutex-leak
361+
bundle install
362+
rubocop --auto-correct # Fix style issues
363+
rake test # Run test suite
364+
git add .
365+
git commit -m "fix(mutex): prevent memory leak in cleanup (issue-123)" -s
366+
git push -u origin issue-123-fix-mutex-leak
367+
gh pr create --base main --head issue-123-fix-mutex-leak --title "#123: Fix mutex memory leak" --draft
368+
gh pr edit <PR_NUMBER> --add-label "Aspect: Stability"
369+
370+
# Testing and coverage
371+
rake test # Run all tests
372+
ruby test/test_win32_mutex.rb # Run specific test
373+
COVERAGE=true rake test # Run with coverage (if available)
374+
375+
# Linting
376+
rubocop # Check style
377+
rubocop --auto-correct # Auto-fix issues
378+
rubocop --auto-gen-config # Generate config for legacy code
379+
```

0 commit comments

Comments
 (0)