Compare commits

...
Author SHA1 Message Date
Antigravity AI 76f45ca249 fix: generate ENCRYPTION_MASTER_KEY in setup scripts and fix health check IPv6 bug
- setup.sh / setup.ps1 now generate and inject ENCRYPTION_MASTER_KEY on first
  install (was always blank, causing instrumentation.ts startup crash)
- Health check changed from localhost to 127.0.0.1 in both docker-compose.yml
  and self-host/docker-compose.yml — Alpine resolves localhost to ::1 (IPv6)
  but Next.js binds only to 0.0.0.0 (IPv4)
2026-05-23 16:38:48 +12:00
Silvertakana eba8ff4400 Merge branch 'main' into fix/gc-workflow-oidc-permission 2026-05-23 16:00:24 +12:00
Antigravity AI 78fb6c2304 fix(docker): auto-baseline P3005 when schema exists without migration history
Wraps prisma migrate deploy in the container entrypoint to detect P3005
(schema populated by pnpm dev / prisma db push before the Docker stack was
started). When detected, runs prisma migrate diff to confirm zero schema
drift, then marks each migration as applied via migrate resolve --applied
and retries deploy. Exits with a clear error if drift is found.

Also documents the auto-baseline behavior in database-migrations.md and
fixes duplicate section numbering in that file.
2026-05-23 15:56:53 +12:00
Antigravity AI fef8483094 fix: merge main into fix/gc-workflow-oidc-permission, resolve conflicts
Conflicts resolved:
- .github/workflows/garbage-collector.yml: kept show_full_output: true from this branch (PR #177 on main lacked it)
- package.json: bumped version to 2.17.7 (patch bump for fix: merge commit)
2026-05-23 15:13:05 +12:00
Antigravity AI dcc72e9410 fix(docker): guard community seeder cd and add ENCRYPTION_MASTER_KEY default
- Wrap `cd $SEEDERS_DIR/community` in an existence check so the
  data-engine container no longer crashes when local-seeders/community/
  is an empty or uncloned nested git repo. The container was entering
  Docker's exponential-backoff restart loop (2s→60s) on every boot.
- Add ENCRYPTION_MASTER_KEY to the wwv environment block with a
  local-dev fallback, matching the AUTH_SECRET pattern. Without it the
  Next.js instrumentation hook throws at startup and the app never
  serves a request.
2026-05-23 15:08:46 +12:00
Antigravity AI 9c0988a5e5 docs: mark cloud-auth-architecture.md as superseded by ADR-003 2026-05-23 14:31:16 +12:00
Antigravity AI 47cba3fb20 fix(gc): show agent output and explicit dry-run issue posting
- Add show_full_output: true so Claude responses appear in CI logs
- Replace vague dry-run instruction with explicit gh issue create/comment
  commands so output has a concrete destination (tracking issue)
- Bake DRY_RUN value into prompt at workflow-expansion time to eliminate
  ambiguity about env var reading
2026-05-23 01:46:06 +12:00
Antigravity AI fdd22387b6 fix: add id-token write permission and fix invalid inputs in GC workflow
The claude-code-action@v1 uses OIDC for OAuth token auth, which requires
id-token: write in workflow permissions. Without it ACTIONS_ID_TOKEN_REQUEST_URL
is not set and the action fails after 3 retry attempts.

Also moves model and allowed_tools from unsupported top-level inputs into
claude_args where they are valid CLI flags for claude-code-action@v1.
2026-05-23 01:27:02 +12:00
7 changed files with 90 additions and 22 deletions

No files matched your search

+14 -2
View File
@@ -13,10 +13,22 @@ When making database schema changes, you must ensure that generated migrations a
- **Add "IF EXISTS" clauses**: Prisma can sometimes produce brittle drop statements (`DROP INDEX "my_index"`). To prevent migrations from crashing if a state desynchronization occurs, manually edit the migration file to use `DROP INDEX IF EXISTS "my_index";` or `DROP TABLE IF EXISTS "table_name";`.
- **Data Preservation**: When dropping columns or renaming, carefully review the migration to ensure data is correctly mapped. In PostgreSQL, ensure that cascaded drops don't accidentally remove required data.
## 2. Managing Failed Migrations
## 2. P3005 Auto-Baseline (Handled in `docker-entrypoint.sh`)
`docker-entrypoint.sh` automatically recovers from Prisma **P3005** ("schema not empty, no migration history"). This happens when `pnpm dev` (which runs `prisma db push`) populates the database before the Docker stack is started.
The entrypoint only auto-baselines when **both** conditions hold:
1. The error is exactly P3005.
2. `prisma migrate diff` reports zero schema drift between the live DB and `prisma/schema.prisma`.
If drift is detected the container exits with a clear error message directing you to `pnpm db:reset`.
> **Never add manual `migrate resolve --applied` calls** unless you are outside the container and have independently verified the above two conditions. The entrypoint already handles the common case.
## 3. Managing Failed Migrations
If a migration fails in production:
- **Never blindly mark as resolved**: Do not run `prisma migrate resolve --applied <migration_name>` unless you have explicitly verified that the database schema precisely matches the expected state.
- If you use `resolve --applied`, Prisma will permanently skip that migration in the future, leaving your database structurally out of sync with your Prisma Client.
## 3. Backups Before DDL
## 4. Backups Before DDL
Never perform direct DDL operations (ALTER, DROP, CREATE) on a production database without first confirming an automated backup exists, or manually taking a `pg_dump` backup of the database.
+1 -1
View File
@@ -29,7 +29,7 @@ services:
db:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:3000/api/health || exit 1"]
test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://127.0.0.1:3000/api/health || exit 1"]
interval: 30s
timeout: 10s
retries: 3
+54 -2
View File
@@ -29,8 +29,60 @@ if [ -z "$DATABASE_URL" ]; then
fi
echo "[entrypoint] Running database migrations..."
prisma migrate deploy
echo "[entrypoint] Migrations complete."
set +e
MIGRATE_OUT=$(prisma migrate deploy 2>&1)
MIGRATE_CODE=$?
set -e
if [ $MIGRATE_CODE -eq 0 ]; then
echo "[entrypoint] Migrations complete."
elif echo "$MIGRATE_OUT" | grep -q "P3005"; then
# P3005: schema exists but _prisma_migrations has no history.
# Happens when 'prisma db push' (pnpm dev) ran before 'prisma migrate deploy' (docker).
# Safe to auto-baseline only if there is zero schema drift.
echo "[entrypoint] P3005: schema exists without migration history."
echo "[entrypoint] Verifying schema matches migrations before auto-baselining..."
set +e
DIFF_OUT=$(prisma migrate diff \
--from-url "$DATABASE_URL" \
--to-schema-datamodel prisma/schema.prisma \
--script 2>&1)
DIFF_CODE=$?
set -e
if [ $DIFF_CODE -ne 0 ]; then
echo "[entrypoint] Could not verify schema state — aborting." >&2
echo "$DIFF_OUT" >&2
exit 1
fi
# Positive-match for DDL keywords: any real drift emits at least one of these.
# Checking for presence is safer than checking for absence of content.
if echo "$DIFF_OUT" | grep -qiE "^(CREATE|ALTER|DROP|INSERT|UPDATE|DELETE|TRUNCATE)"; then
echo "[entrypoint] Schema drift detected — cannot auto-baseline." >&2
echo "[entrypoint] Run 'pnpm db:reset' to wipe and re-migrate, or resolve drift manually." >&2
echo "$MIGRATE_OUT" >&2
exit 1
fi
echo "[entrypoint] No drift detected. Baselining existing schema..."
for migration_dir in prisma/migrations/*/; do
if [ -f "${migration_dir}migration.sql" ]; then
migration_name=$(basename "$migration_dir")
echo "[entrypoint] Marking as applied: $migration_name"
set +e
prisma migrate resolve --applied "$migration_name"
RESOLVE_CODE=$?
set -e
if [ $RESOLVE_CODE -ne 0 ]; then
echo "[entrypoint] Failed to baseline $migration_name — aborting." >&2
exit 1
fi
fi
done
prisma migrate deploy
echo "[entrypoint] Migrations complete."
else
echo "$MIGRATE_OUT" >&2
exit $MIGRATE_CODE
fi
# Generate self-signed SSL certificates for local HTTPS bridging if they don't exist
if [ ! -f "./data/localhost.crt" ] || [ ! -f "./data/localhost.key" ]; then
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "worldwideview",
"version": "2.17.7",
"version": "2.17.8",
"private": true,
"type": "module",
"packageManager": "[email protected]",
+1 -1
View File
@@ -18,7 +18,7 @@ services:
db:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:3000/api/health || exit 1"]
test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://127.0.0.1:3000/api/health || exit 1"]
interval: 30s
timeout: 10s
retries: 3
+11 -6
View File
@@ -25,15 +25,20 @@ Invoke-WebRequest -Uri "https://raw.githubusercontent.com/silvertakana/worldwide
# Generate .env
if (-Not (Test-Path .env)) {
Write-Host "[*] Generating new .env file with AUTH_SECRET..."
$bytes = New-Object Byte[] 32
[System.Security.Cryptography.RandomNumberGenerator]::Create().GetBytes($bytes)
$secret = -join ($bytes | ForEach-Object { $_.ToString("x2") })
Write-Host "[*] Generating new .env file with secrets..."
$rng = [System.Security.Cryptography.RandomNumberGenerator]::Create()
$authBytes = New-Object Byte[] 32
$rng.GetBytes($authBytes)
$authSecret = -join ($authBytes | ForEach-Object { $_.ToString("x2") })
$encBytes = New-Object Byte[] 16
$rng.GetBytes($encBytes)
$encKey = -join ($encBytes | ForEach-Object { $_.ToString("x2") })
Write-Host "[*] Downloading .env template..."
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/silvertakana/worldwideview/main/.env.example" -OutFile .env
$envContent = Get-Content .env -Raw
$envContent = $envContent -replace "(?m)^AUTH_SECRET=.*", "AUTH_SECRET=$secret"
$envContent = $envContent -replace "(?m)^AUTH_SECRET=.*", "AUTH_SECRET=$authSecret"
$envContent = $envContent -replace "(?m)^ENCRYPTION_MASTER_KEY=.*", "ENCRYPTION_MASTER_KEY=$encKey"
$envContent | Out-File -FilePath .env -Encoding utf8
} else {
Write-Host "[Success] .env already exists, skipping generation."
+8 -9
View File
@@ -21,21 +21,20 @@ fi
echo "📦 Downloading docker-compose.yml..."
curl -fsSL -o docker-compose.yml https://raw.githubusercontent.com/silvertakana/worldwideview/main/self-host/docker-compose.yml
# 2. Generate .env with a persistent secret
# 2. Generate .env with persistent secrets
if [ ! -f .env ]; then
echo "🔐 Generating new .env file with AUTH_SECRET..."
# Use openssl if available, otherwise use urandom
echo "🔐 Generating new .env file with secrets..."
if command -v openssl &> /dev/null; then
SECRET=$(openssl rand -hex 32)
AUTH_SECRET=$(openssl rand -hex 32)
ENCRYPTION_MASTER_KEY=$(openssl rand -hex 16)
else
SECRET=$(head -c 32 /dev/urandom | xxd -p)
AUTH_SECRET=$(head -c 32 /dev/urandom | xxd -p)
ENCRYPTION_MASTER_KEY=$(head -c 16 /dev/urandom | xxd -p)
fi
echo "📥 Downloading .env template..."
curl -fsSL -o .env https://raw.githubusercontent.com/silvertakana/worldwideview/main/.env.example
# Replace AUTH_SECRET= with the generated secret
# (macOS sed requires an empty string backup extension, Linux does not. Perl is safer across platforms)
perl -pi -e "s/^AUTH_SECRET=.*$/AUTH_SECRET=$SECRET/" .env
perl -pi -e "s/^AUTH_SECRET=.*$/AUTH_SECRET=$AUTH_SECRET/" .env
perl -pi -e "s/^ENCRYPTION_MASTER_KEY=.*$/ENCRYPTION_MASTER_KEY=$ENCRYPTION_MASTER_KEY/" .env
else
echo "✅ .env already exists, skipping generation."
fi