Skip to content

feat(server)!: select divergence storage with one URL flag - #75

Merged
alecthomas merged 1 commit into
mainfrom
aat/storage-url
Oct 28, 2026
Merged

alecthomas merged 1 commit into
mainfrom
aat/storage-url

Conversation

@alecthomas

Copy link
Copy Markdown
Collaborator

Picking a divergence backend took two flags, --storage and --redis-url, and the Redis URL meant nothing unless the other flag said redis. Every new backend would have needed another flag of its own.

spectre serve now takes a single --storage URL whose scheme picks the backend: memory:// (the default) or redis:// / rediss://. Each backend registers a constructor for its schemes in a small registry in the storage package, and an unknown scheme is rejected when the command line is parsed.

This is a breaking change: --redis-url is gone, so --storage=redis --redis-url=redis://host:6379/0 becomes --storage=redis://host:6379/0.

🤖 Generated with Claude Code

Choosing a backend took two flags, and the Redis URL flag meant nothing
unless the other one said redis. A single storage URL names the backend
by its scheme and carries its settings, so adding a backend no longer
needs a new flag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alecthomas alecthomas changed the title refactor(server)!: select divergence storage with one URL flag feat(server)!: select divergence storage with one URL flag Oct 28, 2026
@alecthomas
alecthomas marked this pull request as ready for review October 28, 2026 11:14
@alecthomas
alecthomas merged commit 094fb9f into main Oct 28, 2026
6 checks passed
@alecthomas
alecthomas deleted the aat/storage-url branch October 28, 2026 11:14
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 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-10-28T11:15:45.728625Z 41f7008 Draft marked ready
ℹ️ 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.

@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: 41f7008a36

ℹ️ 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".

)
// constructors maps each URL scheme to its backend. Backends write it only from
// init, so reading it needs no lock.
var constructors = map[string]Constructor{} //nolint:gochecknoglobals // Backends register themselves.

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 Keep the backend registry out of package-global state

The new constructors map introduces mutable global state in a domain package, and the backend init() functions populate it implicitly on import. This violates the root AGENTS.md architecture requirements that prohibit global state outside main entry points and place initialization/bootstrap in Main; suppressing gochecknoglobals does not satisfy those requirements. Construct and register the backends explicitly during bootstrap and pass the registry to storage, or use stateless dispatch for the built-in schemes.

AGENTS.md reference: AGENTS.md:L5-L10

Useful? React with 👍 / 👎.

alecthomas added a commit that referenced this pull request Oct 28, 2026
The SPECTRE server could store divergences only in a single Redis
server. This adds support for a Redis Cluster.

- `--storage` selects cluster mode with the `redis-cluster://` and
`rediss-cluster://` schemes. Further seed nodes go in `addr` query
parameters, such as
`redis-cluster://localhost:7000?addr=localhost:7001`. go-redis parses
single-node and cluster URLs with the same `redis` and `rediss` schemes,
so a separate scheme is needed to choose between them.
- A cluster client cannot talk to a standalone Redis server, so plain
`redis://` URLs keep using the single-node client.
- The store holds a go-redis `UniversalClient`, which both clients
satisfy. Every command touches the one divergences key, which lives in a
single slot, so `WATCH` transactions work unchanged in a cluster.
- A cluster URL with a database path is rejected, because go-redis would
otherwise ignore the path and silently use database 0.

The tests run the shared store tests and `Open` against a cluster
client. They use miniredis, which acts as a one-node cluster owning
every slot. As a result, redirects between nodes are not exercised.

This is stacked on #75.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant