Skip to content

feat: nix flake#2

Merged
0xgleb merged 2 commits into
feat/licensefrom
feat/nix-flake
May 14, 2026
Merged

feat: nix flake#2
0xgleb merged 2 commits into
feat/licensefrom
feat/nix-flake

Conversation

@0xgleb
Copy link
Copy Markdown
Collaborator

@0xgleb 0xgleb commented May 9, 2026

Closes RAI-459.

What

Bootstraps the repository with foundational project scaffolding:

  • .envrc — configures nix-direnv to automatically load the Nix dev shell when entering the directory, watching flake.nix and flake.lock for changes
  • .gitignore — excludes build artifacts, local databases, secrets, and tooling caches
  • flake.nix + flake.lock — defines the Nix dev shell with sqlx-cli, cargo-expand, and cargo-nextest on top of the rainix base environment
  • AGENTS.md — comprehensive AI agent guidance covering architecture, coding standards, workflow, testing strategy, security, and documentation conventions

Why

The repository needed a reproducible development environment and a clear set of conventions for both human contributors and AI agents. The Nix flake ensures all developers get identical tooling. AGENTS.md encodes the project's architectural decisions, quality control policies, and domain rules in one place so AI agents can operate consistently without repeated clarification.

How

The Nix flake inherits the rainix dev shell and extends it with Rust-specific tooling. nix-direnv is wired via .envrc to activate the shell automatically. AGENTS.md is structured as a living reference document with a strict character-limit policy to keep it maintainable, covering everything from planning hierarchy and epic decomposition to code style rules and financial data integrity requirements.

Summary by CodeRabbit

  • Chores
    • Updated development environment configuration to support reproducible Nix-based setups
    • Enhanced repository management with updated ignore patterns for local and temporary files
    • Added comprehensive developer guidelines and workflow documentation for contributors

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 9, 2026

Warning

Rate limit exceeded

@0xgleb has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 19 minutes and 10 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: ab8a3e6c-5e85-4d89-b3a7-51d10a829b1d

📥 Commits

Reviewing files that changed from the base of the PR and between 7b07d7a and 11926bd.

⛔ Files ignored due to path filters (4)
  • Cargo.lock is excluded by !**/*.lock
  • examples/complex/Cargo.lock is excluded by !**/*.lock
  • examples/simple/Cargo.lock is excluded by !**/*.lock
  • flake.lock is excluded by !**/*.lock
📒 Files selected for processing (50)
  • .envrc
  • .github/workflows/ci.yaml
  • AGENTS.md
  • CLAUDE.md
  • Cargo.toml
  • README.md
  • SPEC.md
  • clippy.toml
  • crates/event-sorcery/Cargo.toml
  • crates/event-sorcery/src/dependency.rs
  • crates/event-sorcery/src/lib.rs
  • crates/event-sorcery/src/lifecycle.rs
  • crates/event-sorcery/src/projection.rs
  • crates/event-sorcery/src/reactor.rs
  • crates/event-sorcery/src/schema_registry.rs
  • crates/event-sorcery/src/sqlite_event_repository.rs
  • crates/event-sorcery/src/testing.rs
  • crates/event-sorcery/src/view_backend.rs
  • crates/event-sorcery/src/wire.rs
  • crates/sqlite-es/Cargo.toml
  • crates/sqlite-es/README.md
  • crates/sqlite-es/src/cqrs.rs
  • crates/sqlite-es/src/event_repository.rs
  • crates/sqlite-es/src/lib.rs
  • crates/sqlite-es/src/sql_query.rs
  • crates/sqlite-es/src/testing.rs
  • crates/sqlite-es/src/view_repository.rs
  • docs/cqrs.md
  • docs/domain.md
  • docs/sqlx.md
  • docs/ttdd.md
  • examples/README.md
  • examples/complex/Cargo.toml
  • examples/complex/README.md
  • examples/complex/migrations/20260513104032_init.sql
  • examples/complex/migrations/20260513104033_inventory_view.sql
  • examples/complex/src/audit_log.rs
  • examples/complex/src/inventory.rs
  • examples/complex/src/main.rs
  • examples/complex/src/order.rs
  • examples/complex/src/stock_alert.rs
  • examples/simple/Cargo.toml
  • examples/simple/README.md
  • examples/simple/migrations/20260513104023_init.sql
  • examples/simple/migrations/20260513104024_support_ticket_view.sql
  • examples/simple/src/main.rs
  • examples/simple/src/support_ticket.rs
  • flake.nix
  • migrations/20251016210348_init.sql
  • scripts/check-examples.nu
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/nix-flake

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Collaborator Author

0xgleb commented May 9, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@0xgleb 0xgleb mentioned this pull request May 9, 2026
@0xgleb 0xgleb self-assigned this May 9, 2026
@0xgleb 0xgleb force-pushed the feat/nix-flake branch from 310cef1 to 50532ae Compare May 9, 2026 07:57
@0xgleb 0xgleb marked this pull request as ready for review May 9, 2026 08:54
Comment thread .envrc Outdated
Comment thread AGENTS.md
@linear
Copy link
Copy Markdown

linear Bot commented May 9, 2026

RAI-459

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.gitignore:
- Around line 1-9: Add the missing .tmp/ ignore rule to .gitignore so generated
artifacts are not committed; update the .gitignore (alongside entries like
.direnv/ and .env) to include a line with ".tmp/" (avoid duplicating an existing
rule and place it with other generated/local directories) to align with
AGENTS.md's generated-path policy.

In `@AGENTS.md`:
- Around line 367-382: The roadmap example links currently point to the wrong
repository (st0x.liquidity); update the example markdown lines that show
issue/PR links — specifically the patterns "- [ ] [`#N` Issue
title](https://github.com/ST0x-Technology/st0x.liquidity/issues/N)" and "PR: [`#M`
PR title](https://github.com/ST0x-Technology/st0x.liquidity/pull/M)" — to use
the correct repository base (event-sorcery) so both issue and PR example URLs
and any explanatory text reference the event-sorcery GitHub paths consistently.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f46e875b-4e0b-43aa-8f53-d981da211551

📥 Commits

Reviewing files that changed from the base of the PR and between c653d15 and 7b07d7a.

⛔ Files ignored due to path filters (1)
  • flake.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • .envrc
  • .gitignore
  • AGENTS.md
  • flake.nix

Comment thread .gitignore
Comment thread AGENTS.md Outdated
@0xgleb 0xgleb force-pushed the feat/nix-flake branch 2 times, most recently from 727a410 to 3246722 Compare May 9, 2026 10:26
@0xgleb 0xgleb requested review from JuaniRios and findolor May 9, 2026 10:29
@0xgleb 0xgleb force-pushed the feat/nix-flake branch from 3246722 to c95843c Compare May 9, 2026 10:41
@0xgleb 0xgleb force-pushed the feat/nix-flake branch from c95843c to 4a8f3db Compare May 9, 2026 11:07
@0xgleb 0xgleb mentioned this pull request May 9, 2026
@0xgleb 0xgleb requested a review from hardyjosh May 13, 2026 09:48
Rainix-based nix flake providing the rust toolchain, sqlx-cli, cargo-expand, cargo-nextest, and the pre-commit hooks listed in .pre-commit-config.yaml. .envrc auto-loads the shell via nix-direnv. flake.lock pins all inputs for reproducibility.
* feat: workspace + copy sqlite-es and event-sorcery crates

Crates copied verbatim from st0x.issuance (sqlite-es) and st0x.liquidity (event-sorcery). Adds workspace Cargo.toml with strict lints (warnings/clippy::all/pedantic/nursery/unwrap_used/expect_used denied; unsafe_code forbidden), clippy.toml exempting unwrap/expect in tests, and the canonical events+snapshots schema migration. Workspace dependency versions audited and bumped to current semver-compatible releases. cqrs-es held at 0.4.12 — 0.5.0 is a major bump pending deliberate upgrade.

* feat: AGENTS.md, README, and docs (cqrs, sqlx, ttdd) (#4)

* feat: AGENTS.md, SPEC.md, README, and docs

AGENTS.md adapted from upstream st0x conventions, trimmed to the rules that apply here (drops alloy/brokerage/onchain bits). SPEC.md describes the library's goals, components, and behavior. docs/domain.md is the CQRS/ES glossary and naming conventions. docs/cqrs.md is a usage reference. docs/sqlx.md is the running pitfall log. docs/ttdd.md is the type-driven TDD methodology. CLAUDE.md is a symlink to AGENTS.md so both names resolve to the same source of truth.

* feat: GitHub Actions CI (#5)

* feat: GitHub Actions CI

Matrix runs cargo check / nextest / clippy / fmt --check, plus a separate job for pre-commit hooks. Every step uses 'nix develop -c …' so CI runs the same toolchain as local dev. Caches ~/.cargo and target/ keyed on lockfile + flake.lock.

* feat: replace SqliteProjectionRepo with RepoFamily GAT (#6)

* feat: replace SqliteProjectionRepo with ViewBackend GAT

The previous design parameterized Projection over a Repo type that was bound to ViewRepository<Lifecycle<Entity>, Lifecycle<Entity>>. That bound named the pub(crate) Lifecycle type in a public position, tripping the private_bounds lint, and was suppressed with #[allow(private_bounds)] in three impl blocks pending the crate's extraction.

ViewBackend is a GAT-on-trait HKT emulation: a ViewBackend instance is a type-level function (View, Aggregate) -> SomeRepo. Projection<Entity, Backend: ViewBackend> applies the function internally to obtain Backend::Repo<Lifecycle<Entity>, Lifecycle<Entity>>, so Lifecycle saturation happens inside the struct/method bodies, not in any public bound. SqliteViewBackend is the default. The three #[allow(private_bounds)] suppressions are removed. Test repos InMemoryRepo<View, Agg> and ConflictingRepo<View, Agg> made generic with paired ViewBackend adapters so existing tests still compile.

* docs: add examples of how to use the repo (#7)

Adds a runnable examples/ directory at the workspace root covering the
core event-sorcery surface:

- basic_entity: smallest setup -- EventSourced, Store, send/load,
  load_entity, send_command, load_all_ids, count_aggregates,
  load_ids_paginated, compact_events, incremental_vacuum.
- projection: Materialized = Table with a SQLite generated column for
  filtered queries; load/load_all/filter/rebuild/rebuild_all; injects a
  domain Service via Arc<dyn Clock>.
- reactor: multi-entity StockAlert reactor wired across two stores plus
  a single-entity AuditLog reactor running alongside an auto-projection.

Each example has a README.md explaining the concept and a #[cfg(all(test,
feature = "test-support"))] mod tests block exercising replay,
TestHarness, TestStore, SpyReactor, and ReactorHarness. examples/README.md
indexes the three; the repo-root README.md links to it.

CI now runs every example in a dedicated matrix job and includes
--all-targets so example test modules execute under cargo nextest.
@0xgleb 0xgleb merged commit 7761f05 into feat/license May 14, 2026
13 of 14 checks passed
@0xgleb 0xgleb deleted the feat/nix-flake branch May 14, 2026 15:41
0xgleb added a commit that referenced this pull request May 14, 2026
* chore: bootstrap repo with LICENSE and shared config

MIT LICENSE plus repo-wide configuration that applies to every PR in the stack: .gitignore, .yamlfmt (formatter config), and .coderabbit.yaml (review automation).

* feat: nix flake (#2)

* feat: nix dev shell + direnv

Rainix-based nix flake providing the rust toolchain, sqlx-cli, cargo-expand, cargo-nextest, and the pre-commit hooks listed in .pre-commit-config.yaml. .envrc auto-loads the shell via nix-direnv. flake.lock pins all inputs for reproducibility.

* feat: copy sqlite-es and event-sorcery crates (#3)

* feat: workspace + copy sqlite-es and event-sorcery crates

Crates copied verbatim from st0x.issuance (sqlite-es) and st0x.liquidity (event-sorcery). Adds workspace Cargo.toml with strict lints (warnings/clippy::all/pedantic/nursery/unwrap_used/expect_used denied; unsafe_code forbidden), clippy.toml exempting unwrap/expect in tests, and the canonical events+snapshots schema migration. Workspace dependency versions audited and bumped to current semver-compatible releases. cqrs-es held at 0.4.12 — 0.5.0 is a major bump pending deliberate upgrade.

* feat: AGENTS.md, README, and docs (cqrs, sqlx, ttdd) (#4)

* feat: AGENTS.md, SPEC.md, README, and docs

AGENTS.md adapted from upstream st0x conventions, trimmed to the rules that apply here (drops alloy/brokerage/onchain bits). SPEC.md describes the library's goals, components, and behavior. docs/domain.md is the CQRS/ES glossary and naming conventions. docs/cqrs.md is a usage reference. docs/sqlx.md is the running pitfall log. docs/ttdd.md is the type-driven TDD methodology. CLAUDE.md is a symlink to AGENTS.md so both names resolve to the same source of truth.

* feat: GitHub Actions CI (#5)

* feat: GitHub Actions CI

Matrix runs cargo check / nextest / clippy / fmt --check, plus a separate job for pre-commit hooks. Every step uses 'nix develop -c …' so CI runs the same toolchain as local dev. Caches ~/.cargo and target/ keyed on lockfile + flake.lock.

* feat: replace SqliteProjectionRepo with RepoFamily GAT (#6)

* feat: replace SqliteProjectionRepo with ViewBackend GAT

The previous design parameterized Projection over a Repo type that was bound to ViewRepository<Lifecycle<Entity>, Lifecycle<Entity>>. That bound named the pub(crate) Lifecycle type in a public position, tripping the private_bounds lint, and was suppressed with #[allow(private_bounds)] in three impl blocks pending the crate's extraction.

ViewBackend is a GAT-on-trait HKT emulation: a ViewBackend instance is a type-level function (View, Aggregate) -> SomeRepo. Projection<Entity, Backend: ViewBackend> applies the function internally to obtain Backend::Repo<Lifecycle<Entity>, Lifecycle<Entity>>, so Lifecycle saturation happens inside the struct/method bodies, not in any public bound. SqliteViewBackend is the default. The three #[allow(private_bounds)] suppressions are removed. Test repos InMemoryRepo<View, Agg> and ConflictingRepo<View, Agg> made generic with paired ViewBackend adapters so existing tests still compile.

* docs: add examples of how to use the repo (#7)

Adds a runnable examples/ directory at the workspace root covering the
core event-sorcery surface:

- basic_entity: smallest setup -- EventSourced, Store, send/load,
  load_entity, send_command, load_all_ids, count_aggregates,
  load_ids_paginated, compact_events, incremental_vacuum.
- projection: Materialized = Table with a SQLite generated column for
  filtered queries; load/load_all/filter/rebuild/rebuild_all; injects a
  domain Service via Arc<dyn Clock>.
- reactor: multi-entity StockAlert reactor wired across two stores plus
  a single-entity AuditLog reactor running alongside an auto-projection.

Each example has a README.md explaining the concept and a #[cfg(all(test,
feature = "test-support"))] mod tests block exercising replay,
TestHarness, TestStore, SpyReactor, and ReactorHarness. examples/README.md
indexes the three; the repo-root README.md links to it.

CI now runs every example in a dedicated matrix job and includes
--all-targets so example test modules execute under cargo nextest.
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.

3 participants