-
Notifications
You must be signed in to change notification settings - Fork 3
infra: mandatory PR hygiene gate + CI hardening [Build 1111.011] #110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
e9b1763
f44543b
c74c8e0
c546920
8810b9c
6432df4
006b56e
751d385
2a12a92
db40d90
18b4b87
71ca4c0
4893acc
3b525ae
8a009cc
74ceaab
515398d
7453cec
d877eb2
3a0c4c5
38dd7d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| --- | ||
| description: Repeatable 100/100 Perfection Loop. Iteratively repairs and verifies code until the Project Health Score is 100/100. | ||
| argument-hint: <pr-number> | ||
| --- | ||
| # PR PERFECTION LOOP (pr-loop) | ||
| **Target PR:** $1 | ||
| **Goal:** 100/100 (25/25 Points) | ||
| **Mode:** Orchestrator (YOLO-parity) | ||
| **Protocol:** V12 Autonomous Perfection mandate. | ||
|
|
||
| You are the V12 Perfection Orchestrator. You MUST NOT STOP until PHS is 100/100. | ||
|
|
||
| --- | ||
|
|
||
| ## ORCHESTRATION RULES | ||
|
|
||
| - **SCORE 100 MANDATE**: You are BANNED from merging or ending the loop if PHS < 100. | ||
| - **HYGIENE GATE**: You MUST pass Step 0 (Clean Branch & Diff Size) before every push. | ||
| - **LOCAL FIRST**: You must achieve Local Score 15/15 before every push. | ||
| - **FORENSIC AUDIT**: Every failure must be categorized as [VALID], [HALLUCINATION], [INFRA-NOISE], or [ACCESS_BLOCKED]. | ||
| - **F5 GATE**: The only manual action is the final NinjaTrader verification at Score 100. | ||
|
|
||
| --- | ||
|
|
||
| ## THE PERFECTION CYCLE | ||
|
|
||
| ### Step 0: Pre-Flight Hygiene (MANDATORY) | ||
| **Switch to: Advanced mode** | ||
| Hand off: | ||
| ``` | ||
| TASK: Verify PR Hygiene | ||
| PROTOCOL: | ||
| 1. Run `powershell -File .\scripts\verify_pr_hygiene.ps1`. | ||
| 2. If FAIL: HALT and report the violation (e.g. "Diff > 10k" or "Branch is dirty"). | ||
| 3. If PASS: Advance to Step 1. | ||
| ``` | ||
|
|
||
| ### Step 1: Local Integrity (Goal: 15/15) | ||
| **Switch to: v12-engineer mode** | ||
| Hand off: | ||
| ``` | ||
| TASK: Local Repair & Hygiene | ||
| INPUT: PR #$1 bot findings + local lint/test results. | ||
| PROTOCOL: | ||
| 1. FIX all surgical violations (braces, sealed classes, complexity). | ||
| 2. CATEGORIZE issues in docs/brain/workflow_health.md ([VALID], [HALLUCINATION], [INFRA-NOISE]). | ||
| 3. VERIFY: Run `powershell -File .\scripts\calculate_fleet_score.ps1`. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P0: Missing required script Prompt for AI agents |
||
| 4. If Score < 15, repeat Step 1. | ||
| 5. If Score = 15, emit: [LOCAL-READY] PHS 15/15. | ||
| ``` | ||
|
|
||
| ### Step 2: Global Integrity (Goal: 25/25) | ||
| **Switch to: Advanced mode** | ||
| Hand off: | ||
| ``` | ||
| TASK: Global Audit & Monitor | ||
| PROTOCOL: | ||
| 1. git add . && git commit -m "fix: PHS Perfection Loop - PR #$1" && git push | ||
| 2. monitor_pr_checks $1 (Wait for all bots). | ||
| 3. Run `powershell -File .\scripts\calculate_fleet_score.ps1 -PrNumber $1`. | ||
| 4. If Score < 100, emit: [PHS-RETRY] Current: X/100. | ||
| 5. If Score = 100, emit: [PHS-PERFECT] 100/100. | ||
| ``` | ||
|
|
||
| ### Step 3: Loop Control | ||
| - If [PHS-RETRY]: **Restart at Step 1.** | ||
| - If [PHS-PERFECT]: **Advance to final F5 verification.** | ||
|
|
||
| --- | ||
|
|
||
| ## FINAL HANDSHAKE | ||
| Once 100/100 is achieved, STOP and ask Director: | ||
| "PHS 100/100 achieved. Please press F5 in NinjaTrader. Type 'F5 done' to merge." | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,35 @@ | ||
| --- | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: Removing Prompt for AI agents |
||
| engines: | ||
| csharp: true | ||
| markdown: false | ||
| python: false | ||
| shell: false | ||
| duplication: false | ||
| prospector: false | ||
| pylint: false | ||
| bandit: false | ||
| remark-lint: false | ||
|
|
||
| exclude_paths: | ||
| - "scripts/**" | ||
| - "docs/**" | ||
| - ".github/**" | ||
| - "**/*.md" | ||
| - "testsprite_tests/**" | ||
| - ".agent/**" | ||
| - ".agents/**" | ||
| - ".bob/**" | ||
| - ".codex/**" | ||
| - ".cursor/**" | ||
| - ".gemini/**" | ||
| - ".antigravitycli/**" | ||
| - "Traycerrefactor/**" | ||
| - "artifacts/**" | ||
| - "benchmarks/**" | ||
| - "node_modules/**" | ||
| - "obj/**" | ||
| - "bin/**" | ||
| - "**/*.md" | ||
| - "**/*.py" | ||
| - "**/*.ps1" | ||
| - "**/*.bat" | ||
| - "**/*.json" | ||
| - "**/*.yaml" | ||
| - "**/*.yml" | ||
| - "deploy-sync.ps1" | ||
| - "check_ascii.py" | ||
| - "fix_skills.py" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| scripts/** | ||
| docs/** | ||
| testsprite_tests/** | ||
| .agent/** | ||
| .agents/** | ||
| .bob/** | ||
| .codex/** | ||
| .cursor/** | ||
| .gemini/** | ||
| .antigravitycli/** | ||
| Traycerrefactor/** | ||
| artifacts/** | ||
| **/*.md | ||
| **/*.py | ||
| **/*.ps1 | ||
| **/*.bat | ||
| **/*.json | ||
| **/*.yaml | ||
| **/*.yml | ||
| deploy-sync.ps1 | ||
| check_ascii.py | ||
| fix_skills.py |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,9 +3,14 @@ name: CodeQL | |
| on: | ||
| push: | ||
| branches: ["main", "dev"] | ||
| paths: | ||
| - 'src/**/*.cs' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: The added Prompt for AI agents |
||
| - 'tests/**/*.cs' | ||
|
coderabbitai[bot] marked this conversation as resolved.
cubic-dev-ai[bot] marked this conversation as resolved.
|
||
| pull_request: | ||
| # CodeQL runs on ALL PRs regardless of target branch for maximum coverage. | ||
| # Previously limited to main -- expanded to catch vulnerabilities in feature branches before merge. | ||
| paths: | ||
| - 'src/**/*.cs' | ||
| - 'tests/**/*.cs' | ||
| schedule: | ||
| - cron: "0 6 * * 1" | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,82 @@ | ||||||||||
| # [SENTINEL] V12 Autonomous Testing Pyramid | ||||||||||
| # Implements Unit, Property, and TDD validation suites on hosted CI. | ||||||||||
| # Bypasses NinjaTrader DLL dependency via tests/NinjaTrader.Mocks.cs | ||||||||||
|
|
||||||||||
| name: "Sentinel Testing Pyramid" | ||||||||||
|
|
||||||||||
| on: | ||||||||||
| push: | ||||||||||
| branches: ["main", "build/**"] | ||||||||||
| paths: | ||||||||||
| - "src/**.cs" | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: The path filters use Prompt for AI agentsThere was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WARNING: Invalid glob |
||||||||||
| - "tests/**.cs" | ||||||||||
|
Comment on lines
+11
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: To match files nested under subdirectories in GitHub Actions Citations:
Use recursive path globs to match all nested C# files in the workflow trigger. The patterns Proposed fix- - "src/**.cs"
- - "tests/**.cs"
+ - "src/**/*.cs"
+ - "tests/**/*.cs"📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| - "Testing.csproj" | ||||||||||
| pull_request: | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WARNING: |
||||||||||
| branches: ["main"] | ||||||||||
|
|
||||||||||
| jobs: | ||||||||||
| test-pyramid: | ||||||||||
| name: Build & Run Pyramid Suites | ||||||||||
| runs-on: windows-latest | ||||||||||
|
|
||||||||||
| steps: | ||||||||||
| - name: Checkout repository | ||||||||||
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | ||||||||||
| with: | ||||||||||
| fetch-depth: 0 | ||||||||||
|
|
||||||||||
|
Comment on lines
+28
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: cat -n .github/workflows/sentinel-pyramid.ymlRepository: mkalhitti-cloud/universal-or-strategy Length of output: 3518 🌐 Web query:
💡 Result: Risk summary: Using actions/checkout with the default persist-credentials behavior can increase impact if later steps in the job are compromised, because the GitHub token used for authenticated git operations may be written to the runner’s local git configuration and be available to subsequent steps until cleanup. The safer configuration (when you don’t need authenticated git push/fetch) is to set persist-credentials: false on the checkout step. What persist-credentials does (per GitHub docs) - actions/checkout “persists the token in the local git config” so scripts can run authenticated git commands, and the token is “removed during post-job cleanup”. Setting persist-credentials: false “opt-out[s]” of this behavior. [1][2] Why that can be a security risk - Because the token is available to later steps, any malicious/compromised code running in the same job after checkout could potentially read and use it to perform operations with the token’s permissions (the practical impact depends on the token’s permissions configured for the workflow). This “credentials being persistent … gives every step … implicit access to the token” concern is explicitly discussed in the actions/checkout issue. [3] - OWASP’s GitHub Actions security guidance recommends using actions/checkout with persist-credentials: false “to prevent Git credentials from being persisted to the workflow’s environment, reducing the risk of credential exposure if the workflow is compromised.” [4] Mitigations / best practices (grounded in the sources above) 1) Set persist-credentials: false on actions/checkout unless you truly need authenticated git operations that require the token (e.g., pushing back to the repo). [1][4] 2) Ensure least-privilege token permissions (both the checkout docs and the discussion around this risk emphasize using minimal permissions). [1][3] Example workflow snippet - uses: actions/checkout@v5 with: persist-credentials: false Note on “how bad is it?” - The exact exploitation path isn’t fully described in the official checkout docs snippet we captured, but the core risk mechanism is: token persistence makes it accessible to subsequent steps in the same workflow run until post-job cleanup. [1][2] Citations:
Add
Proposed fix - name: Checkout repository
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0
+ persist-credentials: false🧰 Tools🪛 zizmor (1.25.2)[warning] 23-26: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false (artipacked) 🤖 Prompt for AI Agents |
||||||||||
| - name: Setup .NET | ||||||||||
| uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4 | ||||||||||
| with: | ||||||||||
| dotnet-version: "8.0.x" | ||||||||||
|
|
||||||||||
| - name: Restore dependencies | ||||||||||
| run: dotnet restore Testing.csproj --nologo | ||||||||||
| shell: pwsh | ||||||||||
|
|
||||||||||
| - name: 1. Unit Tests (Pure Logic) | ||||||||||
| # Validates math, sizing, and rounding kernels. | ||||||||||
| run: dotnet test Testing.csproj --filter "FullyQualifiedName~UniversalOrStrategy.Tests.LogicTests" --no-restore --nologo --logger "trx;LogFileName=unit-results.trx" | ||||||||||
| shell: pwsh | ||||||||||
|
|
||||||||||
| - name: 2. TDD Concurrency Suites (Epic 1 Delta) | ||||||||||
| # Validates lock-free patterns and atomic FSM transitions. | ||||||||||
| run: dotnet test Testing.csproj --filter "FullyQualifiedName~UniversalOrStrategy.Tests.Epic1DeltaTests" --no-restore --nologo --logger "trx;LogFileName=tdd-results.trx" | ||||||||||
| shell: pwsh | ||||||||||
|
|
||||||||||
| - name: 3. Property-Based Testing (FsCheck) | ||||||||||
| # [FUTURE] This will run FsCheck properties once defined in tests. | ||||||||||
| run: | | ||||||||||
| Write-Host "Searching for property tests..." | ||||||||||
| dotnet test Testing.csproj --filter "Category=Property" --no-restore --nologo | ||||||||||
| shell: pwsh | ||||||||||
|
|
||||||||||
| - name: Check for non-ASCII characters (ASCII Gate) | ||||||||||
| # [MANIFESTO] Section 7: Mandatory ASCII check for NT8 compiler safety. | ||||||||||
| run: | | ||||||||||
| $files = Get-ChildItem -Path "src" -Filter "*.cs" -Recurse | ||||||||||
| $violations = @() | ||||||||||
| foreach ($f in $files) { | ||||||||||
| $content = [System.IO.File]::ReadAllBytes($f.FullName) | ||||||||||
| foreach ($byte in $content) { | ||||||||||
| if ($byte -gt 127) { | ||||||||||
| $violations += $f.FullName | ||||||||||
| break | ||||||||||
| } | ||||||||||
| } | ||||||||||
| } | ||||||||||
| if ($violations.Count -gt 0) { | ||||||||||
| Write-Host "ASCII GATE FAILED -- non-ASCII bytes found in:" | ||||||||||
| $violations | ForEach-Object { Write-Host " - $_" } | ||||||||||
| exit 1 | ||||||||||
| } else { | ||||||||||
| Write-Host "ASCII Gate PASSED." | ||||||||||
| } | ||||||||||
| shell: pwsh | ||||||||||
|
|
||||||||||
| - name: Upload Test Results | ||||||||||
| if: always() | ||||||||||
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | ||||||||||
| with: | ||||||||||
| name: test-results | ||||||||||
| path: "**/TestResults/*.trx" | ||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,8 +4,14 @@ on: | |
| push: | ||
| branches: | ||
| - main | ||
| paths: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: Using Prompt for AI agents |
||
| - 'src/**/*.cs' | ||
| - 'tests/**/*.cs' | ||
| pull_request: | ||
| types: [opened, synchronize, reopened] | ||
| paths: | ||
| - 'src/**/*.cs' | ||
| - 'tests/**/*.cs' | ||
|
|
||
| jobs: | ||
| sonarcloud: | ||
|
|
@@ -39,7 +45,6 @@ jobs: | |
| # [NOTE] Hosted CI lacks proprietary NinjaTrader assemblies (targets .NET 4.8). | ||
| # Analysis is partial (no NinjaTrader refs), but we must allow it to proceed for SCA. | ||
| continue-on-error: true | ||
| continue-on-error: true | ||
| run: | | ||
| dotnet-sonarscanner begin /k:"mkalhitti-cloud_universal-or-strategy" /o:"mkalhitti-cloud" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vstest.reportsPaths="**/*.trx" /d:sonar.cs.opencover.reportsPaths="**/coverage.opencover.xml" /d:sonar.exclusions="docs/**,.github/**,**/*.md,.agent/**,.agents/**,.bob/**,.codex/**,.cursor/**,.gemini/**,Traycerrefactor/**,artifacts/**" | ||
| dotnet build Linting.csproj | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -30,11 +30,13 @@ | |||||
| - **Sovereign Audit**: `droid /review` (Focus on P0-P3 severity findings). | ||||||
| - **Readiness Check**: `droid /readiness-report` (Maintain Level 2+). | ||||||
| - **Forensic Scan**: `grep -r "lock(" src/` (Zero-match requirement). | ||||||
| - **Jane Street KB Query**: `& "%USERPROFILE%\AppData\Local\Programs\Python\Python312\python.exe" scripts/query_kb.py "<term>"` (Retrieves HFT and high-performance system guidelines from the Firestore knowledge base). | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hardcoding the specific Python installation path (including the version
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: Added line documents a Prompt for AI agents |
||||||
|
|
||||||
| ## 4. Communication & Context | ||||||
|
|
||||||
| - **Active Task**: Always check `docs/brain/task.md` before initiating work. | ||||||
| - **Handoffs**: Use the `docs/brain/nexus_a2a.json` via the **Nexus Bridge** for inter-agent state synchronization. | ||||||
| - **Expert Knowledge Base (RAG)**: Before starting complex design, refactoring, or performance engineering tasks, query the Jane Street Knowledge Base using `scripts/query_kb.py` to retrieve verified microsecond-latency patterns and testing standards. | ||||||
|
|
||||||
| ## 5. Karpathy Behavioral Protocols (LLM Coding Hygiene) | ||||||
|
|
||||||
|
|
@@ -59,7 +61,7 @@ | |||||
| - Touch only what you must. Clean up only your own mess. | ||||||
| - Do NOT "improve" adjacent code, comments, or formatting. | ||||||
| - **WHITESPACE MUTATION BANNED**: Never mutate whitespace, line endings, or indentation across files. This creates bloated diffs that obscure logic and break CI limits. | ||||||
| - **STRICT DIFF LIMIT**: Pull Request diffs MUST remain under 150,000 characters. | ||||||
| - **STRICT DIFF LIMIT**: Pull Request diffs MUST target less than 10,000 characters of source code changes (in `src/`). Split larger epics into smaller, focused PRs. | ||||||
| - **DIFF PRE-CHECK**: Before pushing, run `powershell -File .\deploy-sync.ps1`. If the **DIFF GUARD** fails, you must isolate the logic changes and revert whitespace/artifact bloat. | ||||||
| - If unrelated dead code is noticed, REPORT it -- do not act on it. | ||||||
| - Every changed line must trace directly to the Mission Brief. | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add language identifiers to fenced code blocks.
The three fenced blocks are missing language tags, which triggers markdownlint MD040 and can fail docs hygiene checks.
Suggested patch
@@
-
+textTASK: Local Repair & Hygiene
INPUT: PR #$1 bot findings + local lint/test results.
PROTOCOL:
powershell -File .\scripts\calculate_fleet_score.ps1.Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.bob/commands/pr-loop.md around lines 30 - 36, Add language identifiers to
the three fenced code blocks so markdownlint MD040 is satisfied: update the
fences surrounding the blocks that start with "TASK: Verify PR Hygiene", "TASK:
Local Repair & Hygiene", and "TASK: Global Audit & Monitor" to use a language
tag such as "text" (i.e., change
totext for each of those fenced blocks)so the docs pass hygiene checks; apply the same change to the other occurrences
mentioned (lines referenced in the review: the additional blocks at 41-50 and
55-63).