Skip to content

Commit 72387e5

Browse files
committed
Lots of clean up
1 parent 652f543 commit 72387e5

File tree

11 files changed

+415
-22
lines changed

11 files changed

+415
-22
lines changed

.github/README.github.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,39 @@ This directory contains repository-level configuration and assets that tailor Gi
99

1010
Audience: maintainers and contributors configuring Copilot or repository automation.
1111

12+
Scope: This README documents the `.github/` directory only. For project-wide overview and concepts, see the root [README.md](../README.md) (especially “Copying Copilot Customisations”).
13+
1214
### Copying Copilot Customisations
1315

14-
The custom chatmodes, instructions and prompts can be copied into the same directory structure of another repository. Each file has comments that explain the approach, structure and content of each file.
16+
The custom chat modes, instructions, and prompts are designed to be portable across repositories with the same directory layout. For general guidance and caveats, see the root [README: “Copying Copilot Customisations”](../README.md#7-copying-copilot-customisations).
1517

16-
Each of these files contains **HTML comments** that explain the funtionality, intent and any prompting methods used to reinforce instructions to the AI assistant. **Read the raw source code** to see this information.
18+
Most files contain **HTML comments** inlined with additional context (functionality, intent, and prompting techniques). View the raw source to see these notes.
1719

1820
## GitHub Copilot Customisation
1921

20-
The [copilot-instructions.md](copilot-instructions.md) file contains the main instructions for Github Copilot.
22+
The [copilot-instructions.md](copilot-instructions.md) file contains the main instructions for GitHub Copilot.
23+
24+
It defines mandatory development workflows (branching, commit and PR conventions), coding standards, and review/quality gates using clear, machine-parseable XML-style tags (for example, <CRITICAL_REQUIREMENT/>). Copilot and other AI assistants use these rules to stay consistent with your team’s process.
25+
26+
Key SSOT anchors:
27+
- Quality & Coverage Policy: [copilot-instructions.md#quality-policy](./copilot-instructions.md#quality-policy)
28+
- Branching & Workflow, Naming, Commit Conventions: see relevant sections in the same file
2129

22-
It defines mandatory development workflows (branching, commit and PR conventions), coding standards, and review/quality gates using clear, machine-parseable XML-style tags (for example, <CRITICAL_REQUIREMENT/>). Copilot and other AI assistants use these rules to stay consistent with your team’s process. See also:
30+
See also:
2331
- Project overview in [README.md](../README.md)
2432
- Agent context in [AGENTS.md](../AGENTS.md)
2533

2634
### Custom Chat Modes
2735

2836
- [Custom Chat Modes](./chatmodes/README.md)
2937

30-
Chat Modes provide specialized behaviors in Copilot Chat (e.g., Developer, Code Review, Documentation, Testing, Planner). Each mode documents its persona, process, constraints, and available tools. Pick a mode in Copilot Chat to bias the assistant for the task at hand. Files live under `./chatmodes/` and use the `.chatmode.md` extension.
38+
Chat Modes provide specialized behaviors in Copilot Chat (e.g., Developer, Code Review, Documentation, Testing, Planner). Each mode documents its persona, process, constraints, and available tools. Files live under `./chatmodes/` and use the `.chatmode.md` extension.
3139

3240
### Custom Instructions
3341

3442
- [Custom Instructions](./instructions/README.md)
3543

36-
Instruction files are small, focused rule sets with optional frontmatter (e.g., `applyTo`) that scope guidance to specific files or languages. They help Copilot generate code and docs that match project standards. Notable files include:
44+
Instruction files are small, focused rule sets with optional frontmatter (e.g., `applyTo`) that scope guidance to specific files or languages. They help Copilot generate code and docs that match project standards. Notable files include (SSOTs):
3745
- `backend.instructions.md` (Java/Python/C# backends)
3846
- `frontend.instructions.md` (TypeScript/React conventions)
3947
- `docs.instructions.md` (applies to all `**/*.md`)
@@ -47,7 +55,7 @@ Reusable prompts act like slash commands in Copilot Chat (e.g., `/write-adr`, `/
4755

4856
## GitHub Actions Customisation
4957

50-
The `./workflows/` folder holds GitHub Actions. It’s currently empty and ready for CI/CD jobs (for example: lint Markdown, validate instruction frontmatter, run tests). Add workflow files as needed following standard GitHub Actions practices.
58+
The `./workflows/` folder holds GitHub Actions. It’s currently empty and ready for CI/CD jobs (for example: lint Markdown, validate instruction frontmatter, run tests). Add workflow files as needed following standard GitHub Actions practices. Prefer referencing SSOT anchors (e.g., Quality Policy) in validation jobs.
5159

5260
References:
5361
- GitHub Actions docs: https://docs.github.com/actions

.github/copilot-instructions.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ AI assistants MUST follow trunk-based development with lightweight, short-lived
108108
- Commit frequency: Minimum 1 commit per day of active work
109109
- PR size: Target ≤ 400 lines of code changes per PR
110110
- Review requirement: At least 1 human reviewer approval required
111+
- Review turnaround: Initial review feedback target ≤ 1 business day for typical PRs
111112
</WORKFLOW_ENFORCEMENT>
112113

113114
<!--
@@ -142,6 +143,7 @@ AI assistants MUST use these exact naming patterns for branches and pull request
142143
- `refactor/` - Code refactoring without functional changes
143144
- `test/` - Test additions or modifications
144145
- `chore/` - Maintenance tasks (dependencies, build scripts)
146+
- `plan/` - Planning artifacts and proposals
145147

146148
**Examples:**
147149
-`feature/add-user-authentication`
@@ -343,6 +345,51 @@ AI assistants MUST follow these coding standards and reference project-specific
343345

344346
---
345347

348+
<!--
349+
==============================================================================
350+
QUALITY & COVERAGE POLICY SECTION
351+
==============================================================================
352+
PURPOSE: Define a single source of truth (SSOT) for test coverage and quality
353+
targets across the repository. Eliminates conflicting mandates in chat modes.
354+
REINFORCEMENT TECHNIQUES:
355+
- Stable HTML anchor for cross-file references
356+
- Tiered numeric targets with clear enforcement and exception process
357+
- Directive language (MUST/SHOULD) to enable automation
358+
==============================================================================
359+
-->
360+
361+
<a name="quality-policy"></a>
362+
## Quality & Coverage Policy
363+
364+
Principles:
365+
- Tiered Targets: Apply realistic thresholds by test type and importance.
366+
- Quality > Percentage: Prefer meaningful assertions and coverage of error/security paths over chasing a numeric score.
367+
- Transparency: Exceptions must be explicit and justified in the PR.
368+
369+
Tiered Targets:
370+
- Core domain logic: target ≥ 95% line/branch coverage
371+
- Integrations/adapters: target ≥ 85%
372+
- Generated scaffolds and spikes: opportunistic; may be exempt if tagged and justified in PR
373+
374+
Enforcement:
375+
- Global threshold: CI fails if overall repository coverage < 90%
376+
- Module threshold: CI fails if any core module drops below its target (≥ 95%)
377+
378+
Critical Coverage (must be 100%):
379+
- Hot paths (performance- or user-critical flows)
380+
- Error and exception paths (including negative and edge-case handling)
381+
- Security-relevant logic (authn/authz, input validation, data protection)
382+
383+
Exceptions:
384+
- Use a PR footer section titled "Coverage Exception:" explaining scope, rationale, and risk mitigation
385+
- Obtain at least one reviewer acknowledgment of the exception in review comments
386+
387+
References:
388+
- Chat modes (Developer/Tester) MUST reference this section instead of hardcoding numeric targets.
389+
- Project-specific overrides, if any, MUST be documented here to remain authoritative.
390+
391+
---
392+
346393
<!--
347394
==============================================================================
348395
REPOSITORY OVERVIEW SECTION

.github/instructions/backend.instructions.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,21 @@ Follow idiomatic practices for the chosen programming language and framework. Pr
1515
- **Error Handling**: Implement robust error handling and logging to ensure system stability and ease of debugging.
1616
- **Configuration Management**: Externalize configuration from code. Use environment variables or configuration files. Do not commit secrets to version control.
1717

18+
<a name="backend-architecture"></a>
19+
## Architecture & Structure
20+
21+
Adopt a simple, layered architecture to keep boundaries clear and testable:
22+
- Entry (HTTP/CLI/Queue) → Controller/Handler → Service (business logic) → Repository (data access) → External systems.
23+
- Keep DTOs separate from domain models; map at edges.
24+
- Inject dependencies through constructors. Avoid singletons and global state.
25+
26+
Language-specific notes:
27+
- Spring Boot: Controllers (`@RestController`) → Services (`@Service`) → Repos (`@Repository`). Use packages by feature when helpful.
28+
- Django: Views/ViewSets → Services (plain modules) → ORM Models/Managers. Keep fat models thin services as needed; avoid business logic in views.
29+
- ASP.NET Core: Controllers → Services (DI) → Repositories (EF Core). Prefer interfaces for services/repositories for testability.
30+
31+
Testing guidance: unit-test services with fakes; integration-test controllers and repositories. See `.github/copilot-instructions.md#quality-policy` for coverage expectations.
32+
1833
## Language-Specific Guidelines
1934

2035
### Java
@@ -32,6 +47,18 @@ Follow idiomatic practices for the chosen programming language and framework. Pr
3247
5. **REST APIs**: Use `@RestController` for creating RESTful services and DTOs (Data Transfer Objects) to decouple API contracts from domain models.
3348
6. **Security**: Use Spring Security for authentication and authorization.
3449

50+
##### Example: Global Exception Handler (Spring)
51+
```java
52+
@RestControllerAdvice
53+
public class GlobalExceptionHandler {
54+
@ExceptionHandler(EntityNotFoundException.class)
55+
public ResponseEntity<ApiError> handleNotFound(EntityNotFoundException ex) {
56+
return ResponseEntity.status(HttpStatus.NOT_FOUND)
57+
.body(new ApiError("not_found", ex.getMessage()));
58+
}
59+
}
60+
```
61+
3562
### Python
3663

3764
- **Dependency Management**: Use `pip` with `requirements.txt` or a tool like Poetry or Pipenv.
@@ -45,12 +72,42 @@ Follow idiomatic practices for the chosen programming language and framework. Pr
4572
- **Settings**: Manage settings for different environments carefully (e.g., `settings/base.py`, `settings/dev.py`, `settings/prod.py`).
4673
- **Security**: Use Django's built-in security features (e.g., CSRF protection, XSS protection).
4774

75+
##### Example: Logging Errors via Middleware (Django)
76+
```python
77+
# core/middleware.py
78+
class ErrorLoggingMiddleware:
79+
def __init__(self, get_response):
80+
self.get_response = get_response
81+
82+
def __call__(self, request):
83+
return self.get_response(request)
84+
85+
def process_exception(self, request, exception):
86+
import logging
87+
logger = logging.getLogger(__name__)
88+
logger.exception("Unhandled error", extra={"path": request.path})
89+
return None # let default handlers run
90+
```
91+
92+
Add to `MIDDLEWARE` in settings to enable.
93+
4894
#### Flask
4995

5096
- **Project Structure**: Use Blueprints to organize larger applications.
5197
- **ORM**: Use SQLAlchemy with Flask-SQLAlchemy for database interactions.
5298
- **Configuration**: Use instance folders for configuration.
5399

100+
##### Example: Error Handler (Flask)
101+
```python
102+
from flask import Flask, jsonify
103+
104+
app = Flask(__name__)
105+
106+
@app.errorhandler(ValueError)
107+
def handle_value_error(err):
108+
return jsonify({"error": "invalid_input", "message": str(err)}), 400
109+
```
110+
54111
### C#/.NET
55112

56113
- **Project Structure**: Follow the standard .NET project structure.
@@ -66,6 +123,19 @@ Follow idiomatic practices for the chosen programming language and framework. Pr
66123
4. **API Development**: Use controllers for API endpoints and follow RESTful principles.
67124
5. **Security**: Use ASP.NET Core Identity for authentication and authorization.
68125

126+
##### Example: Centralized Exception Handling (ASP.NET Core)
127+
```csharp
128+
// In Program.cs
129+
app.UseExceptionHandler(appError =>
130+
{
131+
appError.Run(async context =>
132+
{
133+
context.Response.StatusCode = StatusCodes.Status500InternalServerError;
134+
await context.Response.WriteAsJsonAsync(new { error = "internal_error" });
135+
});
136+
});
137+
```
138+
69139
<!-- Removed duplicated placeholder sections to avoid conflicts; guidance above already covers Flask, Django, and ASP.NET Core. -->
70140

71141
## API Development
@@ -74,9 +144,61 @@ Follow idiomatic practices for the chosen programming language and framework. Pr
74144
2. **Request/Response Formats**: Follow the API guidelines for request/response formats (e.g., JSON).
75145
3. **Versioning**: Implement the API versioning strategy defined in the docs to ensure backward compatibility.
76146

147+
Return consistent error shapes (code, message, correlationId) and map exceptions to appropriate status codes. Do not leak stack traces to clients.
148+
77149
## Performance Optimization
78150

79151
1. **Caching**: Implement caching strategies to reduce database load and improve response times.
80152
2. **Database Optimization**: Optimize database queries and use indexing where appropriate.
81153
3. **Asynchronous Processing**: Use asynchronous processing for long-running tasks to improve API responsiveness.
82154

155+
<a name="backend-error-handling"></a>
156+
## Error Handling
157+
158+
- Fail fast on invalid inputs; validate at boundaries (controllers) and in domain invariants.
159+
- Map known exception types to stable error responses; emit machine-parsable `code` fields.
160+
- Use global exception handling (Spring `@ControllerAdvice`, Django middleware, Flask `errorhandler`, ASP.NET Core `UseExceptionHandler`).
161+
- Log errors with context (no secrets/PII), include correlation/trace IDs, and prefer structured logs (JSON).
162+
- Tests must cover error and exception paths (see `.github/copilot-instructions.md#quality-policy`).
163+
164+
<a name="backend-observability"></a>
165+
## Observability
166+
167+
- Logging: structured, leveled logs; include correlation/trace IDs.
168+
- Spring: use SLF4J + MDC; Micrometer for metrics (`@Timed`).
169+
- Python: stdlib `logging` with structured formatter; expose health endpoints.
170+
- .NET: `ILogger<T>` with scopes; OpenTelemetry exporters for traces/metrics.
171+
- Metrics: instrument hot paths, DB calls, external requests; standard RED/USE metrics.
172+
- Tracing: propagate trace headers (W3C TraceContext). Use OpenTelemetry SDKs where available.
173+
174+
Examples:
175+
```java
176+
// Spring: add correlation ID to MDC
177+
try (MDC.MDCCloseable c = MDC.putCloseable("correlationId", cid)) {
178+
log.info("Processing request");
179+
}
180+
```
181+
182+
```csharp
183+
// .NET: log scope with correlation id
184+
using (logger.BeginScope(new Dictionary<string, object>{{"correlationId", cid}}))
185+
{
186+
logger.LogInformation("Processing request");
187+
}
188+
```
189+
190+
<a name="backend-security"></a>
191+
## Security Essentials
192+
193+
- Authentication & Authorization: enforce least privilege; guard all sensitive endpoints.
194+
- Input validation & output encoding: prevent injection and XSS; use parameterized queries only.
195+
- Secrets management: never commit secrets; load from env/managed secret stores; rotate regularly.
196+
- Transport security: enforce HTTPS; set secure headers (HSTS, CSP, X-Frame-Options, X-Content-Type-Options).
197+
- CSRF/CORS: configure appropriately for web apps and APIs.
198+
- Dependency hygiene: pin versions; scan with SCA tools; review transitive risks.
199+
- Data protection: avoid logging PII/secrets; encrypt at rest/in transit where applicable.
200+
201+
References:
202+
- Branch/PR workflow and conventions: `.github/copilot-instructions.md`.
203+
- Coverage and critical-path rules: `.github/copilot-instructions.md#quality-policy`.
204+

.github/instructions/bdd-tests.instructions.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,20 @@ SECTION PURPOSE: Set global conventions for feature files.
1818
3. Prefer concrete, observable behavior over implementation details.
1919
4. Keep steps business-readable; avoid UI selectors or technical jargon.
2020

21+
<a name="bdd-naming"></a>
22+
### Naming & File Structure
23+
- Filenames: `feature-name.feature` (kebab-case), matching the Feature title slug.
24+
- Feature titles: imperative, business behavior oriented (e.g., "Sign in to account").
25+
- Scenario titles: describe outcome (e.g., "Login fails with invalid password").
26+
- Step definitions: use domain language; keep glue thin and reusable.
27+
28+
<a name="bdd-background-state-tags"></a>
29+
### Background, State, and Tags
30+
- Background: only shared, immutable setup. Avoid modifying global state here.
31+
- State isolation: each scenario sets its own preconditions; no order dependence.
32+
- Tags: use `@smoke`, `@regression`, `@wip`, `@negative`, `@slow` to group and control execution.
33+
- Data: prefer Scenario Outline for variations; keep example tables compact and meaningful.
34+
2135
<!--
2236
SECTION PURPOSE: Define the minimal contract for a good Scenario.
2337
PROMPTING: Checklist for scenario completeness and clarity.
@@ -28,6 +42,8 @@ PROMPTING: Checklist for scenario completeness and clarity.
2842
- Steps follow Given-When-Then order; And is used only to add detail.
2943
- Preconditions are explicit; no hidden state from previous scenarios.
3044
- Data examples: use Scenario Outline when testing variations.
45+
- Avoid hidden UI details and timing assumptions; assert observable outcomes.
46+
- Keep nouns/verbs consistent across features.
3147

3248
<!--
3349
SECTION PURPOSE: Enforce machine-checkable constraints to keep specs healthy.
@@ -67,6 +83,50 @@ Feature: User login
6783
| alice | wrong |
6884
| bob | bad |
6985

86+
<a name="bdd-good-vs-bad"></a>
87+
## Good vs Bad Scenarios
88+
89+
Example 1: Clear, behavior-focused vs UI-coupled
90+
91+
Good:
92+
```
93+
Scenario: Add item to cart updates total
94+
Given a priced item exists
95+
And my cart is empty
96+
When I add the item to my cart
97+
Then my cart total should equal the item price
98+
```
99+
100+
Bad:
101+
```
102+
Scenario: Click add button updates total
103+
Given I click the button with id "#add-btn"
104+
And I wait 3 seconds
105+
Then the element ".total" text should be "$9.99"
106+
```
107+
108+
Example 2: Single outcome vs multiple assertions
109+
110+
Good:
111+
```
112+
Scenario: Payment declined shows error
113+
Given my card is blocked
114+
When I attempt to pay
115+
Then I should see a decline message
116+
```
117+
118+
Bad:
119+
```
120+
Scenario: Payment declined does many things
121+
Given my card is blocked
122+
When I attempt to pay
123+
Then I should see a decline message
124+
And my order is cancelled
125+
And my basket is emptied
126+
And an email is sent
127+
```
128+
Rationale: Split into separate scenarios to keep each focused and reliable.
129+
70130
<!--
71131
SECTION PURPOSE: Encourage living docs and CI-ready behavior.
72132
-->
@@ -76,3 +136,5 @@ SECTION PURPOSE: Encourage living docs and CI-ready behavior.
76136
2. Implement the step definitions minimally to pass.
77137
3. Add edge case scenarios and Scenario Outlines; keep steps reusable.
78138
4. Wire into CI to run on PRs and gate merges on failures.
139+
5. Tag scenarios appropriately and configure CI to run fast suites on PRs (e.g., `@smoke`) and full suites nightly.
140+
6. Keep step definitions DRY; refactor when duplication creeps in.

.github/instructions/docs.instructions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ Prompting techniques: Concise quality checklist that is easy to verify automatic
161161
Purpose: Visualize the documentation workflow and decision points.
162162
Prompting techniques: Mermaid diagram with loopbacks and explicit approval gate to reinforce process.
163163
-->
164+
<a name="documentation-process-flow"></a>
164165
## Documentation Process (Flow)
165166

166167
```mermaid

AGENTS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ This file provides general instructions and context for all AI agents working in
1313
- Use this file to understand the project’s goals, structure, and best practices.
1414
- Reference configuration and documentation files for deeper context.
1515
- For Copilot-specific instructions, see `.github/copilot-instructions.md`.
16+
- Authoritative workflow rules (branching, commits, PRs, coverage policy) live in `.github/copilot-instructions.md` — link to it instead of duplicating.
1617
- Other AI Agents should consider `.github/copilot-instructions.md` as informative, but not supersede their own custom instruction files, if present.
1718
- It's critical to stop and alert the user if an AI finds conflicting instructions.
1819
- The assistant must never use emoji's to decorate its responses to the user
@@ -24,4 +25,4 @@ This file provides general instructions and context for all AI agents working in
2425
- Agent todo items MUST be maintained as a Markdown checkbox list only in `plans/TODO.md`, not in any other agent-specific file.
2526
- Source code will be stored in the `src` directory.
2627

27-
This file may repeat some context from other docs to ensure agents have the information they need.
28+
This file intentionally stays minimal; prefer linking to SSOT docs (see `README.md` Appendix: SSOT Source Map) over copying content.

0 commit comments

Comments
 (0)