standard_ledger 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 411ad3db9a71ca8adddecc84d407dabddbd167c7ed00e534e975a700b3a2e8f2
4
- data.tar.gz: aeb938a4e1fb16c6df67fbb76a93a5687c40116be040df5da44e65541ce4d282
3
+ metadata.gz: 89af058a7d94051bc75f8e853d1be397270b52bc5a02020dfdd41484c6cacda5
4
+ data.tar.gz: 50eef558981621f3561c42095d294f87f09d7ed18e8fc5a5919c0801262f257b
5
5
  SHA512:
6
- metadata.gz: 2d0cd11b66c8d22b76cf9444e8840d92c35ccd81d4eba224e8123b208aa5c706503bc9cf6e9bbf1dc7bff564df4728adac79eeeacc254a976efb8cfa1fd0907a
7
- data.tar.gz: 5f352fe00a36e01ef43aa4d8efb197a32314c43f0b31657342996dc91bcf422933e4076b851813bd6c6fd7ab69a52d18f53e9650fbced76292b9deca52b6ce0b
6
+ metadata.gz: 16d8c529a99909adb4739feb0ea76e996ebd709c044bc56dd2722bc041f4c17670d2bb383a48072df9a686bc02b1c2a49add8206618ddeb7fb86dd2b45e61c9f
7
+ data.tar.gz: 5f152b064c69e8da3f7e2767c4b3914da197599ed64ecc8e512be6c34e334af25337f83fd68080c7811a3f4772df647d5799ae635cb0116409286455bd86bf0e
data/CHANGELOG.md CHANGED
@@ -6,7 +6,30 @@ project adheres to [Semantic Versioning](https://semver.org/).
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
- Nothing yet.
9
+ ## [0.5.0] - 2026-09-22
10
+
11
+ ### Changed
12
+ - `required_ruby_version` raised from `>= 3.4` to `>= 4.0`, and the repo's
13
+ `.ruby-version` moved from 3.4.4 to 4.0.1 to match. The 3.4 floor was never
14
+ exercised — CI has only ever run the 4.0.x matrix — and every consumer runs
15
+ 4.0.x. This aligns the gem with the rest of the `standard_*` family.
16
+
17
+ ### Documentation
18
+ - New README **Events** section documenting all five lifecycle events
19
+ (`entry.created`, `projection.applied`, `projection.failed`,
20
+ `projection.refreshed`, `projection.rebuilt`), their payloads, and the four
21
+ places a payload shape differs from the obvious one: `:sql` mode sends
22
+ `target: nil`, `:matview` events carry `view:`/`concurrently:` instead of
23
+ `entry:`/`target:`, `projection.rebuilt` carries `entry_class:` rather than
24
+ `entry:`, and input errors (matview name validation,
25
+ `RefreshInsideTransaction`) propagate without firing `projection.failed`.
26
+ Also records that subscriber exceptions are swallowed by design.
27
+ - README installation now shows the RubyGems pin. It still said "private during
28
+ incubation, pin from git"; the gem has been on RubyGems since 2026-05-07 and
29
+ the last git-pinned consumer was converted in 2026-07.
30
+ - `CLAUDE.md` consumer list corrected: it listed two consumers and claimed
31
+ git+tag consumption. There are four (`fundbright-web`, `luminality-web`,
32
+ `sidekick-web`, `jumpdrive-web`), all plain rubygems.
10
33
 
11
34
  ## [0.4.0] - 2026-05-07
12
35
 
@@ -423,7 +446,9 @@ roadmap.
423
446
  and `:trigger` (host-owned, gem records rebuild SQL).
424
447
  - `standard_ledger:doctor` rake task (verifies trigger presence, etc.).
425
448
 
426
- [Unreleased]: https://github.com/rarebit-one/standard_ledger/compare/v0.3.0...HEAD
449
+ [Unreleased]: https://github.com/rarebit-one/standard_ledger/compare/v0.5.0...HEAD
450
+ [0.5.0]: https://github.com/rarebit-one/standard_ledger/compare/v0.4.0...v0.5.0
451
+ [0.4.0]: https://github.com/rarebit-one/standard_ledger/compare/v0.3.0...v0.4.0
427
452
  [0.3.0]: https://github.com/rarebit-one/standard_ledger/compare/v0.2.0...v0.3.0
428
453
  [0.2.0]: https://github.com/rarebit-one/standard_ledger/compare/v0.1.0...v0.2.0
429
454
  [0.1.0]: https://github.com/rarebit-one/standard_ledger/releases/tag/v0.1.0
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 Rarebit One
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -283,12 +283,16 @@ Five projection modes — pick per declaration:
283
283
 
284
284
  ## Installation
285
285
 
286
- The gem is private during incubation. Pin from git:
286
+ The gem is published on RubyGems:
287
287
 
288
288
  ```ruby
289
- gem "standard_ledger", git: "https://github.com/rarebit-one/standard_ledger", ref: "<sha>"
289
+ gem "standard_ledger", "~> 0.4"
290
290
  ```
291
291
 
292
+ (It was git-pinned during incubation. Don't reintroduce a `git:` reference —
293
+ it makes a bare `bundle install` a prerequisite for every other command in a
294
+ fresh checkout, blocking `rubocop`/`rspec` until it has been run.)
295
+
292
296
  Then run the install generator to drop a configured initializer in place:
293
297
 
294
298
  ```bash
@@ -317,6 +321,57 @@ StandardLedger.configure do |c|
317
321
  end
318
322
  ```
319
323
 
324
+ ## Events
325
+
326
+ The gem emits five lifecycle events. On Rails 8.1+ they go through
327
+ `Rails.event.notify(name, **payload)`; on older Rails (or any host without the
328
+ structured reporter) they fall back to
329
+ `ActiveSupport::Notifications.instrument(name, payload)`. The backend is
330
+ detected per call, not cached at load — the gem is required before Rails has
331
+ finished booting.
332
+
333
+ Every name is prefixed with `Config#notification_namespace` (default
334
+ `standard_ledger`), so a host that renames the namespace renames all five.
335
+
336
+ | Event | Fired when | Payload |
337
+ |---|---|---|
338
+ | `<prefix>.entry.created` | after the entry's transaction commits | `entry:`, `kind:`, `targets:` (a `{ name => target }` hash) |
339
+ | `<prefix>.projection.applied` | a projection wrote successfully | `entry:`, `target:`, `projection:`, `mode:`, `duration_ms:` — plus `attempt:` in `:async` mode |
340
+ | `<prefix>.projection.failed` | a projection raised | the `applied` payload plus `error:` (the exception) |
341
+ | `<prefix>.projection.refreshed` | a matview refresh succeeded | `view:`, `concurrently:`, `duration_ms:` |
342
+ | `<prefix>.projection.rebuilt` | `StandardLedger.rebuild!` finished one target | `entry_class:`, `target:`, `projection:`, `mode:` |
343
+
344
+ Four payload shapes are worth knowing before you write a subscriber that
345
+ assumes a key is always present:
346
+
347
+ - **`:sql` mode sends `target: nil`.** The recompute statement is bound by
348
+ `:target_id` and never loads the record, so there is no object to hand you.
349
+ - **`:matview` events carry `view:`/`concurrently:` instead of
350
+ `entry:`/`target:`.** A refresh is view-wide — Postgres has no partial-refresh
351
+ primitive — so no single entry or target caused it. The matview variant of
352
+ `projection.failed` also carries `mode: :matview`, while
353
+ `projection.refreshed` carries no `mode:` at all.
354
+ - **`projection.rebuilt` carries `entry_class:`, not `entry:`.** Rebuild is
355
+ log replay across an entire class; there is no originating entry.
356
+ - **`projection.failed` is not fired for input errors.** An `ArgumentError`
357
+ from the matview name validator, or `RefreshInsideTransaction` from the
358
+ boundary check, propagates without an event — the SQL was never issued, so
359
+ nothing failed to project.
360
+
361
+ **Subscriber exceptions are swallowed** (warned to stderr, not re-raised).
362
+ Ledger observability must never take down a host's request path: by emit time
363
+ the projection has already either succeeded or been rolled back, so there is
364
+ nothing a raising subscriber could usefully abort. Don't put work in a
365
+ subscriber that you need to have happened.
366
+
367
+ Retries: `:async` projections are capped by `Config#default_async_retries`
368
+ (default 3), and both `applied` and `failed` carry `attempt:` so subscribers
369
+ can tell first-try success from retry success.
370
+
371
+ `standard_audit` consumers can subscribe to `entry.created` to write an audit
372
+ row; the gem itself never calls into audit. That coupling is deliberately the
373
+ host's to opt into — see "Relationship to standard_audit" below.
374
+
320
375
  ## Testing
321
376
 
322
377
  The gem ships an opt-in RSpec support file. Hosts add this to their
@@ -382,4 +437,4 @@ Neither subsumes the other.
382
437
 
383
438
  ## License
384
439
 
385
- MIT. See [MIT-LICENSE](MIT-LICENSE).
440
+ MIT. See [LICENSE](LICENSE).
@@ -1,3 +1,3 @@
1
1
  module StandardLedger
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: standard_ledger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jaryl Sim
@@ -134,7 +134,7 @@ extensions: []
134
134
  extra_rdoc_files: []
135
135
  files:
136
136
  - CHANGELOG.md
137
- - MIT-LICENSE
137
+ - LICENSE
138
138
  - README.md
139
139
  - Rakefile
140
140
  - lib/generators/standard_ledger/install/install_generator.rb
@@ -175,7 +175,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
175
175
  requirements:
176
176
  - - ">="
177
177
  - !ruby/object:Gem::Version
178
- version: '3.4'
178
+ version: '4.0'
179
179
  required_rubygems_version: !ruby/object:Gem::Requirement
180
180
  requirements:
181
181
  - - ">="
data/MIT-LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Jaryl Sim
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.