Skip to content

Commit e69e174

Browse files
authored
Merge pull request #5 from Diddyy/quality/precommit-guardrails
Quality/precommit guardrails
2 parents 0c0d30b + 8db39fa commit e69e174

20 files changed

Lines changed: 750 additions & 12 deletions

.config/dotnet-tools.json

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
{
22
"version": 1,
33
"isRoot": true,
4-
"tools": {
5-
"csharpier": {
6-
"version": "1.1.1",
7-
"commands": [
8-
"csharpier"
9-
],
10-
"rollForward": false
11-
}
12-
}
13-
}
4+
"tools": {}
5+
}

.gitattributes

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,24 @@
33
###############################################################################
44
* text=auto
55

6+
# Force LF for source and tooling-related text files
7+
*.cs text eol=lf
8+
*.csproj text eol=lf
9+
*.props text eol=lf
10+
*.targets text eol=lf
11+
*.tt text eol=lf
12+
*.md text eol=lf
13+
*.json text eol=lf
14+
*.yml text eol=lf
15+
*.yaml text eol=lf
16+
*.sh text eol=lf
17+
*.ps1 text eol=lf
18+
.githooks/* text eol=lf
19+
20+
# Keep Windows endings for solution and batch files
21+
*.sln text eol=crlf
22+
*.bat text eol=crlf
23+
624
###############################################################################
725
# Set default behavior for command prompt diff.
826
#

.githooks/pre-commit

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env sh
2+
set -eu
3+
4+
echo "Running fast local checks..."
5+
dotnet tool restore
6+
7+
staged_files="$(mktemp)"
8+
trap 'rm -f "$staged_files"' EXIT
9+
10+
git diff --cached --name-only --diff-filter=ACMR -- '*.cs' \
11+
| grep '^TurboSamplePlugin/.*\.cs$' \
12+
> "$staged_files" || true
13+
14+
if [ -s "$staged_files" ]; then
15+
echo "Checking staged files with dotnet format (style)..."
16+
tr '\n' '\0' < "$staged_files" \
17+
| xargs -0 dotnet format TurboSamplePlugin/TurboSamplePlugin.csproj style --verify-no-changes --no-restore --severity error --include
18+
else
19+
echo "No staged plugin C# files."
20+
fi
21+
22+
dotnet build TurboSamplePlugin/TurboSamplePlugin.csproj -t:TurboSamplePluginFastCheck

.githooks/pre-push

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env sh
2+
set -eu
3+
4+
echo "Running full quality gate before push..."
5+
dotnet build TurboSamplePlugin/TurboSamplePlugin.csproj -t:TurboSamplePluginQualityGate

.github/workflows/quality.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Code Quality
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
quality:
9+
name: quality-${{ matrix.os }}
10+
runs-on: ${{ matrix.os }}
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
os: [ubuntu-latest, windows-latest, macos-latest]
15+
steps:
16+
- name: Checkout turbo-sample-plugin
17+
uses: actions/checkout@v4
18+
with:
19+
path: turbo-sample-plugin
20+
21+
- name: Checkout turbo-cloud
22+
uses: actions/checkout@v4
23+
with:
24+
repository: nitrodevco/turbo-cloud
25+
path: turbo-cloud
26+
27+
- name: Setup .NET
28+
uses: actions/setup-dotnet@v4
29+
with:
30+
global-json-file: turbo-sample-plugin/global.json
31+
32+
- name: Run quality gate
33+
working-directory: turbo-sample-plugin
34+
run: dotnet build TurboSamplePlugin/TurboSamplePlugin.csproj -t:TurboSamplePluginQualityGate

AGENTS.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Turbo Sample Plugin Agent Notes
2+
3+
This repository stays lightweight. Full AI governance policy lives in `../turbo-cloud`.
4+
5+
## Plugin-specific placement rules
6+
- Keep plugin composition and service registration in `TurboSamplePlugin/TurboSamplePlugin.cs`.
7+
- Keep startup orchestration in `TurboSamplePlugin/SamplePluginService.cs`.
8+
- Add protocol changes under:
9+
- `TurboSamplePlugin/Revision/<revision>/Parsers/<Domain>/`
10+
- `TurboSamplePlugin/Revision/<revision>/Serializers/<Domain>/`
11+
- Treat `TurboSamplePlugin/Revision/README.md` as the local source of truth for revision layout.
12+
- Do not move or duplicate revision parsers/serializers into `turbo-cloud`.
13+
- For handler/grain architecture decisions (for example extended profile flow), follow:
14+
- `../turbo-cloud/AGENTS.md`
15+
- `../turbo-cloud/CONTEXT.md`
16+
- For task recipes and portable prompt contract, use `../turbo-cloud/AGENTS.md` as canonical.
17+
- Keep `PacketHandlers` and `EventHandlers` focused on message/event flow.
18+
- Keep database concerns in `TurboSamplePlugin/Database/`.
19+
20+
## Packet addition checklist (revision work)
21+
When adding packet mappings in `TurboSamplePlugin/Revision/Revision20260112`:
22+
1. Update `TurboSamplePlugin/Revision/Revision20260112/Headers.cs`:
23+
- add/update incoming `MessageEvent` id constants
24+
- add/update outgoing `MessageComposer` id constants
25+
2. Add parser class under:
26+
- `TurboSamplePlugin/Revision/Revision20260112/Parsers/<Domain>/*MessageParser.cs`
27+
3. Add serializer class under:
28+
- `TurboSamplePlugin/Revision/Revision20260112/Serializers/<Domain>/*MessageComposerSerializer.cs`
29+
4. Register mappings in:
30+
- `TurboSamplePlugin/Revision/Revision20260112/Revision20260112.cs`
31+
- incoming: `Parsers` dictionary with `MessageEvent` key
32+
- outgoing: `Serializers` dictionary with composer type + `MessageComposer` id
33+
5. Ensure the required `using` directives are present in `Revision20260112.cs` for new parser/serializer namespaces.
34+
35+
## Quality checks
36+
```bash
37+
dotnet build TurboSamplePlugin/TurboSamplePlugin.csproj -t:TurboSamplePluginFastCheck
38+
dotnet build TurboSamplePlugin/TurboSamplePlugin.csproj -t:TurboSamplePluginQualityGate
39+
```

CLAUDE.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Claude Adapter (Turbo Sample Plugin)
2+
3+
This repository keeps plugin-specific rules locally and inherits full AI governance from `../turbo-cloud`.
4+
5+
## Required context load order
6+
1. `AGENTS.md`
7+
2. `TurboSamplePlugin/Revision/README.md`
8+
3. `../turbo-cloud/AGENTS.md`
9+
4. `../turbo-cloud/CONTEXT.md`
10+
11+
## Non-negotiable constraints
12+
- Keep revision parser/serializer work under `TurboSamplePlugin/Revision/<revision>/**`.
13+
- Update `Headers.cs`, parser/serializer classes, and `Revision<id>.cs` mappings together.
14+
- Do not move protocol revision files into `turbo-cloud`.
15+
16+
## Validation commands
17+
```bash
18+
dotnet build TurboSamplePlugin/TurboSamplePlugin.csproj -t:TurboSamplePluginFastCheck
19+
dotnet build TurboSamplePlugin/TurboSamplePlugin.csproj -t:TurboSamplePluginQualityGate
20+
```

CODEX.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Codex Adapter (Turbo Sample Plugin)
2+
3+
This repository keeps plugin-specific rules locally and inherits full AI governance from `../turbo-cloud`.
4+
5+
## Required context load order
6+
1. `AGENTS.md`
7+
2. `TurboSamplePlugin/Revision/README.md`
8+
3. `../turbo-cloud/AGENTS.md`
9+
4. `../turbo-cloud/CONTEXT.md`
10+
11+
## Non-negotiable constraints
12+
- Keep revision parser/serializer work under `TurboSamplePlugin/Revision/<revision>/**`.
13+
- Update `Headers.cs`, parser/serializer classes, and `Revision<id>.cs` mappings together.
14+
- Do not move protocol revision files into `turbo-cloud`.
15+
16+
## Validation commands
17+
```bash
18+
dotnet build TurboSamplePlugin/TurboSamplePlugin.csproj -t:TurboSamplePluginFastCheck
19+
dotnet build TurboSamplePlugin/TurboSamplePlugin.csproj -t:TurboSamplePluginQualityGate
20+
```

CONTRIBUTING.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Contributing
2+
3+
If this is your first time in the plugin repo, run bootstrap:
4+
5+
PowerShell:
6+
7+
```powershell
8+
pwsh -File scripts/bootstrap.ps1
9+
```
10+
11+
bash/zsh:
12+
13+
```bash
14+
sh scripts/bootstrap.sh
15+
```
16+
17+
## Build and quality scope
18+
19+
| Command | Scope | Use when |
20+
| --- | --- | --- |
21+
| `dotnet build TurboSamplePlugin/TurboSamplePlugin.csproj` | Plugin only | Default contributor build |
22+
| `dotnet build ../turbo-cloud/Turbo.Main/Turbo.Main.csproj` | Core only | Verify emulator-only changes |
23+
| `dotnet build ../turbo-cloud/Turbo.Cloud.sln` | Full integrated workspace | One-window core+plugin workflow |
24+
25+
The plugin repo default quality/build contract is project-scoped to `TurboSamplePlugin/TurboSamplePlugin.csproj`.
26+
27+
### Fast check (pre-commit)
28+
29+
```bash
30+
dotnet build TurboSamplePlugin/TurboSamplePlugin.csproj -t:TurboSamplePluginFastCheck
31+
```
32+
33+
### Full gate (pre-push + CI)
34+
35+
```bash
36+
dotnet build TurboSamplePlugin/TurboSamplePlugin.csproj -t:TurboSamplePluginQualityGate
37+
```
38+
39+
## Integrated plugin workflow
40+
41+
PowerShell:
42+
43+
```powershell
44+
pwsh -File scripts/dev-integrated.ps1
45+
```
46+
47+
bash/zsh:
48+
49+
```bash
50+
sh scripts/dev-integrated.sh
51+
```
52+
53+
Build-only mode:
54+
- PowerShell: `pwsh -File scripts/dev-integrated.ps1 -BuildOnly`
55+
- bash/zsh: `sh scripts/dev-integrated.sh --build-only`
56+
57+
## Toolchain pinning
58+
59+
Pinned toolchain files:
60+
- .NET SDK pin: `global.json`
61+
- Local tools pin: `.config/dotnet-tools.json`
62+
63+
When bumping versions, include a passing `TurboSamplePluginQualityGate` run in the same change.
64+
65+
## Git hooks
66+
67+
Repository-managed hooks in `.githooks`:
68+
- `pre-commit` -> staged-file `dotnet format ... style --verify-no-changes` + `TurboSamplePluginFastCheck`
69+
- `pre-push` -> `TurboSamplePluginQualityGate`
70+
71+
Enable if needed:
72+
73+
```bash
74+
git config --local core.hooksPath .githooks
75+
```
76+
77+
## Local config and runtime linkage
78+
79+
Plugin DB/runtime local settings:
80+
1. Keep `.env` local to this repo and set `PLUGIN_DEV_CONNECTION`.
81+
2. Ensure `turbo-cloud/appsettings.Development.json` includes `Turbo:Plugin:DevPluginPaths`.
82+
83+
## Troubleshooting integrated builds
84+
85+
If integrated solution build fails due unrelated core/plugin state, isolate first:
86+
87+
```bash
88+
dotnet build TurboSamplePlugin/TurboSamplePlugin.csproj
89+
```

Directory.Build.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
<AnalysisLevel>latest</AnalysisLevel>
44
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
55
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
6+
<!-- Enforce critical Orleans serialization diagnostics for contributor safety. -->
7+
<WarningsAsErrors>$(WarningsAsErrors);ORLEANS0012;ORLEANS0013</WarningsAsErrors>
68
</PropertyGroup>
79
<ItemGroup>
810
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" PrivateAssets="all" />

0 commit comments

Comments
 (0)