omen 0.8.0 → 0.9.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: 50e0ccd4a4b0c3fa358e235be39a5e79b53fabbcb4e05c09424508cab6be99f9
4
- data.tar.gz: 4c4de5e474629c685455a599469c33caff9ae1e646dd331752313bf8c2e00020
3
+ metadata.gz: c51ab71a4d3ccce3f1bdcfa1e6f4b6a8196e2778f55368e7dea902e220f367d4
4
+ data.tar.gz: '003328f8dcba05fe6654e1852b8c9c18ef5e305d8c0ba95456b266c01880c546'
5
5
  SHA512:
6
- metadata.gz: 5158631649bc16dbeffbd630ba07303880657e30dd0c15ccba1ebde0a66317985caff827dfa423259d71091f74bf835634fa029050cd554917427784f9ef766e
7
- data.tar.gz: 91910028f557c76263c24b7c664aca12e6e89a8f5c009e605e4fd3563f1c39a8bbd35672dc24c3529c800a689b5c62a09a572e3e5e01f5072232ee8acf98db03
6
+ metadata.gz: 89a995c7beebd10a587d370ba7e8762f4e92a05252985045666101e64af81f10e5b7100631d670bd12ef89fe527fd4fc744f56918d26500268a39667311ee941
7
+ data.tar.gz: cf1a91b08d3e40e10d4a43a12872f2befad7cdefea114bbfe0e0e4eb78a8eb55076201ac8bf55e0bd2cd22d9a7ae3a4525367880d0a9622aa05a3d6f11e9062f
data/CHANGELOG.md CHANGED
@@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file.
5
5
  For more information about changelogs, check [Keep a Changelog](http://keepachangelog.com) and
6
6
  [Vandamme](http://tech-angels.github.io/vandamme).
7
7
 
8
+ ## 0.9.0 - 2026-09-18
9
+
10
+ * [Fix] An answer landing touches the reading it belongs to, so a page watching one refreshes
11
+ on the answer rather than on whichever status change the run happens to make around it. A
12
+ question already touched its reading, which is why a question appeared and its answer did not.
13
+ * [Fix] Making an audience's role and letting members into it are two transactions, not one.
14
+ A managed database refuses to make a role at all, and a refusal takes its whole transaction
15
+ with it -- so the membership a role already there only needed was rolled back with the
16
+ refusal, and every statement run as it went on saying the app was misconfigured.
17
+ * [Change] An audience whose Postgres role could not be made says so once and narrows nothing,
18
+ rather than failing table by table and then reporting the audience narrowed. A managed
19
+ database refuses `CREATE ROLE` to the app's own user, and the refusal used to arrive as a
20
+ screenful of `role does not exist` followed by a success line.
21
+
8
22
  ## 0.8.0 - 2026-09-16
9
23
 
10
24
  * [Feature] Make how a Postgres role is made safely public, so a host builds the read-only role
@@ -5,7 +5,10 @@ class Omen::Answer < Omen.config.record
5
5
  # A \uXXXX escape that outlived JSON.parse, because Claude escaped the backslash of its own.
6
6
  UNICODE_ESCAPE = /\\u([0-9a-fA-F]{4})/
7
7
 
8
- belongs_to :question
8
+ # Touched, so that a reading whose answer has just landed says so: the reading is what
9
+ # broadcasts, and the row it broadcasts for is this one. Without it a page waits on the
10
+ # status the run happens to change around the answer rather than on the answer itself.
11
+ belongs_to :question, touch: true
9
12
 
10
13
  # @return [String] the side of the conversation this was said on, in the words the API uses.
11
14
  def role = 'assistant'
data/lib/omen/grants.rb CHANGED
@@ -30,8 +30,10 @@ module Omen
30
30
  ]
31
31
  end
32
32
 
33
- # The same role, made for one audience rather than for every table: it is granted nothing
34
- # here, since a narrowing names the tables and the columns of each itself.
33
+ # Who may enter the role, and the schema it reads in. Kept apart from making the role: a
34
+ # managed database refuses to make one at all, and a refusal takes its whole transaction
35
+ # with it -- so membership granted in the same breath would be lost to a role that was
36
+ # already there and only needed letting into.
35
37
  # @param connection [ActiveRecord::ConnectionAdapters::AbstractAdapter] a writing one.
36
38
  # @param name [String] the role to make.
37
39
  # @param members [Array<String>] the roles that may enter it, none of them inheriting it.
@@ -39,7 +41,6 @@ module Omen
39
41
  def self.narrowed(connection, name, members)
40
42
  role = connection.quote_table_name name
41
43
  [
42
- *made(connection, name),
43
44
  *members.map { |member| apart role, connection.quote_table_name(member) },
44
45
  "GRANT USAGE ON SCHEMA public TO #{role}",
45
46
  ]
data/lib/omen/inquirer.rb CHANGED
@@ -14,6 +14,13 @@ module Omen
14
14
  UNMADE = 'Could not make %{role}, so every reading will say this app is misconfigured. Ask ' \
15
15
  'for that role, NOLOGIN, granted SELECT on every table but %{tables}.'
16
16
 
17
+ # Said where an audience's own role could not be made. Its tables are then granted to
18
+ # nobody and no policy stands over them, so every reading of that audience says the app is
19
+ # misconfigured -- and every statement after the refusal fails for the same reason, which
20
+ # is one message worth saying and a screenful worth not.
21
+ UNNARROWED = 'Could not make %{role}, so nothing was narrowed to it and every reading of ' \
22
+ 'that audience will say this app is misconfigured. Ask for that role, NOLOGIN.'
23
+
17
24
  # Said where a role that already existed is one a reading should not be able to reach through.
18
25
  DANGEROUS = '%{role} holds %{held}. This gem cannot take that away without being a superuser ' \
19
26
  'itself, so ask for it to be taken away.'
@@ -58,10 +65,24 @@ module Omen
58
65
  # @param members [Array<String>] the roles that may enter a narrowed one.
59
66
  # @return [void]
60
67
  def self.narrow(connection, members)
61
- Omen::Reading.narrowings.each do |narrowing|
62
- narrowing.statements(connection, members).each { |group| Omen.attempted connection, *group }
63
- puts "Narrowed #{narrowing.role} to the rows #{narrowing.setting} names"
64
- end
68
+ Omen::Reading.narrowings.each { |narrowing| narrowed connection, narrowing, members }
69
+ end
70
+
71
+ # One audience: its role made first and asked for straight after, since everything else
72
+ # here names that role and a database that would not make it refuses the lot. Nothing is
73
+ # said to have been narrowed where nothing was.
74
+ # @param connection [ActiveRecord::ConnectionAdapters::AbstractAdapter] a writing one.
75
+ # @param narrowing [Omen::Narrowing] the audience to write.
76
+ # @param members [Array<String>] the roles that may enter its role.
77
+ # @return [void]
78
+ def self.narrowed(connection, narrowing, members)
79
+ making, *holding = narrowing.statements(connection, members)
80
+ Omen.attempted connection, *making
81
+ return warn UNNARROWED % { role: narrowing.role } unless
82
+ Attributes.exists? connection, narrowing.role
83
+
84
+ holding.each { |group| Omen.attempted connection, *group }
85
+ puts "Narrowed #{narrowing.role} to the rows #{narrowing.setting} names"
65
86
  end
66
87
 
67
88
  # Discovered rather than named: SET LOCAL ROLE needs the connecting role to be a member of
@@ -37,7 +37,8 @@ module Omen
37
37
  # @return [Array<Array<String>>] the statements, grouped: what arrives together is applied
38
38
  # together, so no table is left with row level security on and no policy under it.
39
39
  def statements(connection, members)
40
- [ Grants.narrowed(connection, @role, members),
40
+ [ Grants.made(connection, @role),
41
+ Grants.narrowed(connection, @role, members),
41
42
  *@whole.map { |table| granted connection, table },
42
43
  *@own.map { |table, own| narrowed connection, table, own }, ]
43
44
  end
data/lib/omen/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Omen
2
2
  # The version of this gem, as RubyGems knows it.
3
- VERSION = '0.8.0'
3
+ VERSION = '0.9.0'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Baccigalupo