Skip to content

feat(backup): back up the database before migrating it - #3402

Merged
Quick104 merged 4 commits into
mainfrom
feat/backups-6-before-upgrade
Nov 5, 2026
Merged

Quick104 merged 4 commits into
mainfrom
feat/backups-6-before-upgrade

Conversation

@Quick104

@Quick104 Quick104 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Closes #2313
Validation tasks: changes #1224 C2; changes #1225 C2 (both passed on a server upgraded from an older build, and this changes the startup path that upgrade goes through)

When an upgrade's migrations fail or turn out wrong, the documented recovery
is to restore a backup taken before the upgrade. Admins have to remember to
take one, and often don't. This makes Silo back up the database itself before
it applies pending migrations, and stop instead of migrating if that backup
fails.

Stacked on #3401. This is the last of the six pull requests for #2313.

Approach

  • Startup sequence: one wrapper advisory lock, held on its own connection,
    covers the whole sequence: the legacy schema_versions bootstrap, the
    pending check with the same goose provider that runs Up, then (when
    migrations are pending) the backup lock, a database-only backup, and Up.
    Other API servers wait on the wrapper and then find nothing pending. Losing
    either lock cancels the dump or the migration.
  • Upgrade outcomes: the migrations themselves are unchanged and still run
    through the same goose provider's Up, so upgrade-time data migrations such
    as 20261010162953_disable_unused_approved_community_catalog (the community
    plugin catalog stays off until an admin opts in) apply as before. The backup
    that runs first only reads the database.
  • Old schemas: the backup reads only settings that exist in the old
    schema, with defaults, and writes db.dump plus its manifest. It writes no
    restore set or files, because the new binary's tables don't exist yet.
    Its manifest is signed with SECRET_KEY like every backup's, so restoring
    it doesn't need --accept-lost-credentials. It takes the backup lock
    directly, so the nightly slot never skips it and it never changes the slot.
    It writes no restore journal.
  • Retries: a start after failed migrations reuses the earlier
    before-upgrade backup when it is this server's newest, verified, under
    6 hours old, and records the same pending migrations over the same
    applied ones (upgrade.pending in its manifest). A restart loop therefore
    takes one backup, not one per start. Rotation keeps the two newest
    before-upgrade copies, and never deletes one whose upgrade hasn't applied
    all its migrations yet.
  • Restoring one: restoring a before-upgrade backup of an older schema
    works. The steps after the load skip, and print, any step that needs a
    table or column that schema lacks, except the credential and plugin
    steps: those fall back to leaving out the backup's credentials and
    turning off its plugins, and fail the restore if they can't.
  • Fails closed: if the backup fails, startup stops with the reason.
    SILO_SKIP_BACKUP_BEFORE_MIGRATE=true skips it for one start. It is
    skipped, with a log line, on a new install, when backups are off, on the
    SQLite user store, when there is nowhere to write, and when a bucket's key
    isn't confirmed.
  • Waiting: SILO_MIGRATION_WAIT (default 60 minutes) bounds how long a
    server waits for the migration lock. The docs give startup probe sizing for
    Kubernetes.

Validation

  • Go: gofmt, build, go vet, and changed-line golangci-lint against the previous pull request: pass.
  • Contract and repository checks: verify-apiv2-openapi, -web-types, -fixtures, -contract (additive only), verify-migrations, verify-migration-ledger, verify-size-ratchet, verify-local-paths, verify-settings-bindings: pass.
  • Web: tsc -b, eslint and prettier on changed files, and vitest: pass.
  • verify-route-inventory was not run (it needs Linux with cgo); this pull request adds no legacy routes.
  • Database tests against PostgreSQL 18: this pull request's contract tests pass (56 for the stack), covering the bootstrap before the pending check, lock order, waiting behind a nightly backup, failing closed and an old schema.
  • On a development server, an upgrade with a pending migration took a database backup first (about 8 minutes, 15 GB) and then migrated.
  • On an isolated server upgraded from a main build (bundled PostgreSQL, backups in its private S3 bucket): the first start skipped the backup and logged why (the SECRET_KEY was not yet confirmed), then migrated. After the key was confirmed on the Backups page, a start with one pending migration (one rolled back with --migrate-down-to) took a database-only backup and then migrated; a plain restart took none; and a retry of the same upgrade kept the earlier backup instead of taking another.

Evidence

The Backups page lists a backup taken before an upgrade as "Taken before an upgrade", and its download dialog says it holds the database only. A restore-set request for such a backup answers 409 with a detail that now names backups taken before an upgrade. Startup logs say whether the backup was taken or skipped and why.

Evidence: https://evidence.siloserver.org/r/silo-server/pr-3402/

Risks

  • Startup time: an upgrade with pending migrations now waits for a
    database backup. On shared development that took 8 minutes for about 15 GB.
  • Development machines: without pg_dump 18, Silo refuses to start when
    a migration is pending. DEVELOPMENT.md and .env.example give the
    override.
  • Settings read errors: a failure to read the backup settings before
    migrating now stops startup, with the override named.
  • Timeouts: SILO_MIGRATE_TIMEOUT now covers only goose Up and the
    index step.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • Each test this pull request adds meets "Decide what to test" in CONTRIBUTING.md.
  • The Evidence section shows every change a user can see, or says there is none.

AI Disclosure

  • Harness: T3 Code with Claude Code
  • Tool(s): Claude Code with subagents; OpenAI Codex CLI for independent review
  • Model(s): claude-opus-5-5; gpt-6.1-sol (review)
  • Involvement: Fully AI-generated. The maintainer tested the backups work it came from on a development server; the diff awaits human review.
  • Adversarial review: gpt-6.1-sol reviewed the backups work read-only in repeated rounds; every finding was fixed or answered before this branch was cut.

🤖 Generated with Claude Code

Note

Add automatic database-only backup before startup migrations

  • Server startup (migrate-only and primary node) now runs migrations through database.MigrateAtStartup with a pre-migration callback that takes a database-only backup and holds the backup lock through migrations (backup_wiring.go, migrate_startup.go)
  • Adds a before-upgrade backup kind that skips blobs and restore sets, records pending migrations in the manifest, and restores in database-only mode with storage files left in place (upgrade.go, restore.go)
  • Backup failures stop startup before migrations run; skips are honored for the SILO_SKIP_BACKUP_BEFORE_MIGRATE override, disabled backups, SQLite user store, missing destinations, and unconfirmed encryption keys
  • Rotation keeps the two newest before-upgrade backups outside the regular keep count, and protects them while their recorded migrations remain unfinished
  • Restores from older-schema backups tolerate missing tables and columns: post-load steps are skipped or fall back (e.g. restored plugins get disabled), and absent credential tables are reported rather than failing
  • Risk: restore and rotation paths changed broadly — check postLoad.strictStep fallbacks in restore.go, planRotation retention in rotation.go, and the DatabaseLoader.DisablePlugins interface addition, which requires implementation by all loaders

Macroscope summarized ec48f91.

@silo-triage silo-triage Bot added the size/XXL 1000–2999 added + deleted lines (all files); change volume, not priority. label Nov 2, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-05T16:28:24.975079Z ec48f91 New commits
🔒 Security Review ✅ Completed 2026-11-05T16:32:58.292684Z ec48f91 New commits

Security findings

Advisory findings (1)

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

Startup migration paths now coordinate through database locks and can create a database-only backup before applying pending migrations to an existing schema. The before-upgrade kind is supported by backup, restore, API, and administration paths.

Changes: Pre-migration backup and startup migration

Layer / File(s) Summary
Database-only backup behavior
internal/backup/layout.go, internal/backup/manifest.go, internal/backup/service.go, internal/backup/blobs.go, internal/backup/settings.go, internal/backup/snapshot.go, internal/backup/rotation.go, internal/backup/source_private.go, internal/backup/*_test.go, internal/backup/doc.go, docs/architecture/backups.md
The before-upgrade kind produces a manifest and db.dump without blob objects or a restore set. Backup processing skips blob enumeration, status publication, and upload sweeping for this kind. Rotation retains the two newest before-upgrade backups.
Startup migration and backup coordination
internal/database/migrate.go, internal/database/migrate_startup.go, internal/database/migration_command.go, internal/backup/upgrade.go, cmd/silo/backup_wiring.go, cmd/silo/main.go, internal/database/migrate_startup_test.go, internal/backup/upgrade_postgres_test.go, cmd/silo/backup_wiring_test.go, scripts/ci/db-contracts.txt, .env.example, DEVELOPMENT.md, docs/architecture/backups.md, docs/release-versioning.md, docs/update-to-1.0.md
Startup migration paths use MigrateAtStartup. For an existing schema with pending migrations, the configured callback runs a before-upgrade backup and holds its guard through migration execution. The code handles lock waits, backup skips and failures, and lock-session loss.
Restore and administration surfaces
internal/backup/restore.go, internal/backup/swap.go, internal/backup/restoreset_read.go, internal/apiv2/admin_backups.go, contracts/api/v2/openapi.json, contracts/api/v2/breaking-approvals.json, web/src/api/v2/schema.ts, web/src/pages/admin-backups/*, docs/backups-api.md, docs/architecture/backups.md
Restore and verification paths check only objects present for database-only backups and do not write blob files when the manifest has no blobs. API schemas and the administration page recognize before-upgrade and describe its database-only contents.

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Startup as Silo startup
  participant Migration as MigrateAtStartup
  participant Backup as BeforeUpgrade
  participant Database as PostgreSQL
  Startup->>Migration: Run startup migrations
  Migration->>Database: Acquire wrapper lock and check pending migrations
  Migration->>Backup: Back up existing schema before migration
  Backup->>Database: Acquire subsystem lock and dump database
  Backup-->>Migration: Return held guard
  Migration->>Database: Apply migrations while guard is held
  Migration-->>Startup: Return migration result
Loading

Suggested labels: go, javascript, api-v2, needs-review, impact: data-loss, impact: usability, evidence-required

Suggested reviewers: rhainland, blurbery

Merge Risk: Moderate · up to 92f09

Upgrade recovery and backup-retention limitations remain material and should be resolved or explicitly accepted before merging.

Security architecture risk: Low · up to 92f09

The design improves upgrade recovery while preserving backup authentication and restricting access to database copies. No introduced security vulnerability was established in the reviewed paths. Recovery remains conditional on backup configuration and available storage, and deployment-specific behavior has not been fully validated.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The additional recovery copy is installation-database-wide rather than tenant-scoped and can contain password hashes and settings. Its confidentiality therefore depends on the configured destination, local account isolation, and archive-key protection rather than on application-level access to individual records.

Trust Boundaries and Controls

  • observed — The new automatic path supplies normal SECRET_KEY-derived manifest authentication and archive keys. Database-only manifests have an explicit constrained shape, and retention distinguishes authenticated copies from unverified destination content before deleting recovery points.

Resilience and Maintainability Implications

  • observed — Lock ownership is tied to database sessions. Wrapper or backup-guard loss cancels in-flight work, failure releases the acquired backup guard, and normal cleanup releases the guard before the wrapper. Source tests cover concurrent startup and lock loss during backup or migration; these tests were inspected but not executed in this review.
Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed

Check name Status Explanation
Title check Passed The title "feat(backup): back up the database before migrating it" states the main change: the server now takes a database backup before applying pending startup migrations. The changeset adds the bef…
Linked Issues check Passed Directly linked open issue #2313 requires a backup before pending migrations at startup and with --migrate-only. This PR's stated scope is that requirement. Evidence at the reviewed head: (1) internal…
Out of Scope Changes check Passed The changed areas support the before-upgrade backup objective of #2313. Startup sequencing changes (internal/database/migrate_startup.go, migrate.go, migration_command.go, cmd/silo/main.go, cmd/silo/b…
Description check Passed The PR description is specific and on-topic. It explains the problem (no backup before startup migrations), the approach (a wrapper advisory lock, a database-only before-upgrade backup, and fail-close…
Full details: Title check

Explanation

The title "feat(backup): back up the database before migrating it" states the main change: the server now takes a database backup before applying pending startup migrations. The changeset adds the before-upgrade backup kind, the BeforeUpgrade hook, the startup migration runner, and the wiring in main.go, so the title matches the primary change.

Full details: Linked Issues check

Explanation

Directly linked open issue #2313 requires a backup before pending migrations at startup and with --migrate-only. This PR's stated scope is that requirement. Evidence at the reviewed head: (1) internal/database/migrate_startup.go, MigrateAtStartup and migrateAtStartup, takes a wrapper advisory lock on its own connection, runs the legacy bootstrap, checks for pending migrations, and, when migrations are pending on an existing schema, calls opts.BeforeMigrate before goose Up. A new database (current == 0) skips the backup. (2) internal/backup/upgrade.go, Service.BeforeUpgrade, takes the subsystem lock, runs a KindBeforeUpgrade backup, and returns an error that stops startup when the backup fails. It skips only for SILO_SKIP_BACKUP_BEFORE_MIGRATE, disabled backups, the SQLite user store, no destination, or an unconfirmed S3 key, and logs each skip. (3) The PR summary states that cmd/silo/main.go uses the same flow for --migrate-only and primary startup. I did not inspect main.go directly. Automated database tests cover ordering, lock behavior, fail-closed behavior, and the old-schema backup (internal/backup/upgrade_postgres_test.go, internal/database/migrate_startup_test.go, cmd/silo/backup_wiring_test.go); the PR reports these pass on PostgreSQL 18. Other items in #2313 (scheduled backup, restore CLI safeguards, and the admin UI) are not this PR's stated scope. The restore command already exists at head as silo backup restore (cmd/silo/backup_command.go), so it is not a requirement of this PR. The issue's proposed flag name silo --restore <dump> differs from that existing form; this PR does not change that naming.

Full details: Out of Scope Changes check

Explanation

The changed areas support the before-upgrade backup objective of #2313. Startup sequencing changes (internal/database/migrate_startup.go, migrate.go, migration_command.go, cmd/silo/main.go, cmd/silo/backup_wiring.go) implement the wrapper lock, the pre-migration hook, and the audit-index helper now used by both startup and --migrate-only. The backup changes (internal/backup/upgrade.go, service.go, layout.go, lock.go, blobs.go, settings.go, snapshot.go, rotation.go, manifest.go, restore.go, swap.go, source_private.go) add a database-only backup kind and make the restore, verify, and rotation paths accept a manifest without blobs. Contract, API, web, and documentation changes expose the new kind and describe its behavior. Their tests cover the new behavior. No change was found that is unrelated to backup-before-migrate. Some files were reviewed from the PR summary and not as full diffs, so this conclusion rests on that summary for those files.

Full details: Description check

Explanation

The PR description is specific and on-topic. It explains the problem (no backup before startup migrations), the approach (a wrapper advisory lock, a database-only before-upgrade backup, and fail-closed behavior), the skip conditions and the SILO_MIGRATION_WAIT setting. It also lists validation steps, risks and evidence. This matches the changeset described in the raw summary, which covers backup_wiring.go, migrate_startup.go, the backup package, the API schema, the web UI and the docs.

Full details: Docstring Coverage

Explanation

Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 44 functions across 30 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9e62fd0d-dae8-485e-ab6b-c36bc0df1f1a
Commits

Reviewing files that changed from the base of the PR and between f44c30a and 92f0977.

Files selected for processing: 1

  • scripts/ci/db-contracts.txt

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

@macroscopeapp

macroscopeapp Bot commented Nov 2, 2026

Copy link
Copy Markdown

Evidence is missing for these visible changes:

  • internal/apiv2/admin_backups.go and web/src/pages/admin-backups/backupPresentation.ts: before-upgrade backups can now appear in the admin backup list with the label “Taken before an upgrade.” This needs before-and-after captures of the Backups page at desktop and phone widths.
  • web/src/pages/admin-backups/BackupTable.tsx: the download dialog now explains that these backups contain only the database and leave stored files untouched. This needs before-and-after captures of the dialog at desktop and phone widths.

The Evidence section says there is no user-visible change, but does not explain why captures are unavailable. Suggested fix: add the captures under Evidence and identify the surface and build or commit for each.

Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness.

Posted via Macroscope — Visible change evidence

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6323efd1f8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/architecture/backups.md Resolved
@silo-triage silo-triage Bot added enhancement New feature or request priority: P2 Limited scope, workaround exists, or polish stacked Base is another open PR; merge in stack order named in the body labels Nov 2, 2026
@macroscopeapp

macroscopeapp Bot commented Nov 2, 2026

Copy link
Copy Markdown

Two accepted upgrade cases need re-validation after merge. Both explicitly exercised upgrades from older builds, and this PR replaces the startup migration path they exercised with database.MigrateAtStartup (wrapper lock, pre-migration backup/guard, then Goose Up). That same Up applies the plugin-catalog migrations used to preserve or disable the community-catalog preference. The PR should explain why the new upgrade path preserves these validated outcomes; re-run both cases after merge.

  • silo-server#1224 C2 (Server), build 1669 · 5ec82048
  • silo-server#1225 C2 (Web admin), build 1669 · 5ec82048

Suggested fix (no diff): replace the PR body line with Validation tasks: changes #1224 C2; changes #1225 C2.

Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed.

Posted via Macroscope — v1 validation impact

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0252d7ea-52a8-4a34-b43a-5dfba6b5eff0
Commits

Reviewing files that changed from the base of the PR and between 9cce3de and dbd79f8.

Files selected for processing: 39
  • .env.example
  • DEVELOPMENT.md
  • cmd/silo/backup_wiring.go
  • cmd/silo/backup_wiring_test.go
  • cmd/silo/main.go
  • contracts/api/v2/breaking-approvals.json
  • contracts/api/v2/openapi.json
  • docs/architecture/backups.md
  • docs/backups-api.md
  • docs/release-versioning.md
  • docs/update-to-1.0.md
  • internal/apiv2/admin_backups.go
  • internal/backup/blobs.go
  • internal/backup/doc.go
  • internal/backup/layout.go
  • internal/backup/lock.go
  • internal/backup/manifest.go
  • internal/backup/manifest_test.go
  • internal/backup/restore.go
  • internal/backup/restoreset_read.go
  • internal/backup/rotation.go
  • internal/backup/rotation_test.go
  • internal/backup/s3destination_test.go
  • internal/backup/selective_apply_test.go
  • internal/backup/service.go
  • internal/backup/settings.go
  • internal/backup/snapshot.go
  • internal/backup/swap.go
  • internal/backup/upgrade.go
  • internal/backup/upgrade_postgres_test.go
  • internal/database/migrate.go
  • internal/database/migrate_startup.go
  • internal/database/migrate_startup_test.go
  • internal/database/migration_command.go
  • scripts/ci/db-contracts.txt
  • web/src/api/v2/schema.ts
  • web/src/pages/admin-backups/BackupTable.tsx
  • web/src/pages/admin-backups/backupPresentation.test.ts
  • web/src/pages/admin-backups/backupPresentation.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

Comment thread docs/backups-api.md Resolved
@macroscopeapp

macroscopeapp Bot commented Nov 2, 2026

Copy link
Copy Markdown

One additional visible change lacks evidence: internal/apiv2/admin_backups.go changes the 409 detail for a missing restore set to mention backups taken before an upgrade, which API clients may display. The Evidence section has no before-and-after API response excerpts for this changed detail.

Suggested fix: include the 409 response for the same restore-set-preview request from builds before and after this change, identifying both builds or commits, or explain why the response could not be captured.

Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness.

Posted via Macroscope — Visible change evidence

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

2 similar comments
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up Comments

Outside diff Size each backup from a comparable completed backup.

487-487: 🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

Size each backup from a comparable completed backup.

When the newest verified backup is a database-only before-upgrade backup, prepareTarget uses its dump-sized manifest and largest object for the next full nightly or manual backup. The local preflight can then reserve only 1.5 times the dump plus 1 GiB while the full backup streams a much larger blobs.tar into the database's filesystem. This can exhaust the disk. S3 sizing only provides headroom for an object up to twice the selected baseline, so a larger blobs.tar can exceed the 10,000-part limit and fail.

Use a comparable full backup as the baseline for full runs. Use a dump-sized baseline for database-only runs.

Open the source location

Comment thread docs/architecture/backups.md Resolved
Comment thread docs/architecture/backups.md Resolved
Comment thread docs/architecture/backups.md Resolved
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai coderabbitai Bot added api-v2 API v2 / Huma migration program (epic #135); long-running, stacked by phase evidence-required Needs before-and-after evidence before the Evidence check passes go Pull requests that update go code impact: data-loss User data deleted, corrupted, or unrecoverable impact: usability Core flow broken or severely blocked javascript Pull requests that update javascript code needs-review Needs maintainer review to resolve uncertain classification, scope, or changed evidence. labels Nov 4, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: acf1f8c9-726d-4095-82f6-c0d9841517bf
Commits

Reviewing files that changed from the base of the PR and between 6ff8cbf and f44c30a.

Files selected for processing: 6
  • cmd/silo/main.go
  • docs/architecture/backups.md
  • internal/backup/blobs.go
  • internal/backup/snapshot.go
  • scripts/ci/db-contracts.txt
  • web/src/api/v2/schema.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

Comment thread docs/architecture/backups.md Resolved
Comment thread docs/architecture/backups.md Resolved
@Quick104
Quick104 force-pushed the feat/backups-6-before-upgrade branch from f44c30a to 92f0977 Compare November 4, 2026 17:10
Base automatically changed from feat/backups-5-s3 to main November 5, 2026 16:22
@silo-triage silo-triage Bot added size/XXXL 3000+ added + deleted lines (all files); change volume, not priority. and removed size/XXL 1000–2999 added + deleted lines (all files); change volume, not priority. labels Nov 5, 2026
Quick104 and others added 4 commits November 5, 2026 11:22
Startup now takes a database-only `before-upgrade` backup before it runs
pending migrations, under one wrapper lock across API servers and the
backup lock through goose Up. It fails closed, skips only for listed
reasons (a new install, backups off, the SQLite user store, nowhere to
write, an unconfirmed bucket key, or SILO_SKIP_BACKUP_BEFORE_MIGRATE),
waits behind a running backup up to SILO_MIGRATION_WAIT, and keeps the two
newest such backups.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A before-upgrade backup holds the previous release's schema, but the steps
after the load ran the binary's queries and stopped on the first table,
column, or type that schema lacks. When the backup's applied migrations are
fewer than the binary's, such a step is now skipped with a printed line;
each step is one transaction or statement, so a skipped one changed
nothing. The credential carry skips only the tables the schema lacks and
writes only the columns it has, so the backup's credentials do not survive
the restore. The old-schema test now restores that backup into a separate
database and in place of the live one.

The docs also say that a database-only backup cannot bring back a file
changed or deleted after it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A start after failed migrations backed up the database those migrations
left, and rotation kept only the two newest before-upgrade copies, so a
couple of retries could rotate away the copy from before the upgrade.

The manifest now records the migrations pending when a before-upgrade
backup was taken. A retry keeps the earlier backup when it is the newest,
complete and verified, under 6 hours old, and records the same pending
migrations over the same applied ones; otherwise it takes another.
Rotation never deletes a before-upgrade copy whose pending migrations are
not all applied.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
When restoring a backup of an older schema, the steps that replace the
backup's credentials and carry the plugin releases could fail on a missing
column and be skipped, leaving revoked keys working and the backup's
plugins enabled. They now fall back to the stricter outcome: leave out all
of the backup's credentials, or turn off every restored plugin, and fail
the restore if that cannot run either.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Quick104
Quick104 force-pushed the feat/backups-6-before-upgrade branch from d3d093d to ec48f91 Compare November 5, 2026 16:24
@silo-triage silo-triage Bot added size/XXL 1000–2999 added + deleted lines (all files); change volume, not priority. and removed size/XXXL 3000+ added + deleted lines (all files); change volume, not priority. labels Nov 5, 2026
@silo-kody

silo-kody Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@Quick104
Quick104 merged commit cb4f45d into main Nov 5, 2026
16 of 17 checks passed
@Quick104
Quick104 deleted the feat/backups-6-before-upgrade branch November 5, 2026 16:25
Comment thread cmd/silo/backup_wiring.go
Comment on lines +69 to +73
opts, err := upgradeBackupOptions(ctx, pool, bc, cipher)
if err != nil {
if !skip {
return nil, fmt.Errorf("preparing the backup before database migrations, so the migrations did not run: %w. "+
"Fix the cause and start again, or set %s=true to start once without it", err, backup.SkipBeforeUpgradeEnv)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kody code-review Bug medium

Backup skip conditions are evaluated after storage initialization

An invalid or inaccessible storage configuration can block migrations even when no backup should be taken. Check the skip settings before calling storesFromConfig, and acquire only the migration guard when backups are disabled or unsupported.

Prompt for LLM
File cmd/silo/backup_wiring.go, lines 69-73:

Backup skip conditions are evaluated after storage initialization

Disabled backups and SQLite user stores still require `storesFromConfig` to succeed before the skip decision runs, so an invalid or inaccessible storage configuration blocks migrations even though no backup should be taken. Read the skip settings before opening backup storage, and acquire only the migration guard when the backup is disabled or unsupported.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ec48f91c7d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +367 to +368
if err := p.strictStep("replacing the backup's credentials", carryCredentials(ctx, loader, dbURL, liveURL, p.out),
"leaving out all of the backup's "+carriedKinds, func() error { return carryCredentials(ctx, loader, dbURL, "", p.out) }); err != nil {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve stricter access flags when falling back to credential removal

When swap-restoring an older-schema backup on the same deployment with an account-owned live credential, the credential transaction can fail when carriedOwners reads newer user columns such as is_owner. That rolls back keepStricterFlags too. Retrying with an empty live URL clears credentials but bypasses keepStricterFlags, so accounts disabled since the backup return enabled, and libraries or profile restrictions can likewise lose their live protections. Clearing API keys does not prevent those accounts from signing in with their restored password hashes. Preserve the schema-compatible stricter flags independently of credential replacement, or fail the restore if they cannot be preserved.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛡️ Codex Security Review · Automatically triggered

Here are some automated security review suggestions for this pull request.

Reviewed commit: ec48f91c7d

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

}); err != nil {
return err
}
return p.step("carrying the account policies", carryPolicies(ctx, loader, dbURL, liveURL, p.out))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛡️ Codex Security Review · Automatically triggered

P2 Badge Security: Preserve live policies when restoring old schemas

When a same-deployment swap restores a backup from after policy foundation but before policy_documents.revision, and the live server has a newer custom policy, CarryPolicies fails on its unconditional revision insert with 42703. This wrapper converts that failure to success, so the transaction rolls back and the backup's older enabled policy remains. Startup then adds revision and loads that old policy, letting an authenticated user regain library, download, or playback access that the live policy removed. Treat policy carry as a strict step: copy it schema-aware, disable restored policies, or fail the restore.

Useful? React with 👍 / 👎.

Quick104 added a commit that referenced this pull request Nov 5, 2026
The contract gate fails on an approval that matches no change, and the
next pull request removes merged entries.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Quick104 added a commit that referenced this pull request Nov 5, 2026
Resolve the field-list conflicts in internal/apiv2/router.go and
internal/notifications/system.go by keeping main's side, including
NewSystem's `system = &System{` assignment, and adding this branch's plugin
destination fields.

main's backup stack checks that every table is classified. Classify this
branch's tables like the webhook ones: destinations are carried from the
live server with their secrets, delivery attempts are restored as delivery
history and failed if a restore interrupts them, and destinations stay out
of the profile export. The restore output names plugin destinations, and
secret-encryption.md lists the destination settings column.

Drop the two listAdminBackups approvals from breaking-approvals.json: they
belong to #3402, which is merged, and they match no change here.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Quick104 added a commit that referenced this pull request Nov 5, 2026
Merges main through c44b895, which brings the jellycompat playback
contract test fix (#3552). The merge had no conflicts; the SDK pin stays
at v0.32.2-0.20261105162846-0a3e9dc07ed0, and the regenerated API v2
spec, fixtures, web types, and route inventory match the merged tree.

Empties contracts/api/v2/breaking-approvals.json. Its two
listAdminBackups approvals from #3402 match no change once this
branch's spec differs from main's, so the contract check rejected them
as stale. This branch adds only optional default_schedule fields and
needs no approval of its own.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Quick104 added a commit that referenced this pull request Nov 5, 2026
The base now merges current main (cbdf5fb). The merge had no
conflicts, and regenerating the OpenAPI document, route inventory,
fixtures, web types and route manifest changed nothing.

Empty contracts/api/v2/breaking-approvals.json. Main still carries two
listAdminBackups approvals from #3402, and the contract policy rejects
approvals that match no change whenever openapi.json differs from the
base. This branch's /api/v2 changes are additive (new permission
operations and a required permissions_pending response field), so none
needs an approval.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Quick104 added a commit that referenced this pull request Nov 5, 2026
…ion (#3565)

* feat(downloads): let season and series downloads follow a chosen version

A season or series download picked each episode's file from watch history,
so a version chosen on the series page applied only to a single episode.

A v2 series or season page now accepts media_file_id as a version template.
Each episode gets its version closest to that file (edition, resolution, HDR,
video codec), and the template's own episode gets the template file. A file
from another title is 404. The capability reports batch_version. The v1
bridge and monitors keep their current picks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(downloads): require the version template to be in a library the profile can open

A season page's version template now follows the same library scope as the
files it chooses between. The quality ceiling is left out, since a preset
can bring a larger version under it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* chore(apiv2): remove contract approvals that merged in #3402

The contract gate fails on an approval that matches no change, and the
next pull request removes merged entries.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(downloads): run the version-template Postgres test in CI and document kept entries

Register TestSeriesPageFollowsTheVersionTemplatePostgres in the database
contract list, and say in the media_file_id description that existing
managed entries keep their file.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(downloads): say the template's episode still follows the quality ceiling

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Quick104 added a commit that referenced this pull request Nov 6, 2026
…imit (#3562)

* feat(access): let a household allow titles above a profile's rating limit

The household's primary profile can allow a limited profile specific
movies and series above its content-rating or advisory-age limit, one
by one or through a manual personal collection it created (titles added
later are allowed too). Other collections, smart ones included, can be
copied as individual allowances. A series allowance covers its seasons
and episodes. Library restrictions, a custom scope policy's rating
override and a stricter Jellyfin MaxOfficialRating still win.

Enforcement extends the shared maturity predicate to "within limits OR
allowed": the allowed IDs load with the profile row and travel in
access.MaturityLimits, so catalog reads, cache keys, cursors and the
Jellyfin surface pick them up. Allowances have their own Postgres store,
follow title merges, are audited as profile.updated, and are covered by
the backup authority check and table classification.

Adds nine /api/v2 operations behind a capability, the web title-page
"Allow for…" dialog, the profile editor's allowed titles and
collections, and the collection "Allow for…" action. Clears the merged
#3402 breaking-change approvals and carries the one-line jellycompat
test fix from #3552 so the package compiles.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(access): close review gaps in title allowances

- Jellyfin Latest and episode browsing now drop allowances when a
  client's MaxOfficialRating narrows the ceiling, like item browsing.
- Copying a collection copies only titles the household manager may
  see, for stored and smart collections alike.
- A live-allowed collection allows only the movies and series it holds.
- A failed search refresh in the profile editor keeps its results and
  offers a retry.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(access): recheck the manager's PIN inside allowance writes

Allowance writes are authorized before their transaction, so a PIN
change in between left revoked proof able to finish a pending write.
Each write now locks the acting primary profile and refuses with the
household 403 when its PIN revision changed, as profile writes do.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(access): lock the account before the manager profile in allowance writes

Allowance writes locked the acting profile and then updated the users
row, the reverse of account deletion and audited profile writes, so
they could deadlock with either. They now take the audit actor locks
and the account row first.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(backup): read title allowances only from schemas that have them

A full restore reads account authority from the backup's own schema
before it migrates. A backup older than title allowances has neither
table, so the read failed and the restore fell back to dropping every
carried credential. Such a backup's profiles now read as allowing
nothing above their limits.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(migrations): give title allowances the content ID family's collation and cascade

profile_title_allowances.content_id references media_items, so it takes
COLLATE "C" and ON UPDATE CASCADE like every other content ID reference,
keeping the online re-id working with allowance rows present.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(access): cap a collection copy at 10,000 titles

A smart collection with no item limit falls back to the catalog's
10,000,000-item default, so copying it read the whole matching catalog
into one request. A copy now allows at most 10,000 titles, the most a
synced list holds, for smart and stored collections alike.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(web): show a retry when a profile's allowed titles fail to load

A failed load of the allowed titles read as "No titles allowed yet" and
let the search offer titles already allowed; a failed load of the
allowed collections hid them. Both now say the list could not load and
offer a retry, and keep showing data a refresh could not update.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(access): let repeated collection copies reach every title

A stored collection's copy took its first 10,000 entries before
filtering, so entries that are not movies or series used up the
budget, and a repeated copy re-read the same entries. The copy now
reads only movies and series the profile is not yet allowed, so the
cap counts real candidates and a second copy continues with the rest.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(access): page a collection copy past titles the manager cannot see

Titles the household manager cannot see are never allowed, so they
stayed among a stored collection's first candidates on every copy and
a repeated copy could not reach the titles after them. The copy now
reads candidates a page at a time until it has 10,000 visible titles
or has scanned 100,000 entries.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(web): say when a profile's allowed lists could not refresh

A failed refresh kept the cached allowed titles and collections without
saying so. Both now keep showing what they have under a "may be out of
date" notice with a retry.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(api): state the 100,000-entry scan limit of a collection copy

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* perf(access): page collection copies by position, not offset

Offset paging re-read every skipped entry on each page, so a copy
past many hidden titles grew quadratically. Pages now continue after
the last (position, media item) read, on the collection's existing
continuation index.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(apiv2): declare collection title copies non-retryable

A repeated copy of a stored collection longer than one copy's cap
continues with the next titles, so a retry after a lost response does
not converge. allowCollectionTitles now declares non_retryable and says
to read the allowed titles before copying again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(access): bound the titles one profile may be allowed

The allowed list is read with every request a profile makes, and a
live collection had no size bound. A profile may now be allowed at most
10,000 titles: allowing past that answers 422 too_many_allowed_titles,
a copy stops at it, and the read takes at most 10,000, so a live
collection grown past the bound hides the rest instead of slowing
every request.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(access): check copies against the target's libraries; compare live collections on restore

- A collection copy keeps only titles in libraries the target profile
  can reach, as a single allowance does, so a later library change
  cannot switch on an allowance nobody granted.
- A full restore's authority check compares the profile's live-allowed
  collections themselves, so a restored allowance on a collection that
  is empty today cannot grant whatever is added to it later.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(access): bound the allowed-title read, not allowance writes

The write-time cap was imprecise (a collection's stale item count,
titles counted twice), racy, and broke idempotent retries at the
limit, while the read still deduplicated every live collection member
before its LIMIT. The read is now a UNION ALL with a LIMIT and no
ORDER BY, so PostgreSQL stops at 10,000 rows; Go sorts and
deduplicates them. Writes are no longer capped: a profile allowed more
than the bound sees 10,000 and the rest stay hidden.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(backup): compare every direct title allowance on restore

The restore authority check compared the resolved allowed titles, which
stop at 10,000, so a restored direct allowance past that window was
invisible to it yet could become effective once others were removed.
It now also compares the profile's own allowance rows, uncapped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(access): apply the target's libraries while a copy pages

A copy filtered titles the target profile cannot reach only after
filling its 10,000-title batch, so such titles at the start of a
collection could take the whole batch and stay ahead of every repeat.
The actor's access and the target's library scope now form one filter
that both the stored paging and the smart query apply before counting.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(access): keep up to 10,000 distinct allowed titles

The read's row LIMIT counted duplicates before they were removed, so
titles held both directly and through a collection could hide others
below the bound. The collection branch now leaves out titles the
profile is allowed directly, the read takes up to 20,000 rows, and the
profile keeps at most 10,000 distinct titles. Docs say which titles a
profile past the bound sees is unspecified.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(access): check actor and target access separately in collection copies

A title can sit in several libraries. Intersecting the actor's and target's
library lists into one filter dropped a title the actor sees through one
library and the target reaches through another. Each title now passes the
actor's check and the target's check on its own.

A smart collection's membership is now its query under the actor's access
and item limit; the target check filters those members afterwards, so it
no longer pulls in titles outside the collection.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(access): bound the allowed-title read by distinct titles

Titles held by several live collections each took a row of the read's
LIMIT before deduplication, so overlapping collections could use up the
bound and hide titles that were allowed, even with fewer than 10,000
distinct allowed titles. The collection branch now leaves out a title an
earlier live collection holds and reads only whole-title entries, so every
title comes back once and the LIMIT is exactly MaxAllowedTitles.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(access): say the allowed-title bound caps returned rows, not scanned ones

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(access): pass episodes through their series' allowance on the episode relation

The episode relation exposes an episode's own ID as content_id and its
series' rating, so keying the allowance on content_id compared episode IDs
with title IDs and hid an allowed series' episodes. Mixed search hydration
(Meilisearch results, watch-together member state), episode-scope queries
on that relation (episode-scope search) and episode-scope browse facets now
key it on episode_series_id, as the episode_catalog_entries reads already
key on series_id.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(access): rebuild a profile's recommendations when its allowances change

Cached recommendation rows are built under a profile's scope and only
filtered when read, so they could not gain a newly allowed title until the
daily job. Allowing or removing a title or collection, and copying a
collection, now tell the recommendations worker to rebuild the target
profile when the write changed a row, as a change to its limits does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(access): limit collection copies to what the owner can access

Every read of another profile's shared collection limits it to what its
owner can access, but a copy filtered members by the acting profile's
access alone, so a member hidden from its owner could become an allowance.
A copy now reads the collection the way the actor sees it, through
catalog.PersonalCollectionFilter, for both stored and smart collections.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* perf(access): intersect shared-collection allowances with a set

Reading another profile's collection when both profiles have allowances
compared every viewer allowance with every owner allowance, up to 10^8
comparisons at the 10,000-title bound. A set of the owner's allowances
makes it linear.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(access): page the allowed-title listing

Repeated collection copies can give a profile any number of direct
allowances, and listAllowedTitles read and rendered all of them in one
response. It now pages by keyset (created_at, content_id), newest first,
with the standard limit and cursor, over a matching index; the cursor is
bound to the account, both profiles and the viewer policy. A title's
per-profile standing checks its one allowance instead of listing every
allowance of each profile. The profile editor loads the list a page at a
time with "Show more".

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(web): start the allowed-title list over after a change; keep its empty state honest

An allowance change invalidated the paged list, which refetches every
loaded page in turn; it now resets that profile's list to its first page
and refreshes the other allowance queries. Cards the acting profile can't
see are dropped from each page, so an empty page shows "No titles allowed
yet" only when no page follows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(access): bound the live-collection entries a profile read scans

The read deduplicated live-collection titles before its LIMIT, so heavily
overlapping collections made every request of the profile scan their whole
membership. It now reads at most 50,000 whole-title entries of the live
collections (five times the 10,000-title bound) and deduplicates within
them, so overlap up to five times over still yields every distinct title,
and past that the rest stay hidden rather than costing every request more.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(backup): compare every allowed collection's members on restore

The restore authority check compared a profile's resolved allowed titles,
which the bounded allowance read caps, so a restored live collection could
carry members past the bound that later become effective unchecked. It now
also compares every member of the profile's allowed collections, uncapped,
as it already compares every direct allowance; the comparisons use a set
rather than a search per ID.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(access): carry allowed titles in ProfileMaturity

Account restore's preview and apply filter a profile's items with
access.ProfileMaturity, which left out the profile's allowances that
Resolve added separately, so restoring into a limited profile skipped the
history, progress and other data of titles it is allowed. ProfileMaturity
now carries them, and Resolve takes them from it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-v2 API v2 / Huma migration program (epic #135); long-running, stacked by phase enhancement New feature or request evidence-required Needs before-and-after evidence before the Evidence check passes go Pull requests that update go code impact: data-loss User data deleted, corrupted, or unrecoverable impact: usability Core flow broken or severely blocked javascript Pull requests that update javascript code needs-review Needs maintainer review to resolve uncertain classification, scope, or changed evidence. priority: P2 Limited scope, workaround exists, or polish size/XXL 1000–2999 added + deleted lines (all files); change volume, not priority. stacked Base is another open PR; merge in stack order named in the body

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature] Built-in database backup and restore

1 participant