Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5915563
Move schema releases to a protected migration job
Artexis10 Dec 1, 2026
2d62483
Lock Cloud identity rows against the web app's database role
Artexis10 Dec 1, 2026
d66e91c
Record every issued credential in a log the web app cannot write
Artexis10 Dec 1, 2026
e21b73b
Store a row for each download ticket and require it at the gateway
Artexis10 Dec 1, 2026
1da34cb
Prove the identity lock and the issuance log as the real database roles
Artexis10 Dec 2, 2026
2c3a057
Document the migration job, the identity lock and the issuance log
Artexis10 Dec 2, 2026
784f730
Format the issuance retention helper with prettier
Artexis10 Dec 2, 2026
08c18f1
Renumber the identity lock and issuance log migrations after main's 0100
Artexis10 Dec 2, 2026
845eaad
Guard ticket grants and cell identity, and fail the search-path pin o…
Artexis10 Dec 2, 2026
1ffc868
Drop the ticket grant guard, end service credential records, and run …
Artexis10 Dec 2, 2026
c846610
Scope the issuance claim and column-rights requirement, and settle th…
Artexis10 Dec 2, 2026
2b27bcc
Scope the lock and recording requirements, state retention bounds and…
Artexis10 Dec 2, 2026
9a48479
End token family records at revocation or deletion, and prune the iss…
Artexis10 Dec 2, 2026
2d04840
Revoke a tenant's service credentials when its cell is deleted, and s…
Artexis10 Dec 2, 2026
698da64
Revoke a deleted cell's service credentials in the database, and back…
Artexis10 Dec 2, 2026
41d2d33
Refuse a service credential for a tenant with no live cell, and lock …
Artexis10 Dec 2, 2026
49b416f
Answer a deadlock on a service credential request as a retryable 503
Artexis10 Dec 2, 2026
9d249a4
Anchor the audit read on a surviving record, and reopen the cost proof
Artexis10 Dec 2, 2026
e8a7c3d
Run the download suite as the web app's role and the gateway's role
Artexis10 Dec 2, 2026
16fd2f3
Tick task 5.8 with the commit that the cost proof measured
Artexis10 Dec 2, 2026
8eb2dc0
Close the way an earlier grants script restores wide rights
Artexis10 Dec 2, 2026
b4d6a20
Keep the rights check free of the grants script's column lists
Artexis10 Dec 2, 2026
a2e262d
Release the tip of main, page the runbook reads and end records at th…
Artexis10 Dec 2, 2026
99353c5
Count each runbook pass from the previous stop, and cap its look-back…
Artexis10 Dec 2, 2026
aa65dde
Close the recorder and range-read gaps of the issuance log
Artexis10 Dec 2, 2026
e07c87a
docs(openspec): record issuance suite CI evidence
Artexis10 Dec 2, 2026
4343dc1
fix(cloud): check issuance coverage across pruned records and late co…
Artexis10 Dec 2, 2026
d334125
fix(cloud): harden credential deletion and bound audit work
Artexis10 Dec 2, 2026
37f7098
docs: clarify download ticket expiry and cleanup
Artexis10 Dec 2, 2026
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
6 changes: 4 additions & 2 deletions .github/quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ classes:
- "content/*"
- "public/*"
- "ops/*" # the hosted scheduler's cron jobs
# Run by every production deploy (vercel-build) or by the gateway image build.
- "scripts/vercel-maybe-migrate.ts"
# Run by every production deploy (vercel-build), by the schema release job or by the gateway image build.
- "scripts/wait-for-schema-release.ts"
- "scripts/schema-release-plan.sh"
- "scripts/migrate.ts"
- "scripts/*.sql" # the database grants migrate.ts applies
- "scripts/verify-exomem-gateway-bundle.mjs"
Expand All @@ -54,6 +55,7 @@ classes:
- "scripts/strict-generation-visibility-cutover.ts"
- "scripts/generate-jwt-keypair.ts" # `--commit` inserts the public key into signing_keys
- ".github/workflows/publish-exomem-gateway.yml" # builds and publishes the gateway image
- ".github/workflows/migrate-database.yml" # applies the schema release to production
- "instrumentation.ts"
- "next.config.ts"
- "tailwind.config.ts"
Expand Down
75 changes: 75 additions & 0 deletions .github/workflows/migrate-database.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Applies the database migrations and the grants script for the tip of `main`,
# then records the tip's schema release. The production build waits for that
# row (scripts/wait-for-schema-release.ts) and runs no migration itself.
#
# Every run releases the tip of `main` as it stands when the run starts, whatever
# commit started it. The group below keeps one waiting run, so a restart of an
# old run can replace the waiting run of a newer push. That run then releases the
# newer tip and loses nothing. Only the step that applies reads the tip again, and
# it applies nothing when `main` moved during the install: the push that moved it
# started a run of its own. This rule needs a run for every push to `main`, so
# the `push` trigger has no path filter.
#
# This is the only workflow that names the protected environment, and it starts
# only on a push to `main` or by hand. The environment accepts only `main` and
# holds the schema-owner connection string.
name: migrate-database

on:
push:
branches: [main]
workflow_dispatch:
inputs:
dry_run:
description: List the pending migrations and change nothing
type: boolean
default: true

permissions:
contents: read

# One run applies at a time, and a running job is never cancelled: a cancelled
# migration would leave a half-applied step for the next run to find. A dry run
# changes nothing, so it takes a group of its own and never displaces a waiting
# run.
concurrency:
group: ${{ inputs.dry_run && format('schema-dry-run-{0}', github.run_id) || 'schema-release' }}
cancel-in-progress: false

jobs:
migrate:
runs-on: ubuntu-latest
timeout-minutes: 30
environment: production-schema
steps:
# The tip, not the commit that started the run.
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
ref: main
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 24
# No package install script runs in a job that holds the schema owner's credential.
- run: npm ci --ignore-scripts
# Reads git only. It runs after the install and just before the migration, so it
# sees the tip as late as it can.
- id: plan
run: scripts/schema-release-plan.sh >> "$GITHUB_OUTPUT"
# The only step that receives the secret.
- name: Migrate
env:
DATABASE_MIGRATION_URL: ${{ secrets.DATABASE_MIGRATION_URL }}
DRY_RUN: ${{ inputs.dry_run }}
APPLY: ${{ steps.plan.outputs.apply }}
TIP: ${{ steps.plan.outputs.tip }}
SUPERSEDED: ${{ steps.plan.outputs.superseded }}
run: |
if [ "$DRY_RUN" = "true" ]; then
node_modules/.bin/tsx scripts/migrate.ts --dry
elif [ "$APPLY" = "true" ]; then
node_modules/.bin/tsx scripts/migrate.ts --commit "$TIP" --superseded "$SUPERSEDED"
else
echo "::notice::main moved to $TIP while this job installed. The run for that push applies it."
fi
11 changes: 8 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,19 @@ jobs:
- id: install
run: npm ci
- run: npm test
# The PostgreSQL steps run one file at a time: the suites create the same login roles, and
# roles, their passwords and their grants belong to the cluster, so two files cannot share it.
- name: Exomem shared PostgreSQL authority (OAuth, capacity, billing, sessions, migrations)
env:
EXOMEM_TEST_DATABASE_URL: postgresql://postgres:postgres@127.0.0.1:5432/substrate_test
CONFIRM_ENDSTATE_CLOUD_RELEASE_A: "yes"
run: >-
node --import tsx --experimental-test-module-mocks --test
node --import tsx --experimental-test-module-mocks --test --test-concurrency=1
src/lib/exomem-hosted/__tests__/oauth-postgres.integration.test.ts
src/lib/exomem-hosted/__tests__/capacity-postgres.integration.test.ts
src/lib/exomem-hosted/__tests__/migration-upgrade.integration.test.ts
src/lib/exomem-hosted/__tests__/migration-runner.integration.test.ts
src/lib/exomem-hosted/__tests__/schema-release-postgres.integration.test.ts
src/lib/exomem-hosted/__tests__/postgres.integration.test.ts
src/lib/exomem-hosted/__tests__/alert-receiver-postgres.integration.test.ts
src/lib/exomem-hosted/__tests__/access-recovery.test.ts
Expand All @@ -55,17 +58,19 @@ jobs:
EXOMEM_TEST_DATABASE_URL: postgresql://postgres:postgres@127.0.0.1:5432/substrate_test
CONFIRM_ENDSTATE_CLOUD_RELEASE_A: "yes"
run: >-
node --import tsx --experimental-test-module-mocks --test
node --import tsx --experimental-test-module-mocks --test --test-concurrency=1
src/lib/hosted-backup/__tests__/version-commit-postgres.integration.test.ts
src/lib/db/__tests__/pg-sql-driver.integration.test.ts
- name: Exomem Cloud control plane PostgreSQL authority (schema, grants, admission, OAuth, Home channel, exports, lifecycle, deletion, release)
env:
EXOMEM_TEST_DATABASE_URL: postgresql://postgres:postgres@127.0.0.1:5432/substrate_test
CONFIRM_ENDSTATE_CLOUD_RELEASE_A: "yes"
run: >-
node --import tsx --experimental-test-module-mocks --test
node --import tsx --experimental-test-module-mocks --test --test-concurrency=1
src/lib/exomem-hosted/__tests__/cloud-cells-postgres.integration.test.ts
src/lib/exomem-hosted/__tests__/cloud-grants-postgres.integration.test.ts
src/lib/exomem-hosted/__tests__/cloud-identity-lock-postgres.integration.test.ts
src/lib/exomem-hosted/__tests__/cloud-issuance-log-postgres.integration.test.ts
src/lib/exomem-hosted/__tests__/cloud-access-log-postgres.integration.test.ts
src/lib/exomem-hosted/__tests__/cloud-imports-postgres.integration.test.ts
src/lib/exomem-hosted/__tests__/cloud-home-postgres.integration.test.ts
Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,17 @@ For a new blog post, do nothing extra — drop a `.md` file in `content/blog/` w

The substrate also serves as the auth issuer + metadata store + presigned-URL minter for **Endstate Hosted Backup v2**. Protocol locked in [`hosted-backup-contract.md`](./hosted-backup-contract.md) (OIDC discovery, EdDSA JWTs, Argon2id-derived `serverPassword + masterKey` split, R2 storage with 5-version retention).

**Migrations.**
**Local migrations.** Set `LOCAL_DATABASE_URL` to a disposable database before running these commands.

```bash
npm run migrate # apply pending migrations from migrations/*.sql
npm run migrate:dry # list pending migrations without applying
env -u DATABASE_MIGRATION_URL DATABASE_URL="${LOCAL_DATABASE_URL:?}" npm run migrate:dry
env -u DATABASE_MIGRATION_URL DATABASE_URL="${LOCAL_DATABASE_URL:?}" npm run migrate
```

The runner auto-creates a `schema_migrations` tracking table on first invocation.
The runner prefers `DATABASE_MIGRATION_URL` when both variables are set. The local commands clear it for each invocation. Applying migrations creates the tracking table if needed. The dry run only lists pending migrations.

In production, a protected GitHub job (`.github/workflows/migrate-database.yml`) applies the migrations and the grants script for each commit that lands on `main`.
It then records the commit's schema release. The production build reads its schema release and never migrates. [`docs/runbooks/production-keys-and-storage.md`](./docs/runbooks/production-keys-and-storage.md) describes the job and the manual run.

**JWT signing key.** Generate the active EdDSA keypair (and optionally insert the public-key row into `signing_keys`):

Expand Down
Loading
Loading