Skip to content

Commit ccd9287

Browse files
Pigbibicodex
andcommitted
fix: isolate quant monitor repository sync
Co-Authored-By: Codex <noreply@openai.com>
1 parent 1220846 commit ccd9287

5 files changed

Lines changed: 28 additions & 12 deletions

File tree

ops/quant-monitor/scripts/common_env.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ AAB_ROOT="${AIAUDIT_BRIDGE_ROOT:-$(cd "$ROOT/../.." && pwd)}"
77
PROJECTS_ROOT="${PROJECTS_ROOT:-$HOME/Projects}"
88
QUANT_PROJECTS_ROOT="${QUANT_PROJECTS_ROOT:-$ROOT/data/lifecycle-projects}"
99
LIFECYCLE_LOCAL_ROOT="${LIFECYCLE_LOCAL_ROOT:-$ROOT/data/lifecycle-store}"
10-
QPK_ROOT="${QUANT_PLATFORM_KIT_ROOT:-$PROJECTS_ROOT/QuantPlatformKit}"
10+
# Monitoring must never import an editable QuantPlatformKit checkout from a
11+
# developer workspace: the monitor synchronizes and consumes this dedicated
12+
# mirror instead.
13+
QPK_ROOT="${QUANT_PLATFORM_KIT_ROOT:-$QUANT_PROJECTS_ROOT/QuantPlatformKit}"
1114
VENV="${QUANT_MONITOR_VENV:-$ROOT/.venv}"
1215

1316
export QUANT_MONITOR_ROOT="$ROOT"

ops/quant-monitor/scripts/sync_strategy_repos.sh

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,34 @@ REPOS=(
77
UsEquityStrategies
88
CryptoStrategies
99
)
10-
ROOT="${PROJECTS_ROOT:-$HOME/Projects}"
10+
ROOT="${QUANT_MONITOR_ROOT:-$(cd "$(dirname "$0")/.." && pwd)}"
11+
MIRROR_ROOT="${QUANT_PROJECTS_ROOT:-$ROOT/data/lifecycle-projects}"
12+
REPOSITORY_BASE_URL="${QUANT_MONITOR_REPOSITORY_BASE_URL:-https://github.com/QuantStrategyLab}"
1113
failed=0
14+
15+
mkdir -p "$MIRROR_ROOT"
16+
1217
for repo in "${REPOS[@]}"; do
13-
dir="$ROOT/$repo"
18+
dir="$MIRROR_ROOT/$repo"
1419
if [[ -d "$dir/.git" ]]; then
1520
if ! git -C "$dir" fetch origin main --quiet; then
1621
echo "[sync] $repo fetch failed" >&2
1722
failed=1
1823
continue
1924
fi
20-
if ! git -C "$dir" checkout main --quiet; then
25+
if ! git -C "$dir" checkout --detach --quiet origin/main; then
2126
echo "[sync] $repo checkout failed" >&2
2227
failed=1
2328
continue
2429
fi
25-
if ! git -C "$dir" pull --ff-only origin main --quiet; then
26-
echo "[sync] $repo pull failed" >&2
30+
echo "[sync] $repo ok"
31+
else
32+
if ! git clone --depth 1 "$REPOSITORY_BASE_URL/$repo.git" "$dir" --quiet; then
33+
echo "[sync] $repo clone failed" >&2
2734
failed=1
2835
continue
2936
fi
30-
echo "[sync] $repo ok"
31-
else
32-
echo "[sync] skip missing $dir" >&2
37+
echo "[sync] $repo cloned"
3338
fi
3439
done
3540
exit "$failed"

ops/quant-monitor/systemd/codex-daily-briefing.service.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Group=ubuntu
1010
WorkingDirectory=/home/ubuntu/Projects/AIAuditBridge/ops/quant-monitor
1111
Environment=QUANT_MONITOR_ROOT=/home/ubuntu/Projects/AIAuditBridge/ops/quant-monitor
1212
Environment=AIAUDIT_BRIDGE_ROOT=/home/ubuntu/Projects/AIAuditBridge
13-
Environment=QUANT_PLATFORM_KIT_ROOT=/home/ubuntu/Projects/QuantPlatformKit
13+
Environment=QUANT_PLATFORM_KIT_ROOT=/home/ubuntu/Projects/AIAuditBridge/ops/quant-monitor/data/lifecycle-projects/QuantPlatformKit
1414
Environment=QUANT_SENTINEL_TELEGRAM_SECRET_NAME=quant-sentinel-telegram-bot-token
1515
Environment=QUANT_SENTINEL_GCP_PROJECT=firstradequant
1616
Environment=GLOBAL_TELEGRAM_CHAT_ID=

ops/quant-monitor/systemd/codex-quant.service.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Group=ubuntu
1010
WorkingDirectory=/home/ubuntu/Projects/AIAuditBridge/ops/quant-monitor
1111
Environment=QUANT_MONITOR_ROOT=/home/ubuntu/Projects/AIAuditBridge/ops/quant-monitor
1212
Environment=AIAUDIT_BRIDGE_ROOT=/home/ubuntu/Projects/AIAuditBridge
13-
Environment=QUANT_PLATFORM_KIT_ROOT=/home/ubuntu/Projects/QuantPlatformKit
13+
Environment=QUANT_PLATFORM_KIT_ROOT=/home/ubuntu/Projects/AIAuditBridge/ops/quant-monitor/data/lifecycle-projects/QuantPlatformKit
1414
Environment=QUANT_SENTINEL_TELEGRAM_SECRET_NAME=quant-sentinel-telegram-bot-token
1515
Environment=QUANT_SENTINEL_GCP_PROJECT=firstradequant
1616
# Set on VPS only — do not commit real chat id to git:

ops/quant-monitor/tests/test_deploy_scripts.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,18 @@ def test_common_env_separates_code_and_lifecycle_data_roots(self) -> None:
4646
str(Path(home) / "Projects"),
4747
str(monitor_root / "data" / "lifecycle-projects"),
4848
str(monitor_root / "data" / "lifecycle-store"),
49-
str(Path(home) / "Projects" / "QuantPlatformKit"),
49+
str(monitor_root / "data" / "lifecycle-projects" / "QuantPlatformKit"),
5050
],
5151
)
5252

53+
def test_strategy_sync_uses_dedicated_mirrors(self) -> None:
54+
script = (ROOT / "scripts" / "sync_strategy_repos.sh").read_text(encoding="utf-8")
55+
56+
self.assertIn('MIRROR_ROOT="${QUANT_PROJECTS_ROOT:-$ROOT/data/lifecycle-projects}"', script)
57+
self.assertIn('dir="$MIRROR_ROOT/$repo"', script)
58+
self.assertIn("checkout --detach --quiet origin/main", script)
59+
self.assertNotIn("pull --ff-only", script)
60+
5361
def test_health_check_syncs_artifacts_before_monitoring(self) -> None:
5462
script = (ROOT / "scripts" / "health_check.sh").read_text(encoding="utf-8")
5563

0 commit comments

Comments
 (0)