OPC # 0001: Extract OPC into standalone repo

This commit is contained in:
amadzarak
2026-04-25 17:26:42 -04:00
commit 42383bdc03
170 changed files with 21365 additions and 0 deletions
+102
View File
@@ -0,0 +1,102 @@
# clean-slate.ps1
# Wipes all Aspire-managed containers, volumes, and local state for a full clean provision.
# clarity-net is preserved — it was created manually and is permanent.
#
# Usage: .\scripts\clean-slate.ps1
# Add -KeepVolumes to stop/remove containers but leave postgres/vault data intact.
param(
[switch]$KeepVolumes
)
$repoRoot = Split-Path -Parent $PSScriptRoot
Write-Host "`n=== Clarity Clean Slate ===" -ForegroundColor Cyan
# ── 1. Containers ────────────────────────────────────────────────────────────
Write-Host "`n[1/4] Stopping and removing containers..." -ForegroundColor Yellow
$containers = docker ps -a --format "{{.Names}}" | Where-Object { $_ -notmatch "^\s*$" }
if ($containers) {
foreach ($c in $containers) {
Write-Host " Removing $c"
docker stop $c --time 5 2>$null | Out-Null
docker rm $c 2>$null | Out-Null
}
} else {
Write-Host " No containers found."
}
# ── 2. Volumes ────────────────────────────────────────────────────────────────
if ($KeepVolumes) {
Write-Host "`n[2/4] Skipping volume wipe (-KeepVolumes set)." -ForegroundColor DarkYellow
} else {
Write-Host "`n[2/4] Removing anonymous and dangling volumes..." -ForegroundColor Yellow
docker volume prune -f 2>$null | Out-Null
Write-Host " Done."
}
# ── 3. Stale Docker networks (keep clarity-net) ────────────────────────────
Write-Host "`n[3/4] Pruning stale networks (clarity-net preserved)..." -ForegroundColor Yellow
docker network prune -f 2>$null | Out-Null
Write-Host " Done."
# ── 4. Local state on disk ────────────────────────────────────────────────────
Write-Host "`n[4/4] Cleaning local disk state..." -ForegroundColor Yellow
# VaultData — remove init.json and raft data so Vault re-initializes fresh
$vaultData = Join-Path $repoRoot "ControlPlane.AppHost\VaultData"
if (Test-Path $vaultData) {
Get-ChildItem $vaultData -Recurse -File | ForEach-Object {
Write-Host " Removing $_"
Remove-Item $_.FullName -Force
}
} else {
Write-Host " VaultData folder not found, skipping."
}
# ClientAssets XMLs — provisioning records for old tenants
$clientAssets = Join-Path $repoRoot "ClientAssets"
if (Test-Path $clientAssets) {
$xmlFiles = Get-ChildItem $clientAssets -Filter "*.xml"
if ($xmlFiles) {
foreach ($f in $xmlFiles) {
Write-Host " Removing $($f.Name)"
Remove-Item $f.FullName -Force
}
} else {
Write-Host " No XML files found in ClientAssets."
}
} else {
Write-Host " ClientAssets folder not found, skipping."
}
# nginx conf.d — per-tenant route configs from previous provisioning runs
$nginxConfD = Join-Path $repoRoot "ControlPlane.AppHost\NginxConfig\conf.d"
if (Test-Path $nginxConfD) {
$confFiles = Get-ChildItem $nginxConfD -Filter "*.conf"
if ($confFiles) {
foreach ($f in $confFiles) {
Write-Host " Removing $($f.Name)"
Remove-Item $f.FullName -Force
}
} else {
Write-Host " No .conf files found in nginx conf.d."
}
} else {
Write-Host " NginxConfig/conf.d folder not found, skipping."
}
# ── Done ─────────────────────────────────────────────────────────────────────
Write-Host "`n=== Clean slate complete ===" -ForegroundColor Green
Write-Host "clarity-net is still present: $(docker network ls --format '{{.Name}}' | Where-Object { $_ -eq 'clarity-net' })" -ForegroundColor Green
Write-Host "`nNext steps:"
Write-Host " 1. Start ControlPlane.AppHost in Visual Studio"
Write-Host " 2. Wait for all containers to be healthy"
Write-Host " 3. Submit a provisioning job"
+54
View File
@@ -0,0 +1,54 @@
-- OPC schema — run once against the controlplanedb database
-- Convention: commits are linked by scanning git log for "OPC # XXXX" in the subject,
-- no separate commit table needed.
CREATE TABLE IF NOT EXISTS opc (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
number VARCHAR(20) NOT NULL UNIQUE, -- OPC # 0001
title VARCHAR(500) NOT NULL,
description TEXT NOT NULL DEFAULT '',
type VARCHAR(50) NOT NULL DEFAULT 'General',
status VARCHAR(50) NOT NULL DEFAULT 'New',
priority VARCHAR(20) NOT NULL DEFAULT 'Medium',
assignee VARCHAR(200) NOT NULL DEFAULT '',
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE TABLE IF NOT EXISTS opc_note (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
opc_id UUID NOT NULL REFERENCES opc(id) ON DELETE CASCADE,
author VARCHAR(200) NOT NULL,
content TEXT NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
-- Artifact types: BusinessRequirement, Rule, Spec, Documentation, QaTestPath
CREATE TABLE IF NOT EXISTS opc_artifact (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
opc_id UUID NOT NULL REFERENCES opc(id) ON DELETE CASCADE,
artifact_type VARCHAR(50) NOT NULL,
title VARCHAR(500) NOT NULL DEFAULT '',
content TEXT NOT NULL DEFAULT '',
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
-- Index to quickly look up by OPC number (used for git log grep linkage)
CREATE INDEX IF NOT EXISTS ix_opc_number ON opc(number);
CREATE INDEX IF NOT EXISTS ix_opc_note_opc_id ON opc_note(opc_id);
CREATE INDEX IF NOT EXISTS ix_opc_artifact_opc_id ON opc_artifact(opc_id);
-- Manually pinned commits (in addition to auto-detected via git log grep)
CREATE TABLE IF NOT EXISTS opc_pinned_commit (
opc_id UUID NOT NULL REFERENCES opc(id) ON DELETE CASCADE,
hash VARCHAR(40) NOT NULL,
short_hash VARCHAR(10) NOT NULL DEFAULT '',
subject VARCHAR(1000) NOT NULL DEFAULT '',
author VARCHAR(200) NOT NULL DEFAULT '',
pinned_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
pinned_by VARCHAR(200) NOT NULL DEFAULT '',
PRIMARY KEY (opc_id, hash)
);
CREATE INDEX IF NOT EXISTS ix_opc_pinned_commit_opc_id ON opc_pinned_commit(opc_id);
CREATE INDEX IF NOT EXISTS ix_opc_artifact_type ON opc_artifact(opc_id, artifact_type);