@consiliency/agent-board-schema 1.76.0 → 1.80.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.
- package/fixtures/already-applied.json +16 -0
- package/migrations/20261120000200_agent_board_thread_key_serialize.sql +118 -0
- package/migrations/20261121000100_agent_board_thread_key_guards.sql +196 -0
- package/migrations/20261124000100_agent_board_step_up_enforcement.sql +1213 -0
- package/migrations/20261126000100_agent_board_membership_removal_requires_active.sql +243 -0
- package/package.json +1 -1
- package/schema-manifest.json +39 -3
- package/src/deployment-drift-main.test.mjs +89 -6
- package/src/deployment-drift.test.mjs +20 -1
- package/src/tooling.test.mjs +11 -2
- package/tests/agent_board_717_message_replay_scope.test.sql +39 -2
- package/tests/agent_board_717_tasking_replay_scope.test.sql +21 -2
- package/tests/agent_board_membership_removal_state.test.sql +228 -0
- package/tests/agent_board_role_guard.test.sql +3 -1
- package/tests/agent_board_send_outcome.test.sql +39 -1
- package/tests/agent_board_session_identity_approval_revocation.test.sql +5 -0
- package/tests/agent_board_step_up.test.sql +991 -0
- package/tests/agent_board_step_up_helper.test.sql +132 -28
- package/tests/agent_board_thread_key_guards.test.sql +186 -0
- package/tests/agent_board_thread_key_serialize.test.sql +182 -0
- package/tests/agent_board_write_enforcement_class.test.sql +3 -2
- package/tests/catalog/step_up_gated_closure.json +24 -0
- package/tests/fixtures/pgtap-unexposed.sql +9 -4
- package/tests/isolation/expected/create_or_find_thread_same_key_race.out +641 -0
- package/tests/isolation/expected/session_identity_links.out +4 -0
- package/tests/isolation/specs/create_or_find_thread_same_key_race.spec +252 -0
- package/tests/isolation/specs/session_identity_links.spec +5 -0
- package/tests/mutations/669/run.sh +12 -4
- package/tests/mutations/669b/M11_ceil_first.sql +10 -0
- package/tests/mutations/669b/M11_gate_first.sql +10 -0
- package/tests/mutations/669b/M11_grant_first.sql +10 -0
- package/tests/mutations/669b/M11_inv_first.sql +10 -0
- package/tests/mutations/669b/M11_mem_first.sql +10 -0
- package/tests/mutations/669b/M11_readmit_first.sql +10 -0
- package/tests/mutations/669b/M13a_gate_member_preset.sql +12 -0
- package/tests/mutations/669b/M13b_ungate_admin_preset.sql +12 -0
- package/tests/mutations/669b/M16_actor_is_target.sql +14 -0
- package/tests/mutations/669b/M19_drop_readmit.sql +9 -0
- package/tests/mutations/669b/M1_drop_grant.sql +9 -0
- package/tests/mutations/669b/M20_drop_d5_refusal.sql +9 -0
- package/tests/mutations/669b/M21_drop_removal.sql +9 -0
- package/tests/mutations/669b/M21b_only_removed.sql +9 -0
- package/tests/mutations/669b/M21c_gate_members.sql +12 -0
- package/tests/mutations/669b/M21d_requested_state.sql +9 -0
- package/tests/mutations/669b/M23b_api_wrapper_over_audit_writer.sql +6 -0
- package/tests/mutations/669b/M23c_drop_register_type_refusal.sql +9 -0
- package/tests/mutations/669b/M24_drop_kind_refusal.sql +9 -0
- package/tests/mutations/669b/M24b_drop_auth_bind_refusal.sql +9 -0
- package/tests/mutations/669b/M2a_drop_gate.sql +9 -0
- package/tests/mutations/669b/M2b_drop_ceiling.sql +9 -0
- package/tests/mutations/669b/M2c_drop_invite.sql +9 -0
- package/tests/mutations/669b/MAL2_drop_otp.sql +9 -0
- package/tests/mutations/669b/MAL3_admit_passkey.sql +9 -0
- package/tests/mutations/669b/MD7a_no_revocation.sql +2 -0
- package/tests/mutations/669b/MD7b_overwrite_revoked.sql +2 -0
- package/tests/mutations/669b/MD7c_revoke_members.sql +2 -0
- package/tests/mutations/669b/MD7d_revoke_expired.sql +2 -0
- package/tests/mutations/669b/ME1_wrapper_over_gate.sql +7 -0
- package/tests/mutations/669b/MEC2_write_after_helper.sql +10 -0
- package/tests/mutations/669b/MQX_query_to_xml_definer.sql +6 -0
- package/tests/mutations/669b/MQXb_ts_stat_other_schema.sql +4 -0
- package/tests/mutations/669b/MTR_trigger_route.sql +9 -0
- package/tests/mutations/669b/MTRb_new_assign.sql +11 -0
- package/tests/mutations/669b/MTRc_sync_assigns_value.sql +47 -0
- package/tests/mutations/669b/MTX1_tombstone_second_gated_call.sql +15 -0
- package/tests/mutations/669b/MTX2_tombstone_non_delegate_target.sql +10 -0
- package/tests/mutations/669b/MXS_other_schema_names_gated.sql +5 -0
- package/tests/mutations/669b/run.sh +83 -0
- package/tests/mutations/670/M18a_read_operation_default_dropped.sql +11 -0
- package/tests/mutations/670/M18b_read_operation_default_changed.sql +7 -0
- package/tests/mutations/670/M3-DM_helper_on_replay_branch.sql +10 -0
- package/tests/mutations/670/M3-MC_helper_on_replay_branch.sql +10 -0
- package/tests/mutations/s12/M0_identity.sql +56 -0
- package/tests/mutations/s12/M1_serialise_actor_key.sql +57 -0
- package/tests/mutations/s12/M1b_serialise_key_only.sql +57 -0
- package/tests/mutations/s12/M2_unique_index_no_handler.sql +9 -0
- package/tests/mutations/s12/M3_no_trim.sql +56 -0
- package/tests/mutations/s12/M4_casefold.sql +56 -0
- package/tests/mutations/s12/M5_lookup_ignores_actor.sql +56 -0
- package/tests/mutations/s12/M6_reuse_reports_false.sql +56 -0
- package/tests/mutations/s12/run.sh +112 -0
- package/tests/mutations/s12-fix/M0_identity.sql +83 -0
- package/tests/mutations/s12-fix/M10_security_invoker.sql +9 -0
- package/tests/mutations/s12-fix/M11_search_path_changed.sql +9 -0
- package/tests/mutations/s12-fix/M12_reuse_writes_task.sql +84 -0
- package/tests/mutations/s12-fix/M13_dead_inbox_write.sql +84 -0
- package/tests/mutations/s12-fix/M14_metadata_unchecked.sql +78 -0
- package/tests/mutations/s12-fix/M15_metadata_check_after_lock.sql +84 -0
- package/tests/mutations/s12-fix/M16_sql_null_metadata_refused.sql +83 -0
- package/tests/mutations/s12-fix/M17_isolation_unchecked.sql +70 -0
- package/tests/mutations/s12-fix/M18_isolation_check_after_lock.sql +82 -0
- package/tests/mutations/s12-fix/M19_isolation_rr_only.sql +83 -0
- package/tests/mutations/s12-fix/M1_lock_dropped.sql +78 -0
- package/tests/mutations/s12-fix/M1b_lock_key_only.sql +83 -0
- package/tests/mutations/s12-fix/M20_isolation_unsafe_levels_only.sql +83 -0
- package/tests/mutations/s12-fix/M21_isolation_check_miss_path_only.sql +83 -0
- package/tests/mutations/s12-fix/M22_isolation_inverted.sql +83 -0
- package/tests/mutations/s12-fix/M23_isolation_wrong_sqlstate.sql +83 -0
- package/tests/mutations/s12-fix/M24_create_thread_key_unchecked.sql +37 -0
- package/tests/mutations/s12-fix/M25_create_thread_key_nonnull_only.sql +45 -0
- package/tests/mutations/s12-fix/M26_create_thread_key_casefold.sql +45 -0
- package/tests/mutations/s12-fix/M27_create_thread_no_object_guard.sql +45 -0
- package/tests/mutations/s12-fix/M28_create_thread_key_stripped.sql +40 -0
- package/tests/mutations/s12-fix/M29_create_thread_key_nested_refused.sql +45 -0
- package/tests/mutations/s12-fix/M2_lock_actor_only.sql +83 -0
- package/tests/mutations/s12-fix/M30_create_thread_security_invoker.sql +9 -0
- package/tests/mutations/s12-fix/M31_create_thread_search_path_changed.sql +9 -0
- package/tests/mutations/s12-fix/M32_class_new_thread_inserter.sql +14 -0
- package/tests/mutations/s12-fix/M33_class_metadata_update.sql +12 -0
- package/tests/mutations/s12-fix/M33b_class_metadata_update_upper.sql +17 -0
- package/tests/mutations/s12-fix/M33c_class_metadata_update_row_form.sql +16 -0
- package/tests/mutations/s12-fix/M33d_class_metadata_merge_update.sql +16 -0
- package/tests/mutations/s12-fix/M33e_class_metadata_upsert.sql +16 -0
- package/tests/mutations/s12-fix/M34_class_api_role_insert.sql +9 -0
- package/tests/mutations/s12-fix/M3_lock_after_lookup.sql +83 -0
- package/tests/mutations/s12-fix/M4_lock_raw_key.sql +83 -0
- package/tests/mutations/s12-fix/M5_no_trim.sql +83 -0
- package/tests/mutations/s12-fix/M6_casefold.sql +83 -0
- package/tests/mutations/s12-fix/M7_lookup_ignores_actor.sql +82 -0
- package/tests/mutations/s12-fix/M8_reuse_reports_false.sql +83 -0
- package/tests/mutations/s12-fix/M9_blank_key_admitted.sql +83 -0
- package/tests/mutations/s12-fix/run.sh +288 -0
- package/tests/seeds/20261124000100_agent_board_step_up_enforcement.sql.pre.sql +47 -0
|
@@ -12,7 +12,9 @@
|
|
|
12
12
|
-- it there. So an existing install in any other schema is relocated if this session may
|
|
13
13
|
-- (`ALTER EXTENSION … SET SCHEMA` needs the extension's owner; pgtap.control is relocatable = true),
|
|
14
14
|
-- and otherwise REFUSED with the command that resolves it. It is never dropped: a shared cluster's
|
|
15
|
-
-- other tenants may be using it.
|
|
15
|
+
-- other tenants may be using it. Relocation is DATABASE-wide, not session-wide: on a shared cluster
|
|
16
|
+
-- it also moves pgTAP for every other tenant of that database, whose unqualified pgTAP calls then
|
|
17
|
+
-- resolve only if `extensions` is on their search_path too (message-board#764 N6).
|
|
16
18
|
--
|
|
17
19
|
-- The post-conditions are checked, not assumed: pgTAP ends in `extensions`, and resolves on this
|
|
18
20
|
-- session's search_path (the 90-odd test files that set no search_path rely on the role default).
|
|
@@ -52,10 +54,13 @@ begin
|
|
|
52
54
|
raise exception 'pgTAP post-condition failed: extension schema is %, expected extensions', coalesce(v_schema, '<absent>')
|
|
53
55
|
using errcode = '55000';
|
|
54
56
|
end if;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
+
-- `is null` was not enough: a second pgTAP-shaped plan(integer) earlier on the search_path
|
|
58
|
+
-- resolves too, and the tests would then run against it (message-board#764).
|
|
59
|
+
if to_regprocedure('plan(integer)') is distinct from 'extensions.plan(integer)'::regprocedure then
|
|
60
|
+
raise exception 'pgTAP post-condition failed: plan(integer) resolves to % on search_path %, expected extensions.plan(integer)',
|
|
61
|
+
coalesce(to_regprocedure('plan(integer)')::text, '<unresolved>'), current_setting('search_path')
|
|
57
62
|
using errcode = '55000',
|
|
58
|
-
hint = 'Put extensions on this role''s search_path (Supabase sets "$user", public, extensions for postgres).';
|
|
63
|
+
hint = 'Put extensions on this role''s search_path ahead of any other schema defining plan(integer) (Supabase sets "$user", public, extensions for postgres).';
|
|
59
64
|
end if;
|
|
60
65
|
end
|
|
61
66
|
$pgtap$;
|
|
@@ -0,0 +1,641 @@
|
|
|
1
|
+
Parsed test spec with 5 sessions
|
|
2
|
+
|
|
3
|
+
starting permutation: s1_begin s1_call s2_begin s2_call s1_commit s2_commit check
|
|
4
|
+
step s1_begin: BEGIN; SET LOCAL "request.jwt.claim.role" = 'service_role';
|
|
5
|
+
step s1_call:
|
|
6
|
+
insert into public.s12_results(session, thread_id, reused)
|
|
7
|
+
select 's1', t.thread_id, t.reused
|
|
8
|
+
from agent_board.create_or_find_thread(
|
|
9
|
+
'b5120000-0000-4000-8000-00000000000a', 'S-12 subject', 's12-key') t
|
|
10
|
+
returning session, reused;
|
|
11
|
+
|
|
12
|
+
session|reused
|
|
13
|
+
-------+------
|
|
14
|
+
s1 |f
|
|
15
|
+
(1 row)
|
|
16
|
+
|
|
17
|
+
step s2_begin: BEGIN; SET LOCAL "request.jwt.claim.role" = 'service_role';
|
|
18
|
+
step s2_call:
|
|
19
|
+
insert into public.s12_results(session, thread_id, reused)
|
|
20
|
+
select 's2', t.thread_id, t.reused
|
|
21
|
+
from agent_board.create_or_find_thread(
|
|
22
|
+
'b5120000-0000-4000-8000-00000000000a', 'S-12 subject', 's12-key') t
|
|
23
|
+
returning session, reused;
|
|
24
|
+
<waiting ...>
|
|
25
|
+
step s1_commit: COMMIT;
|
|
26
|
+
step s2_call: <... completed>
|
|
27
|
+
session|reused
|
|
28
|
+
-------+------
|
|
29
|
+
s2 |t
|
|
30
|
+
(1 row)
|
|
31
|
+
|
|
32
|
+
step s2_commit: COMMIT;
|
|
33
|
+
step check:
|
|
34
|
+
select (select count(*)::int from agent_board.threads t
|
|
35
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a'
|
|
36
|
+
and t.metadata ->> 'addressingThreadKey' = 's12-key') as threads,
|
|
37
|
+
(select count(distinct r.thread_id)::int from public.s12_results r
|
|
38
|
+
where r.session in ('s1','s2')) as distinct_ids,
|
|
39
|
+
(select string_agg(r.session || '=' || r.reused::text, ',' order by r.session)
|
|
40
|
+
from public.s12_results r) as reused_flags,
|
|
41
|
+
(select count(*)::int from agent_board.threads t
|
|
42
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a'
|
|
43
|
+
and t.metadata ->> 'addressingThreadKey' = 's12-key'
|
|
44
|
+
and t.id not in (select r.thread_id from public.s12_results r)) as orphans,
|
|
45
|
+
(select string_agg(t.metadata ->> 'addressingThreadKey', ',' order by t.metadata ->> 'addressingThreadKey')
|
|
46
|
+
from agent_board.threads t
|
|
47
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a') as actor_a_keys,
|
|
48
|
+
(select count(*)::int from agent_board.threads t
|
|
49
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000b') as actor_b_threads,
|
|
50
|
+
(select bool_and(r3.thread_id <> r1.thread_id)
|
|
51
|
+
from public.s12_results r1, public.s12_results r3
|
|
52
|
+
where r1.session = 's1' and r3.session = 's3') as other_actor_distinct;
|
|
53
|
+
|
|
54
|
+
threads|distinct_ids|reused_flags |orphans|actor_a_keys|actor_b_threads|other_actor_distinct
|
|
55
|
+
-------+------------+----------------+-------+------------+---------------+--------------------
|
|
56
|
+
1| 1|s1=false,s2=true| 0|s12-key | 0|
|
|
57
|
+
(1 row)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
starting permutation: s1_begin s1_call s2_begin s2_call_padded s1_commit s2_commit check
|
|
61
|
+
step s1_begin: BEGIN; SET LOCAL "request.jwt.claim.role" = 'service_role';
|
|
62
|
+
step s1_call:
|
|
63
|
+
insert into public.s12_results(session, thread_id, reused)
|
|
64
|
+
select 's1', t.thread_id, t.reused
|
|
65
|
+
from agent_board.create_or_find_thread(
|
|
66
|
+
'b5120000-0000-4000-8000-00000000000a', 'S-12 subject', 's12-key') t
|
|
67
|
+
returning session, reused;
|
|
68
|
+
|
|
69
|
+
session|reused
|
|
70
|
+
-------+------
|
|
71
|
+
s1 |f
|
|
72
|
+
(1 row)
|
|
73
|
+
|
|
74
|
+
step s2_begin: BEGIN; SET LOCAL "request.jwt.claim.role" = 'service_role';
|
|
75
|
+
step s2_call_padded:
|
|
76
|
+
insert into public.s12_results(session, thread_id, reused)
|
|
77
|
+
select 's2', t.thread_id, t.reused
|
|
78
|
+
from agent_board.create_or_find_thread(
|
|
79
|
+
'b5120000-0000-4000-8000-00000000000a', 'S-12 subject', ' s12-key ') t
|
|
80
|
+
returning session, reused;
|
|
81
|
+
<waiting ...>
|
|
82
|
+
step s1_commit: COMMIT;
|
|
83
|
+
step s2_call_padded: <... completed>
|
|
84
|
+
session|reused
|
|
85
|
+
-------+------
|
|
86
|
+
s2 |t
|
|
87
|
+
(1 row)
|
|
88
|
+
|
|
89
|
+
step s2_commit: COMMIT;
|
|
90
|
+
step check:
|
|
91
|
+
select (select count(*)::int from agent_board.threads t
|
|
92
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a'
|
|
93
|
+
and t.metadata ->> 'addressingThreadKey' = 's12-key') as threads,
|
|
94
|
+
(select count(distinct r.thread_id)::int from public.s12_results r
|
|
95
|
+
where r.session in ('s1','s2')) as distinct_ids,
|
|
96
|
+
(select string_agg(r.session || '=' || r.reused::text, ',' order by r.session)
|
|
97
|
+
from public.s12_results r) as reused_flags,
|
|
98
|
+
(select count(*)::int from agent_board.threads t
|
|
99
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a'
|
|
100
|
+
and t.metadata ->> 'addressingThreadKey' = 's12-key'
|
|
101
|
+
and t.id not in (select r.thread_id from public.s12_results r)) as orphans,
|
|
102
|
+
(select string_agg(t.metadata ->> 'addressingThreadKey', ',' order by t.metadata ->> 'addressingThreadKey')
|
|
103
|
+
from agent_board.threads t
|
|
104
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a') as actor_a_keys,
|
|
105
|
+
(select count(*)::int from agent_board.threads t
|
|
106
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000b') as actor_b_threads,
|
|
107
|
+
(select bool_and(r3.thread_id <> r1.thread_id)
|
|
108
|
+
from public.s12_results r1, public.s12_results r3
|
|
109
|
+
where r1.session = 's1' and r3.session = 's3') as other_actor_distinct;
|
|
110
|
+
|
|
111
|
+
threads|distinct_ids|reused_flags |orphans|actor_a_keys|actor_b_threads|other_actor_distinct
|
|
112
|
+
-------+------------+----------------+-------+------------+---------------+--------------------
|
|
113
|
+
1| 1|s1=false,s2=true| 0|s12-key | 0|
|
|
114
|
+
(1 row)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
starting permutation: s1_begin s1_call s1_commit s2_begin s2_call_padded s2_commit check
|
|
118
|
+
step s1_begin: BEGIN; SET LOCAL "request.jwt.claim.role" = 'service_role';
|
|
119
|
+
step s1_call:
|
|
120
|
+
insert into public.s12_results(session, thread_id, reused)
|
|
121
|
+
select 's1', t.thread_id, t.reused
|
|
122
|
+
from agent_board.create_or_find_thread(
|
|
123
|
+
'b5120000-0000-4000-8000-00000000000a', 'S-12 subject', 's12-key') t
|
|
124
|
+
returning session, reused;
|
|
125
|
+
|
|
126
|
+
session|reused
|
|
127
|
+
-------+------
|
|
128
|
+
s1 |f
|
|
129
|
+
(1 row)
|
|
130
|
+
|
|
131
|
+
step s1_commit: COMMIT;
|
|
132
|
+
step s2_begin: BEGIN; SET LOCAL "request.jwt.claim.role" = 'service_role';
|
|
133
|
+
step s2_call_padded:
|
|
134
|
+
insert into public.s12_results(session, thread_id, reused)
|
|
135
|
+
select 's2', t.thread_id, t.reused
|
|
136
|
+
from agent_board.create_or_find_thread(
|
|
137
|
+
'b5120000-0000-4000-8000-00000000000a', 'S-12 subject', ' s12-key ') t
|
|
138
|
+
returning session, reused;
|
|
139
|
+
|
|
140
|
+
session|reused
|
|
141
|
+
-------+------
|
|
142
|
+
s2 |t
|
|
143
|
+
(1 row)
|
|
144
|
+
|
|
145
|
+
step s2_commit: COMMIT;
|
|
146
|
+
step check:
|
|
147
|
+
select (select count(*)::int from agent_board.threads t
|
|
148
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a'
|
|
149
|
+
and t.metadata ->> 'addressingThreadKey' = 's12-key') as threads,
|
|
150
|
+
(select count(distinct r.thread_id)::int from public.s12_results r
|
|
151
|
+
where r.session in ('s1','s2')) as distinct_ids,
|
|
152
|
+
(select string_agg(r.session || '=' || r.reused::text, ',' order by r.session)
|
|
153
|
+
from public.s12_results r) as reused_flags,
|
|
154
|
+
(select count(*)::int from agent_board.threads t
|
|
155
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a'
|
|
156
|
+
and t.metadata ->> 'addressingThreadKey' = 's12-key'
|
|
157
|
+
and t.id not in (select r.thread_id from public.s12_results r)) as orphans,
|
|
158
|
+
(select string_agg(t.metadata ->> 'addressingThreadKey', ',' order by t.metadata ->> 'addressingThreadKey')
|
|
159
|
+
from agent_board.threads t
|
|
160
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a') as actor_a_keys,
|
|
161
|
+
(select count(*)::int from agent_board.threads t
|
|
162
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000b') as actor_b_threads,
|
|
163
|
+
(select bool_and(r3.thread_id <> r1.thread_id)
|
|
164
|
+
from public.s12_results r1, public.s12_results r3
|
|
165
|
+
where r1.session = 's1' and r3.session = 's3') as other_actor_distinct;
|
|
166
|
+
|
|
167
|
+
threads|distinct_ids|reused_flags |orphans|actor_a_keys|actor_b_threads|other_actor_distinct
|
|
168
|
+
-------+------------+----------------+-------+------------+---------------+--------------------
|
|
169
|
+
1| 1|s1=false,s2=true| 0|s12-key | 0|
|
|
170
|
+
(1 row)
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
starting permutation: s1_begin s1_call s1_commit s2_begin s2_call_upper s2_commit check
|
|
174
|
+
step s1_begin: BEGIN; SET LOCAL "request.jwt.claim.role" = 'service_role';
|
|
175
|
+
step s1_call:
|
|
176
|
+
insert into public.s12_results(session, thread_id, reused)
|
|
177
|
+
select 's1', t.thread_id, t.reused
|
|
178
|
+
from agent_board.create_or_find_thread(
|
|
179
|
+
'b5120000-0000-4000-8000-00000000000a', 'S-12 subject', 's12-key') t
|
|
180
|
+
returning session, reused;
|
|
181
|
+
|
|
182
|
+
session|reused
|
|
183
|
+
-------+------
|
|
184
|
+
s1 |f
|
|
185
|
+
(1 row)
|
|
186
|
+
|
|
187
|
+
step s1_commit: COMMIT;
|
|
188
|
+
step s2_begin: BEGIN; SET LOCAL "request.jwt.claim.role" = 'service_role';
|
|
189
|
+
step s2_call_upper:
|
|
190
|
+
insert into public.s12_results(session, thread_id, reused)
|
|
191
|
+
select 's2', t.thread_id, t.reused
|
|
192
|
+
from agent_board.create_or_find_thread(
|
|
193
|
+
'b5120000-0000-4000-8000-00000000000a', 'S-12 subject', 'S12-KEY') t
|
|
194
|
+
returning session, reused;
|
|
195
|
+
|
|
196
|
+
session|reused
|
|
197
|
+
-------+------
|
|
198
|
+
s2 |f
|
|
199
|
+
(1 row)
|
|
200
|
+
|
|
201
|
+
step s2_commit: COMMIT;
|
|
202
|
+
step check:
|
|
203
|
+
select (select count(*)::int from agent_board.threads t
|
|
204
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a'
|
|
205
|
+
and t.metadata ->> 'addressingThreadKey' = 's12-key') as threads,
|
|
206
|
+
(select count(distinct r.thread_id)::int from public.s12_results r
|
|
207
|
+
where r.session in ('s1','s2')) as distinct_ids,
|
|
208
|
+
(select string_agg(r.session || '=' || r.reused::text, ',' order by r.session)
|
|
209
|
+
from public.s12_results r) as reused_flags,
|
|
210
|
+
(select count(*)::int from agent_board.threads t
|
|
211
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a'
|
|
212
|
+
and t.metadata ->> 'addressingThreadKey' = 's12-key'
|
|
213
|
+
and t.id not in (select r.thread_id from public.s12_results r)) as orphans,
|
|
214
|
+
(select string_agg(t.metadata ->> 'addressingThreadKey', ',' order by t.metadata ->> 'addressingThreadKey')
|
|
215
|
+
from agent_board.threads t
|
|
216
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a') as actor_a_keys,
|
|
217
|
+
(select count(*)::int from agent_board.threads t
|
|
218
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000b') as actor_b_threads,
|
|
219
|
+
(select bool_and(r3.thread_id <> r1.thread_id)
|
|
220
|
+
from public.s12_results r1, public.s12_results r3
|
|
221
|
+
where r1.session = 's1' and r3.session = 's3') as other_actor_distinct;
|
|
222
|
+
|
|
223
|
+
threads|distinct_ids|reused_flags |orphans|actor_a_keys |actor_b_threads|other_actor_distinct
|
|
224
|
+
-------+------------+-----------------+-------+---------------+---------------+--------------------
|
|
225
|
+
1| 2|s1=false,s2=false| 0|s12-key,S12-KEY| 0|
|
|
226
|
+
(1 row)
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
starting permutation: s1_begin s1_call s3_begin s3_call_other_actor s1_commit s3_commit check
|
|
230
|
+
step s1_begin: BEGIN; SET LOCAL "request.jwt.claim.role" = 'service_role';
|
|
231
|
+
step s1_call:
|
|
232
|
+
insert into public.s12_results(session, thread_id, reused)
|
|
233
|
+
select 's1', t.thread_id, t.reused
|
|
234
|
+
from agent_board.create_or_find_thread(
|
|
235
|
+
'b5120000-0000-4000-8000-00000000000a', 'S-12 subject', 's12-key') t
|
|
236
|
+
returning session, reused;
|
|
237
|
+
|
|
238
|
+
session|reused
|
|
239
|
+
-------+------
|
|
240
|
+
s1 |f
|
|
241
|
+
(1 row)
|
|
242
|
+
|
|
243
|
+
step s3_begin: BEGIN; SET LOCAL "request.jwt.claim.role" = 'service_role';
|
|
244
|
+
step s3_call_other_actor:
|
|
245
|
+
insert into public.s12_results(session, thread_id, reused)
|
|
246
|
+
select 's3', t.thread_id, t.reused
|
|
247
|
+
from agent_board.create_or_find_thread(
|
|
248
|
+
'b5120000-0000-4000-8000-00000000000b', 'S-12 subject', 's12-key') t
|
|
249
|
+
returning session, reused;
|
|
250
|
+
|
|
251
|
+
session|reused
|
|
252
|
+
-------+------
|
|
253
|
+
s3 |f
|
|
254
|
+
(1 row)
|
|
255
|
+
|
|
256
|
+
step s1_commit: COMMIT;
|
|
257
|
+
step s3_commit: COMMIT;
|
|
258
|
+
step check:
|
|
259
|
+
select (select count(*)::int from agent_board.threads t
|
|
260
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a'
|
|
261
|
+
and t.metadata ->> 'addressingThreadKey' = 's12-key') as threads,
|
|
262
|
+
(select count(distinct r.thread_id)::int from public.s12_results r
|
|
263
|
+
where r.session in ('s1','s2')) as distinct_ids,
|
|
264
|
+
(select string_agg(r.session || '=' || r.reused::text, ',' order by r.session)
|
|
265
|
+
from public.s12_results r) as reused_flags,
|
|
266
|
+
(select count(*)::int from agent_board.threads t
|
|
267
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a'
|
|
268
|
+
and t.metadata ->> 'addressingThreadKey' = 's12-key'
|
|
269
|
+
and t.id not in (select r.thread_id from public.s12_results r)) as orphans,
|
|
270
|
+
(select string_agg(t.metadata ->> 'addressingThreadKey', ',' order by t.metadata ->> 'addressingThreadKey')
|
|
271
|
+
from agent_board.threads t
|
|
272
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a') as actor_a_keys,
|
|
273
|
+
(select count(*)::int from agent_board.threads t
|
|
274
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000b') as actor_b_threads,
|
|
275
|
+
(select bool_and(r3.thread_id <> r1.thread_id)
|
|
276
|
+
from public.s12_results r1, public.s12_results r3
|
|
277
|
+
where r1.session = 's1' and r3.session = 's3') as other_actor_distinct;
|
|
278
|
+
|
|
279
|
+
threads|distinct_ids|reused_flags |orphans|actor_a_keys|actor_b_threads|other_actor_distinct
|
|
280
|
+
-------+------------+-----------------+-------+------------+---------------+--------------------
|
|
281
|
+
1| 1|s1=false,s3=false| 0|s12-key | 1|t
|
|
282
|
+
(1 row)
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
starting permutation: s1_begin s1_call s1_commit s3_begin s3_call_other_actor s3_commit check
|
|
286
|
+
step s1_begin: BEGIN; SET LOCAL "request.jwt.claim.role" = 'service_role';
|
|
287
|
+
step s1_call:
|
|
288
|
+
insert into public.s12_results(session, thread_id, reused)
|
|
289
|
+
select 's1', t.thread_id, t.reused
|
|
290
|
+
from agent_board.create_or_find_thread(
|
|
291
|
+
'b5120000-0000-4000-8000-00000000000a', 'S-12 subject', 's12-key') t
|
|
292
|
+
returning session, reused;
|
|
293
|
+
|
|
294
|
+
session|reused
|
|
295
|
+
-------+------
|
|
296
|
+
s1 |f
|
|
297
|
+
(1 row)
|
|
298
|
+
|
|
299
|
+
step s1_commit: COMMIT;
|
|
300
|
+
step s3_begin: BEGIN; SET LOCAL "request.jwt.claim.role" = 'service_role';
|
|
301
|
+
step s3_call_other_actor:
|
|
302
|
+
insert into public.s12_results(session, thread_id, reused)
|
|
303
|
+
select 's3', t.thread_id, t.reused
|
|
304
|
+
from agent_board.create_or_find_thread(
|
|
305
|
+
'b5120000-0000-4000-8000-00000000000b', 'S-12 subject', 's12-key') t
|
|
306
|
+
returning session, reused;
|
|
307
|
+
|
|
308
|
+
session|reused
|
|
309
|
+
-------+------
|
|
310
|
+
s3 |f
|
|
311
|
+
(1 row)
|
|
312
|
+
|
|
313
|
+
step s3_commit: COMMIT;
|
|
314
|
+
step check:
|
|
315
|
+
select (select count(*)::int from agent_board.threads t
|
|
316
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a'
|
|
317
|
+
and t.metadata ->> 'addressingThreadKey' = 's12-key') as threads,
|
|
318
|
+
(select count(distinct r.thread_id)::int from public.s12_results r
|
|
319
|
+
where r.session in ('s1','s2')) as distinct_ids,
|
|
320
|
+
(select string_agg(r.session || '=' || r.reused::text, ',' order by r.session)
|
|
321
|
+
from public.s12_results r) as reused_flags,
|
|
322
|
+
(select count(*)::int from agent_board.threads t
|
|
323
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a'
|
|
324
|
+
and t.metadata ->> 'addressingThreadKey' = 's12-key'
|
|
325
|
+
and t.id not in (select r.thread_id from public.s12_results r)) as orphans,
|
|
326
|
+
(select string_agg(t.metadata ->> 'addressingThreadKey', ',' order by t.metadata ->> 'addressingThreadKey')
|
|
327
|
+
from agent_board.threads t
|
|
328
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a') as actor_a_keys,
|
|
329
|
+
(select count(*)::int from agent_board.threads t
|
|
330
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000b') as actor_b_threads,
|
|
331
|
+
(select bool_and(r3.thread_id <> r1.thread_id)
|
|
332
|
+
from public.s12_results r1, public.s12_results r3
|
|
333
|
+
where r1.session = 's1' and r3.session = 's3') as other_actor_distinct;
|
|
334
|
+
|
|
335
|
+
threads|distinct_ids|reused_flags |orphans|actor_a_keys|actor_b_threads|other_actor_distinct
|
|
336
|
+
-------+------------+-----------------+-------+------------+---------------+--------------------
|
|
337
|
+
1| 1|s1=false,s3=false| 0|s12-key | 1|t
|
|
338
|
+
(1 row)
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
starting permutation: s1_begin s1_call s2_begin s2_call_array s1_commit s2_commit check
|
|
342
|
+
step s1_begin: BEGIN; SET LOCAL "request.jwt.claim.role" = 'service_role';
|
|
343
|
+
step s1_call:
|
|
344
|
+
insert into public.s12_results(session, thread_id, reused)
|
|
345
|
+
select 's1', t.thread_id, t.reused
|
|
346
|
+
from agent_board.create_or_find_thread(
|
|
347
|
+
'b5120000-0000-4000-8000-00000000000a', 'S-12 subject', 's12-key') t
|
|
348
|
+
returning session, reused;
|
|
349
|
+
|
|
350
|
+
session|reused
|
|
351
|
+
-------+------
|
|
352
|
+
s1 |f
|
|
353
|
+
(1 row)
|
|
354
|
+
|
|
355
|
+
step s2_begin: BEGIN; SET LOCAL "request.jwt.claim.role" = 'service_role';
|
|
356
|
+
step s2_call_array:
|
|
357
|
+
insert into public.s12_results(session, thread_id, reused)
|
|
358
|
+
select 's2', t.thread_id, t.reused
|
|
359
|
+
from agent_board.create_or_find_thread(
|
|
360
|
+
'b5120000-0000-4000-8000-00000000000a', 'S-12 subject', 's12-key', 'coordination', '[]'::jsonb) t
|
|
361
|
+
returning session, reused;
|
|
362
|
+
|
|
363
|
+
ERROR: metadata must be a JSON object
|
|
364
|
+
step s1_commit: COMMIT;
|
|
365
|
+
step s2_commit: COMMIT;
|
|
366
|
+
step check:
|
|
367
|
+
select (select count(*)::int from agent_board.threads t
|
|
368
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a'
|
|
369
|
+
and t.metadata ->> 'addressingThreadKey' = 's12-key') as threads,
|
|
370
|
+
(select count(distinct r.thread_id)::int from public.s12_results r
|
|
371
|
+
where r.session in ('s1','s2')) as distinct_ids,
|
|
372
|
+
(select string_agg(r.session || '=' || r.reused::text, ',' order by r.session)
|
|
373
|
+
from public.s12_results r) as reused_flags,
|
|
374
|
+
(select count(*)::int from agent_board.threads t
|
|
375
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a'
|
|
376
|
+
and t.metadata ->> 'addressingThreadKey' = 's12-key'
|
|
377
|
+
and t.id not in (select r.thread_id from public.s12_results r)) as orphans,
|
|
378
|
+
(select string_agg(t.metadata ->> 'addressingThreadKey', ',' order by t.metadata ->> 'addressingThreadKey')
|
|
379
|
+
from agent_board.threads t
|
|
380
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a') as actor_a_keys,
|
|
381
|
+
(select count(*)::int from agent_board.threads t
|
|
382
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000b') as actor_b_threads,
|
|
383
|
+
(select bool_and(r3.thread_id <> r1.thread_id)
|
|
384
|
+
from public.s12_results r1, public.s12_results r3
|
|
385
|
+
where r1.session = 's1' and r3.session = 's3') as other_actor_distinct;
|
|
386
|
+
|
|
387
|
+
threads|distinct_ids|reused_flags|orphans|actor_a_keys|actor_b_threads|other_actor_distinct
|
|
388
|
+
-------+------------+------------+-------+------------+---------------+--------------------
|
|
389
|
+
1| 1|s1=false | 0|s12-key | 0|
|
|
390
|
+
(1 row)
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
starting permutation: s1_begin s1_call s4_begin_rr s4_call s1_commit s4_rollback check
|
|
394
|
+
step s1_begin: BEGIN; SET LOCAL "request.jwt.claim.role" = 'service_role';
|
|
395
|
+
step s1_call:
|
|
396
|
+
insert into public.s12_results(session, thread_id, reused)
|
|
397
|
+
select 's1', t.thread_id, t.reused
|
|
398
|
+
from agent_board.create_or_find_thread(
|
|
399
|
+
'b5120000-0000-4000-8000-00000000000a', 'S-12 subject', 's12-key') t
|
|
400
|
+
returning session, reused;
|
|
401
|
+
|
|
402
|
+
session|reused
|
|
403
|
+
-------+------
|
|
404
|
+
s1 |f
|
|
405
|
+
(1 row)
|
|
406
|
+
|
|
407
|
+
step s4_begin_rr: BEGIN ISOLATION LEVEL REPEATABLE READ; SET LOCAL "request.jwt.claim.role" = 'service_role';
|
|
408
|
+
step s4_call: select public.s12_level_call() as outcome;
|
|
409
|
+
outcome
|
|
410
|
+
--------------------------------------------------------------------------------------------------------------
|
|
411
|
+
refused 0A000: create_or_find_thread requires transaction isolation level read committed (got repeatable read)
|
|
412
|
+
(1 row)
|
|
413
|
+
|
|
414
|
+
step s1_commit: COMMIT;
|
|
415
|
+
step s4_rollback: ROLLBACK;
|
|
416
|
+
step check:
|
|
417
|
+
select (select count(*)::int from agent_board.threads t
|
|
418
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a'
|
|
419
|
+
and t.metadata ->> 'addressingThreadKey' = 's12-key') as threads,
|
|
420
|
+
(select count(distinct r.thread_id)::int from public.s12_results r
|
|
421
|
+
where r.session in ('s1','s2')) as distinct_ids,
|
|
422
|
+
(select string_agg(r.session || '=' || r.reused::text, ',' order by r.session)
|
|
423
|
+
from public.s12_results r) as reused_flags,
|
|
424
|
+
(select count(*)::int from agent_board.threads t
|
|
425
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a'
|
|
426
|
+
and t.metadata ->> 'addressingThreadKey' = 's12-key'
|
|
427
|
+
and t.id not in (select r.thread_id from public.s12_results r)) as orphans,
|
|
428
|
+
(select string_agg(t.metadata ->> 'addressingThreadKey', ',' order by t.metadata ->> 'addressingThreadKey')
|
|
429
|
+
from agent_board.threads t
|
|
430
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a') as actor_a_keys,
|
|
431
|
+
(select count(*)::int from agent_board.threads t
|
|
432
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000b') as actor_b_threads,
|
|
433
|
+
(select bool_and(r3.thread_id <> r1.thread_id)
|
|
434
|
+
from public.s12_results r1, public.s12_results r3
|
|
435
|
+
where r1.session = 's1' and r3.session = 's3') as other_actor_distinct;
|
|
436
|
+
|
|
437
|
+
threads|distinct_ids|reused_flags|orphans|actor_a_keys|actor_b_threads|other_actor_distinct
|
|
438
|
+
-------+------------+------------+-------+------------+---------------+--------------------
|
|
439
|
+
1| 1|s1=false | 0|s12-key | 0|
|
|
440
|
+
(1 row)
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
starting permutation: s1_begin s1_call s4_begin_sz s4_call s1_commit s4_rollback check
|
|
444
|
+
step s1_begin: BEGIN; SET LOCAL "request.jwt.claim.role" = 'service_role';
|
|
445
|
+
step s1_call:
|
|
446
|
+
insert into public.s12_results(session, thread_id, reused)
|
|
447
|
+
select 's1', t.thread_id, t.reused
|
|
448
|
+
from agent_board.create_or_find_thread(
|
|
449
|
+
'b5120000-0000-4000-8000-00000000000a', 'S-12 subject', 's12-key') t
|
|
450
|
+
returning session, reused;
|
|
451
|
+
|
|
452
|
+
session|reused
|
|
453
|
+
-------+------
|
|
454
|
+
s1 |f
|
|
455
|
+
(1 row)
|
|
456
|
+
|
|
457
|
+
step s4_begin_sz: BEGIN ISOLATION LEVEL SERIALIZABLE; SET LOCAL "request.jwt.claim.role" = 'service_role';
|
|
458
|
+
step s4_call: select public.s12_level_call() as outcome;
|
|
459
|
+
outcome
|
|
460
|
+
-----------------------------------------------------------------------------------------------------------
|
|
461
|
+
refused 0A000: create_or_find_thread requires transaction isolation level read committed (got serializable)
|
|
462
|
+
(1 row)
|
|
463
|
+
|
|
464
|
+
step s1_commit: COMMIT;
|
|
465
|
+
step s4_rollback: ROLLBACK;
|
|
466
|
+
step check:
|
|
467
|
+
select (select count(*)::int from agent_board.threads t
|
|
468
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a'
|
|
469
|
+
and t.metadata ->> 'addressingThreadKey' = 's12-key') as threads,
|
|
470
|
+
(select count(distinct r.thread_id)::int from public.s12_results r
|
|
471
|
+
where r.session in ('s1','s2')) as distinct_ids,
|
|
472
|
+
(select string_agg(r.session || '=' || r.reused::text, ',' order by r.session)
|
|
473
|
+
from public.s12_results r) as reused_flags,
|
|
474
|
+
(select count(*)::int from agent_board.threads t
|
|
475
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a'
|
|
476
|
+
and t.metadata ->> 'addressingThreadKey' = 's12-key'
|
|
477
|
+
and t.id not in (select r.thread_id from public.s12_results r)) as orphans,
|
|
478
|
+
(select string_agg(t.metadata ->> 'addressingThreadKey', ',' order by t.metadata ->> 'addressingThreadKey')
|
|
479
|
+
from agent_board.threads t
|
|
480
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a') as actor_a_keys,
|
|
481
|
+
(select count(*)::int from agent_board.threads t
|
|
482
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000b') as actor_b_threads,
|
|
483
|
+
(select bool_and(r3.thread_id <> r1.thread_id)
|
|
484
|
+
from public.s12_results r1, public.s12_results r3
|
|
485
|
+
where r1.session = 's1' and r3.session = 's3') as other_actor_distinct;
|
|
486
|
+
|
|
487
|
+
threads|distinct_ids|reused_flags|orphans|actor_a_keys|actor_b_threads|other_actor_distinct
|
|
488
|
+
-------+------------+------------+-------+------------+---------------+--------------------
|
|
489
|
+
1| 1|s1=false | 0|s12-key | 0|
|
|
490
|
+
(1 row)
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
starting permutation: s1_begin s1_call s4_begin_ru s4_call s1_commit s4_rollback check
|
|
494
|
+
step s1_begin: BEGIN; SET LOCAL "request.jwt.claim.role" = 'service_role';
|
|
495
|
+
step s1_call:
|
|
496
|
+
insert into public.s12_results(session, thread_id, reused)
|
|
497
|
+
select 's1', t.thread_id, t.reused
|
|
498
|
+
from agent_board.create_or_find_thread(
|
|
499
|
+
'b5120000-0000-4000-8000-00000000000a', 'S-12 subject', 's12-key') t
|
|
500
|
+
returning session, reused;
|
|
501
|
+
|
|
502
|
+
session|reused
|
|
503
|
+
-------+------
|
|
504
|
+
s1 |f
|
|
505
|
+
(1 row)
|
|
506
|
+
|
|
507
|
+
step s4_begin_ru: BEGIN ISOLATION LEVEL READ UNCOMMITTED; SET LOCAL "request.jwt.claim.role" = 'service_role';
|
|
508
|
+
step s4_call: select public.s12_level_call() as outcome;
|
|
509
|
+
outcome
|
|
510
|
+
---------------------------------------------------------------------------------------------------------------
|
|
511
|
+
refused 0A000: create_or_find_thread requires transaction isolation level read committed (got read uncommitted)
|
|
512
|
+
(1 row)
|
|
513
|
+
|
|
514
|
+
step s1_commit: COMMIT;
|
|
515
|
+
step s4_rollback: ROLLBACK;
|
|
516
|
+
step check:
|
|
517
|
+
select (select count(*)::int from agent_board.threads t
|
|
518
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a'
|
|
519
|
+
and t.metadata ->> 'addressingThreadKey' = 's12-key') as threads,
|
|
520
|
+
(select count(distinct r.thread_id)::int from public.s12_results r
|
|
521
|
+
where r.session in ('s1','s2')) as distinct_ids,
|
|
522
|
+
(select string_agg(r.session || '=' || r.reused::text, ',' order by r.session)
|
|
523
|
+
from public.s12_results r) as reused_flags,
|
|
524
|
+
(select count(*)::int from agent_board.threads t
|
|
525
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a'
|
|
526
|
+
and t.metadata ->> 'addressingThreadKey' = 's12-key'
|
|
527
|
+
and t.id not in (select r.thread_id from public.s12_results r)) as orphans,
|
|
528
|
+
(select string_agg(t.metadata ->> 'addressingThreadKey', ',' order by t.metadata ->> 'addressingThreadKey')
|
|
529
|
+
from agent_board.threads t
|
|
530
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a') as actor_a_keys,
|
|
531
|
+
(select count(*)::int from agent_board.threads t
|
|
532
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000b') as actor_b_threads,
|
|
533
|
+
(select bool_and(r3.thread_id <> r1.thread_id)
|
|
534
|
+
from public.s12_results r1, public.s12_results r3
|
|
535
|
+
where r1.session = 's1' and r3.session = 's3') as other_actor_distinct;
|
|
536
|
+
|
|
537
|
+
threads|distinct_ids|reused_flags|orphans|actor_a_keys|actor_b_threads|other_actor_distinct
|
|
538
|
+
-------+------------+------------+-------+------------+---------------+--------------------
|
|
539
|
+
1| 1|s1=false | 0|s12-key | 0|
|
|
540
|
+
(1 row)
|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
starting permutation: s1_begin s1_call s1_commit s4_begin_rr s4_call s4_rollback check
|
|
544
|
+
step s1_begin: BEGIN; SET LOCAL "request.jwt.claim.role" = 'service_role';
|
|
545
|
+
step s1_call:
|
|
546
|
+
insert into public.s12_results(session, thread_id, reused)
|
|
547
|
+
select 's1', t.thread_id, t.reused
|
|
548
|
+
from agent_board.create_or_find_thread(
|
|
549
|
+
'b5120000-0000-4000-8000-00000000000a', 'S-12 subject', 's12-key') t
|
|
550
|
+
returning session, reused;
|
|
551
|
+
|
|
552
|
+
session|reused
|
|
553
|
+
-------+------
|
|
554
|
+
s1 |f
|
|
555
|
+
(1 row)
|
|
556
|
+
|
|
557
|
+
step s1_commit: COMMIT;
|
|
558
|
+
step s4_begin_rr: BEGIN ISOLATION LEVEL REPEATABLE READ; SET LOCAL "request.jwt.claim.role" = 'service_role';
|
|
559
|
+
step s4_call: select public.s12_level_call() as outcome;
|
|
560
|
+
outcome
|
|
561
|
+
--------------------------------------------------------------------------------------------------------------
|
|
562
|
+
refused 0A000: create_or_find_thread requires transaction isolation level read committed (got repeatable read)
|
|
563
|
+
(1 row)
|
|
564
|
+
|
|
565
|
+
step s4_rollback: ROLLBACK;
|
|
566
|
+
step check:
|
|
567
|
+
select (select count(*)::int from agent_board.threads t
|
|
568
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a'
|
|
569
|
+
and t.metadata ->> 'addressingThreadKey' = 's12-key') as threads,
|
|
570
|
+
(select count(distinct r.thread_id)::int from public.s12_results r
|
|
571
|
+
where r.session in ('s1','s2')) as distinct_ids,
|
|
572
|
+
(select string_agg(r.session || '=' || r.reused::text, ',' order by r.session)
|
|
573
|
+
from public.s12_results r) as reused_flags,
|
|
574
|
+
(select count(*)::int from agent_board.threads t
|
|
575
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a'
|
|
576
|
+
and t.metadata ->> 'addressingThreadKey' = 's12-key'
|
|
577
|
+
and t.id not in (select r.thread_id from public.s12_results r)) as orphans,
|
|
578
|
+
(select string_agg(t.metadata ->> 'addressingThreadKey', ',' order by t.metadata ->> 'addressingThreadKey')
|
|
579
|
+
from agent_board.threads t
|
|
580
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a') as actor_a_keys,
|
|
581
|
+
(select count(*)::int from agent_board.threads t
|
|
582
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000b') as actor_b_threads,
|
|
583
|
+
(select bool_and(r3.thread_id <> r1.thread_id)
|
|
584
|
+
from public.s12_results r1, public.s12_results r3
|
|
585
|
+
where r1.session = 's1' and r3.session = 's3') as other_actor_distinct;
|
|
586
|
+
|
|
587
|
+
threads|distinct_ids|reused_flags|orphans|actor_a_keys|actor_b_threads|other_actor_distinct
|
|
588
|
+
-------+------------+------------+-------+------------+---------------+--------------------
|
|
589
|
+
1| 1|s1=false | 0|s12-key | 0|
|
|
590
|
+
(1 row)
|
|
591
|
+
|
|
592
|
+
|
|
593
|
+
starting permutation: s1_begin s1_call s1_commit s4_begin_rc s4_call s4_commit check
|
|
594
|
+
step s1_begin: BEGIN; SET LOCAL "request.jwt.claim.role" = 'service_role';
|
|
595
|
+
step s1_call:
|
|
596
|
+
insert into public.s12_results(session, thread_id, reused)
|
|
597
|
+
select 's1', t.thread_id, t.reused
|
|
598
|
+
from agent_board.create_or_find_thread(
|
|
599
|
+
'b5120000-0000-4000-8000-00000000000a', 'S-12 subject', 's12-key') t
|
|
600
|
+
returning session, reused;
|
|
601
|
+
|
|
602
|
+
session|reused
|
|
603
|
+
-------+------
|
|
604
|
+
s1 |f
|
|
605
|
+
(1 row)
|
|
606
|
+
|
|
607
|
+
step s1_commit: COMMIT;
|
|
608
|
+
step s4_begin_rc: BEGIN ISOLATION LEVEL READ COMMITTED; SET LOCAL "request.jwt.claim.role" = 'service_role';
|
|
609
|
+
step s4_call: select public.s12_level_call() as outcome;
|
|
610
|
+
outcome
|
|
611
|
+
--------------------
|
|
612
|
+
returned reused=true
|
|
613
|
+
(1 row)
|
|
614
|
+
|
|
615
|
+
step s4_commit: COMMIT;
|
|
616
|
+
step check:
|
|
617
|
+
select (select count(*)::int from agent_board.threads t
|
|
618
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a'
|
|
619
|
+
and t.metadata ->> 'addressingThreadKey' = 's12-key') as threads,
|
|
620
|
+
(select count(distinct r.thread_id)::int from public.s12_results r
|
|
621
|
+
where r.session in ('s1','s2')) as distinct_ids,
|
|
622
|
+
(select string_agg(r.session || '=' || r.reused::text, ',' order by r.session)
|
|
623
|
+
from public.s12_results r) as reused_flags,
|
|
624
|
+
(select count(*)::int from agent_board.threads t
|
|
625
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a'
|
|
626
|
+
and t.metadata ->> 'addressingThreadKey' = 's12-key'
|
|
627
|
+
and t.id not in (select r.thread_id from public.s12_results r)) as orphans,
|
|
628
|
+
(select string_agg(t.metadata ->> 'addressingThreadKey', ',' order by t.metadata ->> 'addressingThreadKey')
|
|
629
|
+
from agent_board.threads t
|
|
630
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a') as actor_a_keys,
|
|
631
|
+
(select count(*)::int from agent_board.threads t
|
|
632
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000b') as actor_b_threads,
|
|
633
|
+
(select bool_and(r3.thread_id <> r1.thread_id)
|
|
634
|
+
from public.s12_results r1, public.s12_results r3
|
|
635
|
+
where r1.session = 's1' and r3.session = 's3') as other_actor_distinct;
|
|
636
|
+
|
|
637
|
+
threads|distinct_ids|reused_flags |orphans|actor_a_keys|actor_b_threads|other_actor_distinct
|
|
638
|
+
-------+------------+----------------+-------+------------+---------------+--------------------
|
|
639
|
+
1| 1|s1=false,s4=true| 0|s12-key | 0|
|
|
640
|
+
(1 row)
|
|
641
|
+
|