Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .agent/rules/zero_waste_discovery.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Zero-Waste Discovery Protocol (V12.932)

## 🛡️ MISSION
To prevent AI agents from wasting tokens, time, and "Context Space" on irrelevant legacy code, backups, and non-active logic nodes.

## 1. Automated Exclusion Rules
AI agents MUST automatically exclude the following patterns from all global scans, refactoring tasks, and audits (unless explicitly instructed by the Director):

* **Backups**: `*.bak`, `*.bak_*`, `*.backup`, `*.old`
* **Datestamps**: Files containing `YYYYMMDD` patterns (e.g. `*.20260224.cs`)
* **Archives**: Files in `ARCHIVE_*`, `LEGACY_*`, or `DEVELOPMENT/TRASH` folders.
* **Binaries**: `*.exe`, `*.dll`, `*.pdb`, `*.user`, `*.suo`
* **Meta**: `.git`, `.qodo`, `.testsprite`, `.claude/cache`

## 2. Active Fleet Focus
When a "Global Scan" or "Project Simplification" is requested, the agent MUST restrict its search space to the **Active Logic Fleet**:
* Directory: `src/`
* Inclusion: `*.cs`
* Exclusion: (All patterns in Section 1)

## 3. Context Conservation
* **Single-File Priority**: If a bug is in `SIMA.cs`, do NOT read `Properties.cs` or `Entries.cs`.
* **Grep-First**: Always use `grep` to find specific line numbers before reading a full file.
* **No Redundant Scanning**: If a file was audited in the last 24 hours and the hash hasn't changed, do not re-scan it.

## 4. Director Escalation
If an agent believes a legacy or backup file contains critical "Logic DNA" needed for a repair, it MUST ask the Director: *"I have found a potential fix in a legacy backup [filename]. Permission to ingest?"*

---
> [!IMPORTANT]
> Failure to follow this protocol results in "Context Debt" and degrades the quality of AI-driven repairs. Protect the Token Budget.
47 changes: 47 additions & 0 deletions .agent/standards_manifesto.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Universal Standards Manifesto: V12 Permanent DNA

This document provides the immutable technical standards for all AI agents (Anthropic, Codex, Antigravity, Cursor, Gemini, Rovo Dev) working on the **Universal OR Strategy V12**.

## 1. Zero-Trust Safety Protocol (The "Law")
* **Verify, Don't Assume:** Never assume the strategy state (e.g., `activePositions`) matches the broker state. Always use `FirstOrDefault` when looking up positions in `acct.Positions` using the instrument object identity.
* **Terminal Removal:** Only remove order references from dictionaries (`stopOrders`, `target1Orders`, etc.) after a broker-confirmed terminal state (`Filled`, `Cancelled`, `Rejected`, `Unknown`).
* **Lifecycle Guards:** Any manual flatten or entry must check `isFlattenRunning` to prevent ordering loops.

## 2. Concurrency & Locking
* **StateLock Rule:** Every mutation of `activePositions`, `entryOrders`, `stopOrders`, or `expectedPositions` MUST occur inside a `lock(stateLock)`.
* **Volatile Optimization:** If a variable is marked `volatile` and is being used for a simple "read-only" check (e.g., `if (pos.RemainingContracts > 0)`), remove unnecessary locks to minimize thread contention.
* **Semaphore Guards:** All `_simaToggleSem.Wait()` calls must be paired with a `Release()` inside a `finally` block.

## 3. Coding Style & Modularity
* **Modular Parity:** Maintain the split file structure (e.g., `SIMA.cs`, `Orders.Management.cs`). Use `partial class` correctly.
* **Naming:** Use `PascalCase` for Methods/Properties, `camelCase` for fields/locals.
* **Metabolic Elegance:** Prioritize readable, surgical logic over dense one-liners.

## 4. Multi-Agent Collaboration Protocol
* **Advisor (Antigravity):** The **"General Manager."** Handles high-level brainstorming, diagnosing market issues, and engineering the core "Mission Prompt."
* **Desk Supervisor & Lab (Gemini CLI):** The **"Quant & Compliance."** Uses **Conductor/ODIN** to turn Antigravity prompts into rigid technical plans. Uses the **Sandbox** to test math/logic in Python before implementation. Runs local security/lint audits.
* **Lead Engineer (Claude Code):** The **"Execution Specialist."** Performs high-speed implementing with **Simultaneous Auditing**.
* **Forensic Auditor (Codex):** The **"Deep Logic Inspector."** Performs a 360-degree forensic scan for logic traps/leaks.
* **Secondary Auditor (Cursor AI):** The **"Peer Reviewer."** Performed by the Cursor agent to provide a cross-verification audit from a different model perspective.
* **Maintenance Inspector (Human):** The **"Final Sign-off."** Used by the Fund Manager in Cursor to perform visual review and manual polish.
* **Context Layer (OneContext):** The **"Order Book."** Maintains a shared trajectory of all agent thoughts and actions.
* **The Bridge:** Handoffs are managed via `implementation_plan.md`, `session_handoff.md`, and **OneContext snapshots**.

## 5. Multi-Agent Parity & Sync Protocol
* **Unified Tooling (MCP):** All MCP servers configured for Claude (`.mcp.json`) must be mirrored in the Gemini CLI (`settings.json`). This ensures that if Claude has access to things like `csharp-lsp` or `tavily-search`, Gemini and Rovo Dev do too.
* **High-Performance Tooling (The Triple Threat):**
- **Tool Search (Discovery):** Used to find specialized tools on-demand. Prevents token-leak.
- **Fine-Grained Streaming (Data Flow):** Streams large parameters (e.g., mass-refactors) without buffering. Reduces initial latency.
- **PTC (Execution):** Runs discovered tools at high frequency inside code containers. Reduces round-trips.
* **Context Parity:** The Project DNA in `CLAUDE.md` must be identical to `GEMINI.md`. All agents must read from the same baseline instructions.
* **Environment Sync:** All agents (including Rovo Dev) must have access to the same local environment variables (API keys, project paths) to ensure execution parity.

## 6. Clean-Slate Repo Hygiene (The "Hygiene Rule")
* **Zero-Delta Mandate**: Every new Mission (initialized via `$MISSION`) MUST start with a 0-delta `main` branch. If "Big Numbers" (large uncommitted/unmerged diffs > 100 lines) exist, the agent MUST recommend a cleanup/merge before starting new work.
* **Atomic Missions**: Every bug fix or feature MUST be its own branch and MUST be merged into `main` immediately upon verification (e.g. F5 compile in NT8). No "stacking" unrelated fixes in long-lived branches.
* **Binary & Log Purge**: Never commit `.exe`, `.log`, `.bak`, or legacy backup folders to source control. They should be stashed, deleted, or added to `.gitignore`.
* **Dashboard Cleanup**: Before ending a session, the agent MUST ensure all work is either Committed or the user has been guided to Merge. The goal is a +0/-0 dashboard between missions.

---
> [!NOTE]
> This document defines **Permanent Standards**. For current active refactoring goals (e.g. Phase 6.0 Simplification), refer to the specific **Implementation Plan** or **Refactoring Roadmap** files.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
bin/
obj/
*.bak*
*.202*
# Zero-Waste Discovery Rule: .agent/rules/zero_waste_discovery.md

# AI System Plumbing (Claude Code / MCP / Antigravity)
.agent/
Expand Down
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
## 🛡️ Protocol Hardening (V12.Phase7)

### 1. Scope Control
- **Discovery Guard**: AI agents MUST automatically ignore all backups (`*.bak`), archives (`ARCHIVE_*`), and date-stamped files from global scans. Reference **[.agent/rules/zero_waste_discovery.md](file:///.agent/rules/zero_waste_discovery.md)** for the full exclusion patterns.
- **Surgical Edits**: AI agents MUST restrict code modifications to the specific files requested in the Mission Brief. NEVER refactor unrelated files without explicit Director authorization.
- **Zero-Trust Planning**: Always generate an `implementation_plan.md` before applying code changes to local files.

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ Verify the project structure and path integrity:
- **Multi-Agent Audit**: Refer to [multi_agent_audit.md](file:///.agent/workflows/multi_agent_audit.md) for coordinating the Reaper Scan.

---
*Status: V12.44 Baseline (Hardened)*
*Status: Build 932 (Stabilized Final)*
72 changes: 41 additions & 31 deletions deploy-sync.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,29 @@ $NtIndicatorDir = Join-Path $NtCustomDir "Indicators"
# File Mappings (Source in Repo -> Target in NT8)
$Mappings = @(
# Indicators
@{ src = "V12StandardPanel_V12_001_Dev.cs"; dst = Join-Path $NtIndicatorDir "V12StandardPanel_V12_001_Dev.cs" },
@{ src = "V12_001.cs"; dst = Join-Path $NtIndicatorDir "V12_001.cs" },

# Strategy (Modularized V12_002 Series)
@{ src = "UniversalORStrategyV12_002_Dev.cs"; dst = Join-Path $NtStrategyDir "UniversalORStrategyV12_002_Dev.cs" },
@{ src = "UniversalORStrategyV12_002_Dev.Entries.cs"; dst = Join-Path $NtStrategyDir "UniversalORStrategyV12_002_Dev.Entries.cs" },
@{ src = "UniversalORStrategyV12_002_Dev.Entries.FFMA.cs"; dst = Join-Path $NtStrategyDir "UniversalORStrategyV12_002_Dev.Entries.FFMA.cs" },
@{ src = "UniversalORStrategyV12_002_Dev.Entries.OR.cs"; dst = Join-Path $NtStrategyDir "UniversalORStrategyV12_002_Dev.Entries.OR.cs" },
@{ src = "UniversalORStrategyV12_002_Dev.Entries.RMA.cs"; dst = Join-Path $NtStrategyDir "UniversalORStrategyV12_002_Dev.Entries.RMA.cs" },
@{ src = "UniversalORStrategyV12_002_Dev.Entries.MOMO.cs"; dst = Join-Path $NtStrategyDir "UniversalORStrategyV12_002_Dev.Entries.MOMO.cs" },
@{ src = "UniversalORStrategyV12_002_Dev.Entries.Trend.cs"; dst = Join-Path $NtStrategyDir "UniversalORStrategyV12_002_Dev.Entries.Trend.cs" },
@{ src = "UniversalORStrategyV12_002_Dev.Entries.Retest.cs"; dst = Join-Path $NtStrategyDir "UniversalORStrategyV12_002_Dev.Entries.Retest.cs" },
@{ src = "UniversalORStrategyV12_002_Dev.Orders.Callbacks.cs"; dst = Join-Path $NtStrategyDir "UniversalORStrategyV12_002_Dev.Orders.Callbacks.cs" },
@{ src = "UniversalORStrategyV12_002_Dev.Orders.Management.cs"; dst = Join-Path $NtStrategyDir "UniversalORStrategyV12_002_Dev.Orders.Management.cs" },
@{ src = "UniversalORStrategyV12_002_Dev.SIMA.cs"; dst = Join-Path $NtStrategyDir "UniversalORStrategyV12_002_Dev.SIMA.cs" },
@{ src = "UniversalORStrategyV12_002_Dev.REAPER.cs"; dst = Join-Path $NtStrategyDir "UniversalORStrategyV12_002_Dev.REAPER.cs" },
@{ src = "UniversalORStrategyV12_002_Dev.UI.Callbacks.cs"; dst = Join-Path $NtStrategyDir "UniversalORStrategyV12_002_Dev.UI.Callbacks.cs" },
@{ src = "UniversalORStrategyV12_002_Dev.UI.Compliance.cs"; dst = Join-Path $NtStrategyDir "UniversalORStrategyV12_002_Dev.UI.Compliance.cs" },
@{ src = "UniversalORStrategyV12_002_Dev.UI.IPC.cs"; dst = Join-Path $NtStrategyDir "UniversalORStrategyV12_002_Dev.UI.IPC.cs" },
@{ src = "UniversalORStrategyV12_002_Dev.UI.Sizing.cs"; dst = Join-Path $NtStrategyDir "UniversalORStrategyV12_002_Dev.UI.Sizing.cs" },
@{ src = "UniversalORStrategyV12_002_Dev.Symmetry.cs"; dst = Join-Path $NtStrategyDir "UniversalORStrategyV12_002_Dev.Symmetry.cs" },
@{ src = "UniversalORStrategyV12_002_Dev.LogicAudit.cs"; dst = Join-Path $NtStrategyDir "UniversalORStrategyV12_002_Dev.LogicAudit.cs" },
@{ src = "UniversalORStrategyV12_002_Dev.Trailing.cs"; dst = Join-Path $NtStrategyDir "UniversalORStrategyV12_002_Dev.Trailing.cs" },
@{ src = "UniversalORStrategyV12_002_Dev.Properties.cs"; dst = Join-Path $NtStrategyDir "UniversalORStrategyV12_002_Dev.Properties.cs" },
@{ src = "V12_002.cs"; dst = Join-Path $NtStrategyDir "V12_002.cs" },
@{ src = "V12_002.Entries.cs"; dst = Join-Path $NtStrategyDir "V12_002.Entries.cs" },
@{ src = "V12_002.Entries.FFMA.cs"; dst = Join-Path $NtStrategyDir "V12_002.Entries.FFMA.cs" },
Comment on lines +19 to +21

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Clean up legacy file links during rename migration

The mapping now only deploys V12_002*/V12_001 files, but the script has no migration step to remove previously deployed UniversalORStrategyV12_002_Dev* and V12StandardPanel_V12_001_Dev files, so existing NT8 environments keep stale legacy scripts side-by-side with the renamed ones. In setups that already ran older builds, this causes parallel old/new strategy code to remain compiled and can lead to running outdated logic unintentionally.

Useful? React with 👍 / 👎.

@{ src = "V12_002.Entries.OR.cs"; dst = Join-Path $NtStrategyDir "V12_002.Entries.OR.cs" },
@{ src = "V12_002.Entries.RMA.cs"; dst = Join-Path $NtStrategyDir "V12_002.Entries.RMA.cs" },
@{ src = "V12_002.Entries.MOMO.cs"; dst = Join-Path $NtStrategyDir "V12_002.Entries.MOMO.cs" },
@{ src = "V12_002.Entries.Trend.cs"; dst = Join-Path $NtStrategyDir "V12_002.Entries.Trend.cs" },
@{ src = "V12_002.Entries.Retest.cs"; dst = Join-Path $NtStrategyDir "V12_002.Entries.Retest.cs" },
@{ src = "V12_002.Orders.Callbacks.cs"; dst = Join-Path $NtStrategyDir "V12_002.Orders.Callbacks.cs" },
@{ src = "V12_002.Orders.Management.cs"; dst = Join-Path $NtStrategyDir "V12_002.Orders.Management.cs" },
@{ src = "V12_002.SIMA.cs"; dst = Join-Path $NtStrategyDir "V12_002.SIMA.cs" },
@{ src = "V12_002.REAPER.cs"; dst = Join-Path $NtStrategyDir "V12_002.REAPER.cs" },
@{ src = "V12_002.UI.Callbacks.cs"; dst = Join-Path $NtStrategyDir "V12_002.UI.Callbacks.cs" },
@{ src = "V12_002.UI.Compliance.cs"; dst = Join-Path $NtStrategyDir "V12_002.UI.Compliance.cs" },
@{ src = "V12_002.UI.IPC.cs"; dst = Join-Path $NtStrategyDir "V12_002.UI.IPC.cs" },
@{ src = "V12_002.UI.Sizing.cs"; dst = Join-Path $NtStrategyDir "V12_002.UI.Sizing.cs" },
@{ src = "V12_002.Symmetry.cs"; dst = Join-Path $NtStrategyDir "V12_002.Symmetry.cs" },
@{ src = "V12_002.LogicAudit.cs"; dst = Join-Path $NtStrategyDir "V12_002.LogicAudit.cs" },
@{ src = "V12_002.Trailing.cs"; dst = Join-Path $NtStrategyDir "V12_002.Trailing.cs" },
@{ src = "V12_002.Properties.cs"; dst = Join-Path $NtStrategyDir "V12_002.Properties.cs" },

# Shared Components
@{ src = "SignalBroadcaster.cs"; dst = Join-Path $NtStrategyDir "SignalBroadcaster.cs" }
Expand All @@ -44,7 +44,13 @@ $Mappings = @(
Write-Host "`n--- WSGTA DEPLOY SYNC: Hardening Environment ---" -ForegroundColor Cyan

foreach ($map in $Mappings) {
$srcPath = Join-Path (Join-Path $RepoRoot "src") $map.src
if ($map.src -match "Indicator") {
$srcPath = Join-Path (Join-Path $RepoRoot "src") $map.src
}
else {
$srcPath = Join-Path (Join-Path $RepoRoot "src") $map.src
}

$dstPath = $map.dst

if (!(Test-Path $srcPath)) {
Expand All @@ -59,16 +65,20 @@ foreach ($map in $Mappings) {
# Sync Logic
if (Test-Path $dstPath) {
$item = Get-Item $dstPath
if ($item.Attributes -match "ReparsePoint") {
# Check if it's already linked
Write-Host "SECURE: $($map.src) is already linked." -ForegroundColor Gray
continue
}
# If it's a file but NOT a link, backup it
# Check if it's already a link to the current source
$isLink = $item.Attributes -match "ReparsePoint"

# Backup if it's a real file (to avoid losing work)
$backup = $dstPath + ".bak_" + (Get-Date -Format "yyyyMMdd_HHmm")
Write-Host "BACKUP: Archiving existing NT file -> $(Split-Path $backup -Leaf)" -ForegroundColor Yellow
Move-Item $dstPath $backup
if ($isLink) {
# Verify it points to the right place or just recreate it
Remove-Item $dstPath -Force
}
else {
# Backup if it's a real file (to avoid losing work)
$backup = $dstPath + ".bak_" + (Get-Date -Format "yyyyMMdd_HHmm")
Write-Host "BACKUP: Archiving existing NT file -> $(Split-Path $backup -Leaf)" -ForegroundColor Yellow
Move-Item $dstPath $backup
}
}

# Create the Link
Expand Down
Loading