@wtfalch/foundry 0.35.1 → 0.35.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3210,14 +3210,13 @@ const PLATFORM_ARCHON_PROJECT = 'platform';
3210
3210
  const PLATFORM_ARCHON_APP_NAME = 'platform-archon';
3211
3211
  const PLATFORM_ARCHON_DB_NAME = 'platform-archon-db';
3212
3212
  /**
3213
- * The database Archon runs on. Live platform-archon moved to `archon_v2` on
3214
- * the same server (2026-10-02, the move onto `@wtfalch/db`), while its Coolify
3215
- * resource still names `archon` as its first database. So both URLs built
3216
- * here set this database themselves, never `internal_db_url`'s path.
3217
- * Archon's own migrations grant to `current_database() || '_rt'`, so
3218
- * {@link ARCHON_RUNTIME_ROLE} follows.
3219
- */
3220
- const ARCHON_POSTGRES_DB = 'archon_v2';
3213
+ * The database Archon runs on, and its owner. A platform made from zero
3214
+ * (2026-10-12) creates `platform-archon-db` with this as its first database,
3215
+ * so both URLs built here set it themselves and never read
3216
+ * `internal_db_url`'s path. Archon's own migrations grant to
3217
+ * `current_database() || '_rt'`, so {@link ARCHON_RUNTIME_ROLE} follows.
3218
+ */
3219
+ const ARCHON_POSTGRES_DB = 'archon';
3221
3220
  const ARCHON_RUNTIME_ROLE = `${ARCHON_POSTGRES_DB}_rt`;
3222
3221
  /** Fixed so the tunnel addresses the container directly (see `provisionPlatformAuth`). */
3223
3222
  const PLATFORM_ARCHON_INTERNAL_NAME = 'platform-archon';
@@ -3691,6 +3690,7 @@ async function provisionPlatformArchon(context, deps, ownerCompany = null) {
3691
3690
  const ownerUrl = archonDatabaseUrl(db.internal_db_url);
3692
3691
  if (liveOwnerUrl) {
3693
3692
  assertSameDatabaseHost('DATABASE_URL_OWNER', liveOwnerUrl, db.internal_db_url);
3693
+ assertArchonDatabasePath('DATABASE_URL_OWNER', liveOwnerUrl);
3694
3694
  }
3695
3695
  else {
3696
3696
  envs.push({ key: 'DATABASE_URL_OWNER', value: ownerUrl });
@@ -5070,12 +5070,30 @@ function assertSameDatabaseHost(key, liveUrl, dbInternalUrl) {
5070
5070
  throw new Error(`platform:archon: ${key} on the app points at host ${liveHost ?? '(unparseable)'}, but the adopted database ${PLATFORM_ARCHON_DB_NAME} is at host ${dbHost ?? '(unparseable)'}; refusing to leave the app's database URLs on different databases`);
5071
5071
  }
5072
5072
  }
5073
+ /**
5074
+ * Throws when `liveUrl`, kept as it is on the app, names another database than
5075
+ * {@link ARCHON_POSTGRES_DB}: a hand-set URL on the wrong path, or a platform
5076
+ * still on the retired `archon_v2`. Names the two databases only, never the URL.
5077
+ */
5078
+ function assertArchonDatabasePath(key, liveUrl) {
5079
+ let database;
5080
+ try {
5081
+ database = decodeURIComponent(new URL(liveUrl).pathname.slice(1));
5082
+ }
5083
+ catch {
5084
+ database = null;
5085
+ }
5086
+ if (database !== ARCHON_POSTGRES_DB) {
5087
+ throw new Error(`platform:archon: ${key} on the app names database ${database ?? '(unparseable)'}, but Archon runs on database ${ARCHON_POSTGRES_DB}; refusing to keep it. Point ${key} at ${ARCHON_POSTGRES_DB} in Coolify and apply again`);
5088
+ }
5089
+ }
5073
5090
  async function ensureArchonRuntimeUrl(coolify, appId, dbInternalUrl) {
5074
5091
  const envs = await coolify.listEnvs(appId);
5075
5092
  const live = envs.find((e) => e.key === 'DATABASE_URL' && !e.is_preview);
5076
5093
  if (live) {
5077
5094
  // #265: kept as it is, but it must name the adopted database's host.
5078
5095
  assertSameDatabaseHost('DATABASE_URL', live.value, dbInternalUrl);
5096
+ assertArchonDatabasePath('DATABASE_URL', live.value);
5079
5097
  return null;
5080
5098
  }
5081
5099
  let host;
@@ -8130,9 +8148,10 @@ const PLATFORM_BACKUP_S3_STORAGE_PENDING_SCOPE_KEY = 'coolify_platform_backup_s3
8130
8148
  const PLATFORM_BACKUP_DEFAULT_FREQUENCY = 'daily';
8131
8149
  /**
8132
8150
  * The database a service's schedule must name. A schedule that names none
8133
- * dumps the Coolify resource's first database, which for live Archon is the
8134
- * abandoned `archon`, not the one it runs on (see {@link ARCHON_POSTGRES_DB}).
8135
- * Every other service runs on its resource's first database and needs no entry.
8151
+ * dumps the Coolify resource's first database; Archon's is named here anyway,
8152
+ * so a resource whose first database is not {@link ARCHON_POSTGRES_DB} is still
8153
+ * dumped right. Every other service runs on its resource's first database and
8154
+ * needs no entry.
8136
8155
  */
8137
8156
  const PLATFORM_BACKUP_DATABASE_NAMES = {
8138
8157
  archon: ARCHON_POSTGRES_DB,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wtfalch/foundry",
3
- "version": "0.35.1",
3
+ "version": "0.35.2",
4
4
  "description": "Foundry's SDK: the declared org's types, the plan and apply contracts, and the state store's interface.",
5
5
  "repository": {
6
6
  "type": "git",