@consiliency/agent-board-schema 1.76.0 → 1.79.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.
Files changed (121) hide show
  1. package/fixtures/already-applied.json +12 -0
  2. package/migrations/20261120000200_agent_board_thread_key_serialize.sql +118 -0
  3. package/migrations/20261121000100_agent_board_thread_key_guards.sql +196 -0
  4. package/migrations/20261124000100_agent_board_step_up_enforcement.sql +1213 -0
  5. package/package.json +1 -1
  6. package/schema-manifest.json +30 -3
  7. package/src/deployment-drift-main.test.mjs +89 -6
  8. package/src/deployment-drift.test.mjs +20 -1
  9. package/src/tooling.test.mjs +9 -2
  10. package/tests/agent_board_717_message_replay_scope.test.sql +39 -2
  11. package/tests/agent_board_717_tasking_replay_scope.test.sql +21 -2
  12. package/tests/agent_board_role_guard.test.sql +3 -1
  13. package/tests/agent_board_send_outcome.test.sql +39 -1
  14. package/tests/agent_board_session_identity_approval_revocation.test.sql +5 -0
  15. package/tests/agent_board_step_up.test.sql +991 -0
  16. package/tests/agent_board_step_up_helper.test.sql +132 -28
  17. package/tests/agent_board_thread_key_guards.test.sql +186 -0
  18. package/tests/agent_board_thread_key_serialize.test.sql +182 -0
  19. package/tests/agent_board_write_enforcement_class.test.sql +3 -2
  20. package/tests/catalog/step_up_gated_closure.json +24 -0
  21. package/tests/fixtures/pgtap-unexposed.sql +9 -4
  22. package/tests/isolation/expected/create_or_find_thread_same_key_race.out +641 -0
  23. package/tests/isolation/expected/session_identity_links.out +4 -0
  24. package/tests/isolation/specs/create_or_find_thread_same_key_race.spec +252 -0
  25. package/tests/isolation/specs/session_identity_links.spec +5 -0
  26. package/tests/mutations/669/run.sh +12 -4
  27. package/tests/mutations/669b/M11_ceil_first.sql +10 -0
  28. package/tests/mutations/669b/M11_gate_first.sql +10 -0
  29. package/tests/mutations/669b/M11_grant_first.sql +10 -0
  30. package/tests/mutations/669b/M11_inv_first.sql +10 -0
  31. package/tests/mutations/669b/M11_mem_first.sql +10 -0
  32. package/tests/mutations/669b/M11_readmit_first.sql +10 -0
  33. package/tests/mutations/669b/M13a_gate_member_preset.sql +12 -0
  34. package/tests/mutations/669b/M13b_ungate_admin_preset.sql +12 -0
  35. package/tests/mutations/669b/M16_actor_is_target.sql +14 -0
  36. package/tests/mutations/669b/M19_drop_readmit.sql +9 -0
  37. package/tests/mutations/669b/M1_drop_grant.sql +9 -0
  38. package/tests/mutations/669b/M20_drop_d5_refusal.sql +9 -0
  39. package/tests/mutations/669b/M21_drop_removal.sql +9 -0
  40. package/tests/mutations/669b/M21b_only_removed.sql +9 -0
  41. package/tests/mutations/669b/M21c_gate_members.sql +12 -0
  42. package/tests/mutations/669b/M21d_requested_state.sql +9 -0
  43. package/tests/mutations/669b/M23b_api_wrapper_over_audit_writer.sql +6 -0
  44. package/tests/mutations/669b/M23c_drop_register_type_refusal.sql +9 -0
  45. package/tests/mutations/669b/M24_drop_kind_refusal.sql +9 -0
  46. package/tests/mutations/669b/M24b_drop_auth_bind_refusal.sql +9 -0
  47. package/tests/mutations/669b/M2a_drop_gate.sql +9 -0
  48. package/tests/mutations/669b/M2b_drop_ceiling.sql +9 -0
  49. package/tests/mutations/669b/M2c_drop_invite.sql +9 -0
  50. package/tests/mutations/669b/MAL2_drop_otp.sql +9 -0
  51. package/tests/mutations/669b/MAL3_admit_passkey.sql +9 -0
  52. package/tests/mutations/669b/MD7a_no_revocation.sql +2 -0
  53. package/tests/mutations/669b/MD7b_overwrite_revoked.sql +2 -0
  54. package/tests/mutations/669b/MD7c_revoke_members.sql +2 -0
  55. package/tests/mutations/669b/MD7d_revoke_expired.sql +2 -0
  56. package/tests/mutations/669b/ME1_wrapper_over_gate.sql +7 -0
  57. package/tests/mutations/669b/MEC2_write_after_helper.sql +10 -0
  58. package/tests/mutations/669b/MQX_query_to_xml_definer.sql +6 -0
  59. package/tests/mutations/669b/MQXb_ts_stat_other_schema.sql +4 -0
  60. package/tests/mutations/669b/MTR_trigger_route.sql +9 -0
  61. package/tests/mutations/669b/MTRb_new_assign.sql +11 -0
  62. package/tests/mutations/669b/MTRc_sync_assigns_value.sql +47 -0
  63. package/tests/mutations/669b/MTX1_tombstone_second_gated_call.sql +15 -0
  64. package/tests/mutations/669b/MTX2_tombstone_non_delegate_target.sql +10 -0
  65. package/tests/mutations/669b/MXS_other_schema_names_gated.sql +5 -0
  66. package/tests/mutations/669b/run.sh +83 -0
  67. package/tests/mutations/670/M18a_read_operation_default_dropped.sql +11 -0
  68. package/tests/mutations/670/M18b_read_operation_default_changed.sql +7 -0
  69. package/tests/mutations/670/M3-DM_helper_on_replay_branch.sql +10 -0
  70. package/tests/mutations/670/M3-MC_helper_on_replay_branch.sql +10 -0
  71. package/tests/mutations/s12/M0_identity.sql +56 -0
  72. package/tests/mutations/s12/M1_serialise_actor_key.sql +57 -0
  73. package/tests/mutations/s12/M1b_serialise_key_only.sql +57 -0
  74. package/tests/mutations/s12/M2_unique_index_no_handler.sql +9 -0
  75. package/tests/mutations/s12/M3_no_trim.sql +56 -0
  76. package/tests/mutations/s12/M4_casefold.sql +56 -0
  77. package/tests/mutations/s12/M5_lookup_ignores_actor.sql +56 -0
  78. package/tests/mutations/s12/M6_reuse_reports_false.sql +56 -0
  79. package/tests/mutations/s12/run.sh +112 -0
  80. package/tests/mutations/s12-fix/M0_identity.sql +83 -0
  81. package/tests/mutations/s12-fix/M10_security_invoker.sql +9 -0
  82. package/tests/mutations/s12-fix/M11_search_path_changed.sql +9 -0
  83. package/tests/mutations/s12-fix/M12_reuse_writes_task.sql +84 -0
  84. package/tests/mutations/s12-fix/M13_dead_inbox_write.sql +84 -0
  85. package/tests/mutations/s12-fix/M14_metadata_unchecked.sql +78 -0
  86. package/tests/mutations/s12-fix/M15_metadata_check_after_lock.sql +84 -0
  87. package/tests/mutations/s12-fix/M16_sql_null_metadata_refused.sql +83 -0
  88. package/tests/mutations/s12-fix/M17_isolation_unchecked.sql +70 -0
  89. package/tests/mutations/s12-fix/M18_isolation_check_after_lock.sql +82 -0
  90. package/tests/mutations/s12-fix/M19_isolation_rr_only.sql +83 -0
  91. package/tests/mutations/s12-fix/M1_lock_dropped.sql +78 -0
  92. package/tests/mutations/s12-fix/M1b_lock_key_only.sql +83 -0
  93. package/tests/mutations/s12-fix/M20_isolation_unsafe_levels_only.sql +83 -0
  94. package/tests/mutations/s12-fix/M21_isolation_check_miss_path_only.sql +83 -0
  95. package/tests/mutations/s12-fix/M22_isolation_inverted.sql +83 -0
  96. package/tests/mutations/s12-fix/M23_isolation_wrong_sqlstate.sql +83 -0
  97. package/tests/mutations/s12-fix/M24_create_thread_key_unchecked.sql +37 -0
  98. package/tests/mutations/s12-fix/M25_create_thread_key_nonnull_only.sql +45 -0
  99. package/tests/mutations/s12-fix/M26_create_thread_key_casefold.sql +45 -0
  100. package/tests/mutations/s12-fix/M27_create_thread_no_object_guard.sql +45 -0
  101. package/tests/mutations/s12-fix/M28_create_thread_key_stripped.sql +40 -0
  102. package/tests/mutations/s12-fix/M29_create_thread_key_nested_refused.sql +45 -0
  103. package/tests/mutations/s12-fix/M2_lock_actor_only.sql +83 -0
  104. package/tests/mutations/s12-fix/M30_create_thread_security_invoker.sql +9 -0
  105. package/tests/mutations/s12-fix/M31_create_thread_search_path_changed.sql +9 -0
  106. package/tests/mutations/s12-fix/M32_class_new_thread_inserter.sql +14 -0
  107. package/tests/mutations/s12-fix/M33_class_metadata_update.sql +12 -0
  108. package/tests/mutations/s12-fix/M33b_class_metadata_update_upper.sql +17 -0
  109. package/tests/mutations/s12-fix/M33c_class_metadata_update_row_form.sql +16 -0
  110. package/tests/mutations/s12-fix/M33d_class_metadata_merge_update.sql +16 -0
  111. package/tests/mutations/s12-fix/M33e_class_metadata_upsert.sql +16 -0
  112. package/tests/mutations/s12-fix/M34_class_api_role_insert.sql +9 -0
  113. package/tests/mutations/s12-fix/M3_lock_after_lookup.sql +83 -0
  114. package/tests/mutations/s12-fix/M4_lock_raw_key.sql +83 -0
  115. package/tests/mutations/s12-fix/M5_no_trim.sql +83 -0
  116. package/tests/mutations/s12-fix/M6_casefold.sql +83 -0
  117. package/tests/mutations/s12-fix/M7_lookup_ignores_actor.sql +82 -0
  118. package/tests/mutations/s12-fix/M8_reuse_reports_false.sql +83 -0
  119. package/tests/mutations/s12-fix/M9_blank_key_admitted.sql +83 -0
  120. package/tests/mutations/s12-fix/run.sh +288 -0
  121. package/tests/seeds/20261124000100_agent_board_step_up_enforcement.sql.pre.sql +47 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@consiliency/agent-board-schema",
3
- "version": "1.76.0",
3
+ "version": "1.79.0",
4
4
  "description": "Canonical, immutable, exact-pinnable agent_board schema bundle: ordered SQL migrations, digest + compatibility manifest, and deterministic materialize/plan/check tooling for adopters.",
5
5
  "repository": "https://github.com/Consiliency/message-board.git",
6
6
  "type": "module",
@@ -2,7 +2,7 @@
2
2
  "schema": "agent_board_schema_manifest.v1",
3
3
  "interface": "IF-0-MBPLANE-BUNDLE-1",
4
4
  "package": "@consiliency/agent-board-schema",
5
- "packageVersion": "1.76.0",
5
+ "packageVersion": "1.79.0",
6
6
  "schemaVersion": 8,
7
7
  "minClientVersion": "1.1.0",
8
8
  "source": {
@@ -46,8 +46,8 @@
46
46
  "usage": "upsert (retention/monitoring defaults; on conflict do nothing)"
47
47
  }
48
48
  ],
49
- "migrationCount": 174,
50
- "aggregateSha256": "ede0ebd43adaf97e8f0fb5669eb25eb2153b7d045b39b5d2c9036099903dc56a",
49
+ "migrationCount": 177,
50
+ "aggregateSha256": "e9dc60ce4c9b25adaa2cf64b91f12de8dff51577cb6a7a4477a5bbf29ab9ffa2",
51
51
  "migrations": [
52
52
  {
53
53
  "order": 0,
@@ -1614,6 +1614,33 @@
1614
1614
  "sourceRef": "message-board",
1615
1615
  "bytes": 16604,
1616
1616
  "sha256": "ce1a878aa752f2f7047958984019030ac7d4c2244c114113e52c8a2abc6dd9d9"
1617
+ },
1618
+ {
1619
+ "order": 174,
1620
+ "id": "20261120000200_agent_board_thread_key_serialize",
1621
+ "filename": "20261120000200_agent_board_thread_key_serialize.sql",
1622
+ "origin": "message-board-forward",
1623
+ "sourceRef": "message-board",
1624
+ "bytes": 7075,
1625
+ "sha256": "5eaf5e3af345d4c0913a99491f5fb4d2b1109152f669a752e401b6027d484639"
1626
+ },
1627
+ {
1628
+ "order": 175,
1629
+ "id": "20261121000100_agent_board_thread_key_guards",
1630
+ "filename": "20261121000100_agent_board_thread_key_guards.sql",
1631
+ "origin": "message-board-forward",
1632
+ "sourceRef": "message-board",
1633
+ "bytes": 11249,
1634
+ "sha256": "0921646160fd23878162d6d053c2ac2631ccb8d80d96c98dfffe58a8a627dd8f"
1635
+ },
1636
+ {
1637
+ "order": 176,
1638
+ "id": "20261124000100_agent_board_step_up_enforcement",
1639
+ "filename": "20261124000100_agent_board_step_up_enforcement.sql",
1640
+ "origin": "message-board-forward",
1641
+ "sourceRef": "message-board",
1642
+ "bytes": 78249,
1643
+ "sha256": "26c02cb8797d059b18f5e81d1db0be237126f48a0598b30e36e683763021384a"
1617
1644
  }
1618
1645
  ],
1619
1646
  "excludedBridge": {
@@ -39,23 +39,25 @@ function installChecker(dir) {
39
39
  copyFileSync(join(ROOT, "scripts", file), join(dir, "scripts", file));
40
40
  }
41
41
  }
42
- function fixture() {
42
+ // `mainFiles` land in main's tip commit, `proposalFiles` in the unmerged proposal: { path: text }.
43
+ function fixture({ mainFiles = {}, proposalFiles = {} } = {}) {
43
44
  const root = mkdtempSync(join(tmpdir(), "drift-main-")); roots.push(root);
44
45
  const dir = join(root, "checkout"); mkdirSync(join(dir, PKG), { recursive: true });
45
46
  git(dir, ["init", "-q", "-b", "main"]);
46
- const commit = (version, date, description = "original") => {
47
+ const commit = (version, date, description = "original", extra = {}) => {
47
48
  writeFileSync(join(dir, PKG, "package.json"), JSON.stringify({ name: "@consiliency/agent-board-schema", version, description }, null, 2));
48
49
  writeFileSync(join(dir, PKG, "schema-manifest.json"), JSON.stringify({ schemaVersion: 8, aggregateSha256: `digest-${version}` }));
49
- git(dir, ["add", PKG]);
50
+ for (const [path, text] of Object.entries(extra)) writeFileSync(join(dir, path), text);
51
+ git(dir, ["add", PKG, ...Object.keys(extra)]);
50
52
  git(dir, ["-c", "user.name=fixture", "-c", "user.email=fixture@example.invalid", "commit", "-qm", version + description],
51
53
  { GIT_AUTHOR_DATE: date, GIT_COMMITTER_DATE: date });
52
54
  return git(dir, ["rev-parse", "HEAD"]);
53
55
  };
54
56
  commit("1.63.0", "2026-01-01T00:00:00Z");
55
57
  commit("1.64.0", stamp);
56
- const main = commit("1.64.0", "2026-01-04T00:00:00Z", "adjacent edit");
58
+ const main = commit("1.64.0", "2026-01-04T00:00:00Z", "adjacent edit", mainFiles);
57
59
  git(dir, ["switch", "-qc", "proposal"]);
58
- const proposal = commit("1.65.0", "2026-01-05T00:00:00Z", "unmerged proposal");
60
+ const proposal = commit("1.65.0", "2026-01-05T00:00:00Z", "unmerged proposal", proposalFiles);
59
61
  // A cached tracking branch deliberately lies. CI must use the event's base SHA.
60
62
  git(dir, ["update-ref", "refs/remotes/origin/main", proposal]);
61
63
  // A real local remote supplies operator truth without any network/service access.
@@ -63,7 +65,9 @@ function fixture() {
63
65
  git(dir, ["remote", "add", "origin", remote]);
64
66
  installChecker(dir);
65
67
  const shims = join(root, "bin"); mkdirSync(shims);
66
- writeFileSync(join(shims, "npm"), '#!/bin/sh\nprintf "%s\\n" "$PUBLISHED"\n'); chmodSync(join(shims, "npm"), 0o755);
68
+ // `npm view <pkg> dist-tags|time --json` answer from DIST_TAGS / TIMES and fail when unset, so a
69
+ // test that sets neither sees exactly the old shim (#799).
70
+ writeFileSync(join(shims, "npm"), '#!/bin/sh\ncase " $* " in\n *" dist-tags "*) [ -n "${DIST_TAGS:-}" ] || exit 1; printf "%s\\n" "$DIST_TAGS"; exit 0 ;;\n *" time "*) [ -n "${TIMES:-}" ] || exit 1; printf "%s\\n" "$TIMES"; exit 0 ;;\nesac\nprintf "%s\\n" "$PUBLISHED"\n'); chmodSync(join(shims, "npm"), 0o755);
67
71
  const preload = join(root, "no-network.mjs");
68
72
  writeFileSync(preload, 'globalThis.fetch = async () => ({ ok: true, json: async () => [JSON.parse(process.env.BOARD_ROW)] });');
69
73
  const eventPath = join(root, "event.json");
@@ -171,3 +175,82 @@ describe("authoritative main, independent of the checked-out proposal", () => {
171
175
  expectUnknown(f.run({ env: { GITHUB_ACTIONS: "false" } }));
172
176
  });
173
177
  });
178
+
179
+ // #799. The channel grace must read MAIN's release-dist-tags.json. Switching that read to `HEAD:`
180
+ // left 108/108 green, because every other test serves the file through a shim that ignores the
181
+ // revision; only a real-git probe sees it. Here main is 1.64.0, `latest` is 1.63.0 with main's bump
182
+ // months old (the ordinary rule says DRIFT), and the registry has 1.64.0 on `next`, published
183
+ // yesterday. The only variable is WHICH commit declares `next`.
184
+ describe("the channel grace reads main's release-dist-tags.json, never the checkout's (#799)", () => {
185
+ const DECLARED = {
186
+ "release-dist-tags.json": JSON.stringify({ releases: { "v9.9.9": { distTag: "next", reason: "fixture: held back on next for the #799 probe" } } }),
187
+ "CHANGELOG.md": "# Changelog\n\n## v9.9.9 — fixture\n\nnpm dist-tag: `next`\n",
188
+ };
189
+ const registry = (publishedMs) => ({
190
+ PUBLISHED: "1.63.0",
191
+ DIST_TAGS: JSON.stringify({ latest: "1.63.0", next: "1.64.0" }),
192
+ TIMES: JSON.stringify({ "1.63.0": "2026-01-01T00:00:00.000Z", "1.64.0": new Date(publishedMs).toISOString() }),
193
+ });
194
+ const yesterday = () => Date.now() - 86_400_000;
195
+ const checkoutAt = (f, checkout) => {
196
+ if (checkout === "merge") {
197
+ git(f.dir, ["switch", "-qc", "merge", f.main]);
198
+ git(f.dir, ["-c", "user.name=fixture", "-c", "user.email=fixture@example.invalid", "merge", "--no-ff", "-qm", "PR merge", "proposal"]);
199
+ }
200
+ return git(f.dir, ["rev-parse", "HEAD"]);
201
+ };
202
+
203
+ // The declaration is TWO files, validated together, so each must be read at main on its own.
204
+ // With only the dist-tags read moved to HEAD, a PR adding both files stayed green — main's
205
+ // missing CHANGELOG line failed validation anyway. Hence three splits: each one catches a
206
+ // mutation the others miss (measured; see the #799 commit).
207
+ const SPLITS = {
208
+ "both files in the PR": { mainFiles: {}, proposalFiles: DECLARED },
209
+ "only the dist-tags entry in the PR (main already carries the CHANGELOG line)": {
210
+ mainFiles: { "CHANGELOG.md": DECLARED["CHANGELOG.md"] },
211
+ proposalFiles: { "release-dist-tags.json": DECLARED["release-dist-tags.json"] },
212
+ },
213
+ "only the CHANGELOG line in the PR (main already carries the dist-tags entry)": {
214
+ mainFiles: { "release-dist-tags.json": DECLARED["release-dist-tags.json"] },
215
+ proposalFiles: { "CHANGELOG.md": DECLARED["CHANGELOG.md"] },
216
+ },
217
+ };
218
+ const arms = Object.keys(SPLITS).flatMap((split) => ["proposal", "merge"].map((checkout) => [split, checkout]));
219
+
220
+ it.each(arms)("a PR that declares its own channel still drifts: %s (%s checkout)", (split, checkout) => {
221
+ const f = fixture(SPLITS[split]);
222
+ const head = checkoutAt(f, checkout);
223
+ // The checkout really carries the full declaration; main really lacks the PR's half of it.
224
+ for (const path of Object.keys(DECLARED)) expect(readFileSync(join(f.dir, path), "utf8")).toBe(DECLARED[path]);
225
+ for (const path of Object.keys(SPLITS[split].proposalFiles)) {
226
+ expect(spawnSync("git", ["cat-file", "-e", `${f.main}:${path}`], { cwd: f.dir }).status).not.toBe(0);
227
+ }
228
+ const r = f.run({ env: { GITHUB_SHA: head, ...registry(yesterday()) } });
229
+ expect(r.status).toBe(1);
230
+ expect(r.doc.status).toBe("drift");
231
+ expect(r.doc.facts.mergedCommit).toBe(f.main);
232
+ expect(r.doc.facts.channels ?? null).toBeNull();
233
+ expect(r.out).toMatch(/1 schema version\(s\) merged but NOT published/);
234
+ expect(r.out).not.toMatch(/declared dist-tag/);
235
+ });
236
+
237
+ it.each(["proposal", "merge"])("control: the same declaration on MAIN reaches the grace (%s checkout)", (checkout) => {
238
+ const f = fixture({ mainFiles: DECLARED });
239
+ const head = checkoutAt(f, checkout);
240
+ const r = f.run({ env: { GITHUB_SHA: head, ...registry(yesterday()) } });
241
+ expect(r.status).toBe(0);
242
+ expect(r.doc.status).toBe("ok");
243
+ expect(r.doc.facts.channels?.next?.version).toBe("1.64.0");
244
+ expect(r.out).toMatch(/published under the declared dist-tag `next` \(latest is 1\.63\.0\)/);
245
+ });
246
+
247
+ it("a future-dated publish time on main's declared channel gets no grace", () => {
248
+ const f = fixture({ mainFiles: DECLARED });
249
+ const r = f.run({ env: registry(Date.now() + 30 * 86_400_000) });
250
+ expect(r.status).toBe(1);
251
+ expect(r.doc.status).toBe("drift");
252
+ expect(r.doc.facts.channels?.next?.version).toBe("1.64.0");
253
+ expect(r.out).toMatch(/1 schema version\(s\) merged but NOT published/);
254
+ expect(r.out).not.toMatch(/published under the declared dist-tag/);
255
+ });
256
+ });
@@ -27,7 +27,7 @@
27
27
  // whole PR exists for — is NOT exercised here. It is exercised as a subprocess in
28
28
  // deployment-drift-script.test.mjs, because none of it is reachable through `evaluate()`.
29
29
  import { describe, it, expect } from "vitest";
30
- import { evaluate, minorGap, pgTimestampToIso, OK, DRIFT, UNKNOWN } from "../../../scripts/lib/drift-evaluate.mjs";
30
+ import { evaluate, minorGap, onDeclaredChannel, pgTimestampToIso, OK, DRIFT, UNKNOWN } from "../../../scripts/lib/drift-evaluate.mjs";
31
31
 
32
32
  const NOW = new Date("2026-08-16T18:00:00Z").getTime();
33
33
  const BUMP = "2026-08-16T17:00:00Z";
@@ -341,6 +341,25 @@ describe("dist-tag-aware published leg (#796)", () => {
341
341
  expect(run(held({ channels: onNext("1.36.0", "not-a-date") })).status).toBe(DRIFT);
342
342
  });
343
343
 
344
+ // #799. A registry time later than now is not evidence of a publish. Floored, it was a
345
+ // negative age that never exceeded --max-days, so the grace ran to that date plus --max-days.
346
+ it("#799-future: a future-dated channel publish time grants no grace (1 minute, 1 day, a year ahead)", () => {
347
+ for (const ahead of [60_000, 86_400_000, 365 * 86_400_000]) {
348
+ const iso = new Date(NOW + ahead).toISOString();
349
+ expect(onDeclaredChannel(onNext("1.36.0", iso), "1.36.0", NOW)).toEqual({ tag: "next", version: "1.36.0", ageDays: null });
350
+ const r = run(held({ channels: onNext("1.36.0", iso) }));
351
+ expect(r.status).toBe(DRIFT);
352
+ expect(r.findings.some((f) => /declared dist-tag/.test(f.msg))).toBe(false);
353
+ }
354
+ });
355
+
356
+ it("#799-future: the control — a publish time exactly at now, and one just before, still reach the grace", () => {
357
+ for (const iso of [new Date(NOW).toISOString(), new Date(NOW - 60_000).toISOString()]) {
358
+ expect(onDeclaredChannel(onNext("1.36.0", iso), "1.36.0", NOW)).toEqual({ tag: "next", version: "1.36.0", ageDays: 0 });
359
+ expect(run(held({ channels: onNext("1.36.0", iso) })).status).toBe(OK);
360
+ }
361
+ });
362
+
344
363
  it("#796-strict: a channel naming an OLDER version than merged is still DRIFT (main moved past the held release)", () => {
345
364
  expect(run(held({ channels: onNext("1.35.5", daysAgo(1)) })).status).toBe(DRIFT);
346
365
  });
@@ -41,9 +41,9 @@ describe('manifest integrity', () => {
41
41
  expect(manifest.schemaVersion).toBe(8);
42
42
  expect(manifest.minClientVersion).toMatch(/^\d+\.\d+\.\d+$/);
43
43
  });
44
- it('registers the four MBAUTHZ + four MBSENDAUTHZ + four MBSESSION + four MBDELEG + three MBFED + three MBHARDEN + two MBPORTALGATE + two MBPORTAL-PR32 + two ROOMOWN + two ROOMLINK + one ROOMDELEG + one LOCALAUTH + one ROOMUIAPI + one FEDSESSION + one FEDSESSION-AUTOJOIN + one GATENULL + one MEMBSTATE + one AGENTSDIR + one LEAVEIDEM + one ROLERESET + one MBROWID + one MBHYGIENE + one MBCONSENT-A + one MBCONSENT-B(a) + one MBCONSENT-B(i) + one MBCONSENT-B(ii) + one MBCONSENT-B(iii) + one MBHARDEN-#97 + one MBHARDEN-#118 + one INVITEPOLICY + one OBSGATE + one OBSGATE-2 + one OBSGATE-3 + one OBSGATE-4 + one FLEETMACHINERLS + one RESOLVENOOP + one ROOMDELEG-LANEB + one CLAIMKEY + two MINTHARDEN + one FLEETMACHINEHIJACK + one CLAIMGATE-SHADOW + one CLAIMGATE-ENFORCE + one FLEETMACHINEREACTIVATION + one DELEGCAPCEILING + one FLEETMACHINERECLAIM + one DELEGSOLEWRITER + one FLEETDOMAINRECLAIM + five ATOMICFLEETONBOARDING (onboarding + ceiling-lock + revocation-evidence + fedsession-gate + fedsession-lock-order) + one OUTBOXWAKE + one ENROLLLOCKORDER + one FEDPROVIDERABSENCE + one WAKERECOVERY + one CONSENTRECONCILE + one ENROLLRESUMPTION + one SIGNEDAUTHORITY + one SIGNERLIFECYCLE + one LEDGERAUTHORITY + one CEILINGLOCKCOMMENT + one LEDGERBOARDCREATE + one RECEIPTSUBJECTGATE + one TASKTHREADLOCKORDER + one CLAIMSUBJECTGATE + one FEDSESSIONIDENTITYGATE + one FEDIDENTITYSLUG + one INVITENODOWNGRADE + one SIGNEDWRITEFLAG + one SIGNEDWRITEMODEL + one RTCREDCLAIM + one ORIGINPOSTURE + one BOARDCLAIMPOLICY + one HEARTBEATPRESERVE + one LIVENESSDENOM + one OWNERLESSRENEWTTL + one OWNERLESSQUOTACENSUS + one FLEETDOMAINNODOWNGRADE + one OWNERLESSQUOTACONVERGE + one ADVISORYREVERTRESET + one CLAIMPOLICYRACE + one CLAIMPOLICYLOCKGRANT + one SESSIONCHALLENGESUPERSEDE + one ROOMCONTRACT + one CALLBACKCONSUMER + one ENROLLTOKENSINGLEUSE + one ROOMCONTRACT-ACTIVEFIRST + one ONBOARD + one HOSTED + one HOSTED-FOLLOWUPS + one OWNPOST + one SIDSCHEMA + one SIDOWNER + one GRANTTARGETROLE (#674) + one LASTOWNER (Consiliency/message-board#675) + one SESSIONPROVENANCE (Consiliency/message-board#665) + one REQUESTREMOVED (Consiliency/message-board#680) + one RLSCORRELATION (Consiliency/message-board#589) + one RESOLUTIONAUTHORITY (Consiliency/message-board#668) + one THREADASSOCIATION checkpoint (#667) + one SIDSERVER-MEASUREDMINT (Consiliency/message-board#653) + one REPLYDELIVERY (#661) + one DELIVERYWRITEREXEC (#717 F1) + one REPLAYSCOPE (#717 F2) + one MESSAGEREPLAYSCOPE (#717 F2b) + one SENDOUTCOME (#670) + one STEPUP-PR-A (#669) forward migrations (migrationCount = prior 113 + 5 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 = 174)', () => {
44
+ it('registers the four MBAUTHZ + four MBSENDAUTHZ + four MBSESSION + four MBDELEG + three MBFED + three MBHARDEN + two MBPORTALGATE + two MBPORTAL-PR32 + two ROOMOWN + two ROOMLINK + one ROOMDELEG + one LOCALAUTH + one ROOMUIAPI + one FEDSESSION + one FEDSESSION-AUTOJOIN + one GATENULL + one MEMBSTATE + one AGENTSDIR + one LEAVEIDEM + one ROLERESET + one MBROWID + one MBHYGIENE + one MBCONSENT-A + one MBCONSENT-B(a) + one MBCONSENT-B(i) + one MBCONSENT-B(ii) + one MBCONSENT-B(iii) + one MBHARDEN-#97 + one MBHARDEN-#118 + one INVITEPOLICY + one OBSGATE + one OBSGATE-2 + one OBSGATE-3 + one OBSGATE-4 + one FLEETMACHINERLS + one RESOLVENOOP + one ROOMDELEG-LANEB + one CLAIMKEY + two MINTHARDEN + one FLEETMACHINEHIJACK + one CLAIMGATE-SHADOW + one CLAIMGATE-ENFORCE + one FLEETMACHINEREACTIVATION + one DELEGCAPCEILING + one FLEETMACHINERECLAIM + one DELEGSOLEWRITER + one FLEETDOMAINRECLAIM + five ATOMICFLEETONBOARDING (onboarding + ceiling-lock + revocation-evidence + fedsession-gate + fedsession-lock-order) + one OUTBOXWAKE + one ENROLLLOCKORDER + one FEDPROVIDERABSENCE + one WAKERECOVERY + one CONSENTRECONCILE + one ENROLLRESUMPTION + one SIGNEDAUTHORITY + one SIGNERLIFECYCLE + one LEDGERAUTHORITY + one CEILINGLOCKCOMMENT + one LEDGERBOARDCREATE + one RECEIPTSUBJECTGATE + one TASKTHREADLOCKORDER + one CLAIMSUBJECTGATE + one FEDSESSIONIDENTITYGATE + one FEDIDENTITYSLUG + one INVITENODOWNGRADE + one SIGNEDWRITEFLAG + one SIGNEDWRITEMODEL + one RTCREDCLAIM + one ORIGINPOSTURE + one BOARDCLAIMPOLICY + one HEARTBEATPRESERVE + one LIVENESSDENOM + one OWNERLESSRENEWTTL + one OWNERLESSQUOTACENSUS + one FLEETDOMAINNODOWNGRADE + one OWNERLESSQUOTACONVERGE + one ADVISORYREVERTRESET + one CLAIMPOLICYRACE + one CLAIMPOLICYLOCKGRANT + one SESSIONCHALLENGESUPERSEDE + one ROOMCONTRACT + one CALLBACKCONSUMER + one ENROLLTOKENSINGLEUSE + one ROOMCONTRACT-ACTIVEFIRST + one ONBOARD + one HOSTED + one HOSTED-FOLLOWUPS + one OWNPOST + one SIDSCHEMA + one SIDOWNER + one GRANTTARGETROLE (#674) + one LASTOWNER (Consiliency/message-board#675) + one SESSIONPROVENANCE (Consiliency/message-board#665) + one REQUESTREMOVED (Consiliency/message-board#680) + one RLSCORRELATION (Consiliency/message-board#589) + one RESOLUTIONAUTHORITY (Consiliency/message-board#668) + one THREADASSOCIATION checkpoint (#667) + one SIDSERVER-MEASUREDMINT (Consiliency/message-board#653) + one REPLYDELIVERY (#661) + one DELIVERYWRITEREXEC (#717 F1) + one REPLAYSCOPE (#717 F2) + one MESSAGEREPLAYSCOPE (#717 F2b) + one SENDOUTCOME (#670) + one STEPUP-PR-A (#669) + one THREADKEYSERIALIZE (S-12) + one THREADKEYGUARDS (S-12 #815/#816) + one STEPUP-PR-B (#669) forward migrations (migrationCount = prior 113 + 5 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 = 177)', () => {
45
45
  expect(manifest.migrationCount).toBe(manifest.migrations.length);
46
- expect(manifest.migrationCount).toBe(174);
46
+ expect(manifest.migrationCount).toBe(177);
47
47
  // MBSESSION switched enforcement on (scoped-send re-grant): the client-visible
48
48
  // schema version bumped to 8. MBDELEG tightens delegation and MBFED adds only
49
49
  // enrollment-only additive surface (identity_providers registry, enrollment audit,
@@ -376,6 +376,13 @@ describe('manifest integrity', () => {
376
376
  '20261104190000_agent_board_message_replay_scope.sql',
377
377
  '20261108000100_agent_board_send_outcome.sql',
378
378
  '20261109000100_agent_board_step_up_groundwork.sql',
379
+ '20261120000200_agent_board_thread_key_serialize.sql',
380
+ // S-12 follow-ups: create_or_find_thread refuses a non-READ-COMMITTED transaction (#815) and
381
+ // create_thread refuses the reserved addressingThreadKey (#816).
382
+ '20261121000100_agent_board_thread_key_guards.sql',
383
+ // #669 PR-B: step-up enforcement on the gated conferral routes (renamed from 20261120000100
384
+ // when refreshed onto main, so it sorts after the S-12 migrations).
385
+ '20261124000100_agent_board_step_up_enforcement.sql',
379
386
  ]) {
380
387
  expect(names.has(f)).toBe(true);
381
388
  }
@@ -29,7 +29,7 @@ set search_path = extensions, public, agent_board;
29
29
 
30
30
  begin;
31
31
 
32
- select plan(67);
32
+ select plan(69);
33
33
 
34
34
  create temp table _h(k text primary key, v text);
35
35
  create function pg_temp.v(p_k text) returns text language sql as $$ select v from _h where k = p_k $$;
@@ -631,6 +631,10 @@ select ok(
631
631
  -- no-replay post_message: 43 (two identical calls, two messages)
632
632
  -- recipient-state update_inbox_item_state: UPDATEs the caller's OWN inbox item only (63)
633
633
  -- tasking-f2 create_tasking_delivery family: #717 F2's ceiling (separate PR); NOT claimed here
634
+ -- thread-only create_or_find_thread: a member only because it serializes through
635
+ -- _lock_idempotency_key (S-12, 20261120000200). It writes a THREAD and nothing
636
+ -- else: its body writes no message/task/delivery/inbox row and reaches no writer
637
+ -- of one (68), and two same-key calls create one thread and no other row (69)
634
638
  create temp table _class(signature text primary key, disposition text not null);
635
639
  insert into _class values
636
640
  ('send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb)', 'ceiling'),
@@ -649,7 +653,8 @@ insert into _class values
649
653
  ('update_inbox_item_state(uuid,uuid,text,jsonb)', 'recipient-state'),
650
654
  ('create_tasking_delivery(uuid,uuid,text,text,uuid[],uuid,text,text,text,jsonb)', 'tasking-f2'),
651
655
  ('create_tasking_delivery(uuid,uuid,text,text,jsonb,text,text,text,text,text,jsonb)', 'tasking-f2'),
652
- ('signed_create_tasking_delivery(jsonb,jsonb)', 'tasking-f2');
656
+ ('signed_create_tasking_delivery(jsonb,jsonb)', 'tasking-f2'),
657
+ ('create_or_find_thread(uuid,text,text,text,jsonb)', 'thread-only');
653
658
 
654
659
  create function pg_temp.derived() returns table(signature text, body text) language sql as $d$
655
660
  with fns as (
@@ -824,5 +829,37 @@ select is(pg_temp.refuse('A', pg_temp.mc('A','T',pg_temp.ids('X'),'mk')),
824
829
  select is(pg_temp.sees('X','MC'), '0/0/0/0/0/0 -',
825
830
  'multicast source proof: the original body and C-authored artifact remain invisible after unrelated-delivery replay');
826
831
 
832
+
833
+ -- 68 -- thread-only disposition, by the catalog: each member writes threads, writes no message,
834
+ -- task, task event, delivery or inbox row, and reaches no routine that writes one.
835
+ select is(
836
+ (select coalesce(string_agg(c.signature, ' ' order by c.signature), '(none)')
837
+ from _class c join _derived d on d.signature = c.signature
838
+ where c.disposition = 'thread-only'
839
+ and (d.body !~ agent_board_test.writes_any_re(array['threads'])
840
+ or d.body ~ agent_board_test.writes_any_re(array['messages', 'tasks', 'task_events', 'delivery_recipients', 'inbox_items'])
841
+ or exists (select 1 from agent_board_test.fn_call_closure() cl
842
+ where cl.root_oid = to_regprocedure('agent_board.' || c.signature)
843
+ and agent_board_test.stripped_body(cl.reached_oid)
844
+ ~ agent_board_test.writes_any_re(array['messages', 'tasks', 'task_events', 'delivery_recipients', 'inbox_items'])))),
845
+ '(none)',
846
+ 'thread-only disposition: create_or_find_thread writes threads, and neither it nor anything it calls writes a message, task, event, delivery or inbox row');
847
+
848
+ -- 69 -- thread-only disposition, by behaviour: as agent A, two calls with one fresh key create
849
+ -- exactly one thread (reused false, then true) and change no other row count.
850
+ create function pg_temp.thread_only_rows() returns text language sql as $$
851
+ select pg_temp.fp_rows() || ' tasks=' || (select count(*) from agent_board.tasks)
852
+ || ' events=' || (select count(*) from agent_board.task_events) $$;
853
+ select pg_temp.put('to.before', pg_temp.thread_only_rows());
854
+ select pg_temp.put('to.first', pg_temp.val('A', $$ select reused::text from agent_board.create_or_find_thread(null, 'F2b thread-only', 'f2b717-thread-only') $$));
855
+ select pg_temp.put('to.second', pg_temp.val('A', $$ select reused::text from agent_board.create_or_find_thread(null, 'F2b thread-only', 'f2b717-thread-only') $$));
856
+ select is(
857
+ pg_temp.v('to.first') || '/' || pg_temp.v('to.second')
858
+ || ' threads=' || (select count(*) from agent_board.threads where metadata ->> 'addressingThreadKey' = 'f2b717-thread-only')
859
+ || ' ' || case when pg_temp.thread_only_rows() = pg_temp.v('to.before') then 'rows-unchanged'
860
+ else pg_temp.v('to.before') || ' -> ' || pg_temp.thread_only_rows() end,
861
+ 'false/true threads=1 rows-unchanged',
862
+ 'thread-only disposition: two same-key calls create one thread and write no message, task, delivery, inbox, callback or evidence row');
863
+
827
864
  select * from finish();
828
865
  rollback;
@@ -29,7 +29,7 @@ set search_path = extensions, public, agent_board;
29
29
 
30
30
  begin;
31
31
 
32
- select plan(56);
32
+ select plan(57);
33
33
 
34
34
  do $$
35
35
  begin
@@ -625,12 +625,17 @@ select ok(obj_description('agent_board.create_tasking_delivery(uuid,uuid,text,te
625
625
  -- delivery of the source in the core's own mode;
626
626
  -- pinned behaviourally and by mutation in
627
627
  -- agent_board_717_message_replay_scope.test.sql
628
+ -- create_or_find_thread thread-only -- S-12 (20261120000200): serializes thread
629
+ -- creation, writes no task or message; pinned
630
+ -- behaviourally at 57 here and at 68/69 in
631
+ -- agent_board_717_message_replay_scope.test.sql
628
632
  create temp table _replay_class(signature text primary key, disposition text not null);
629
633
  insert into _replay_class values
630
634
  ('create_tasking_delivery(uuid,uuid,text,text,uuid[],uuid,text,text,text,jsonb)', 'ceiling'),
631
635
  ('post_board_message(uuid,uuid,uuid,text,text,text,text,text,jsonb)', 'one-board'),
632
636
  ('send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb)', 'fixed-717-F2b-740'),
633
- ('send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb)', 'fixed-717-F2b-740');
637
+ ('send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb)', 'fixed-717-F2b-740'),
638
+ ('create_or_find_thread(uuid,text,text,text,jsonb)', 'thread-only');
634
639
  -- 54
635
640
  select is(
636
641
  (select coalesce(string_agg(s, ' ' order by s), '(none)') from (
@@ -657,5 +662,19 @@ select is(pg_temp.refuse('A', format($$ select * from agent_board.post_board_mes
657
662
  pg_temp.v('T'), pg_temp.v('A'), pg_temp.v('B2'))),
658
663
  '42501:thread belongs to a different board | side-effects=none',
659
664
  'one-board disposition: a board post on T cannot target another board');
665
+ -- 57 -- the thread-only disposition, behaviourally: as agent A, two calls with one fresh key
666
+ -- create exactly one thread (reused false, then true) and no task, event, delivery or message.
667
+ create function pg_temp.thread_only_rows() returns text language sql as $$
668
+ select pg_temp.fp_rows() || ' messages=' || (select count(*) from agent_board.messages) $$;
669
+ select pg_temp.put('to.before', pg_temp.thread_only_rows());
670
+ select pg_temp.put('to.first', pg_temp.val('A', $$ select reused::text from agent_board.create_or_find_thread(null, 'F2 thread-only', 'f2717-thread-only') $$));
671
+ select pg_temp.put('to.second', pg_temp.val('A', $$ select reused::text from agent_board.create_or_find_thread(null, 'F2 thread-only', 'f2717-thread-only') $$));
672
+ select is(
673
+ pg_temp.v('to.first') || '/' || pg_temp.v('to.second')
674
+ || ' threads=' || (select count(*) from agent_board.threads where metadata ->> 'addressingThreadKey' = 'f2717-thread-only')
675
+ || ' ' || case when pg_temp.thread_only_rows() = pg_temp.v('to.before') then 'rows-unchanged'
676
+ else pg_temp.v('to.before') || ' -> ' || pg_temp.thread_only_rows() end,
677
+ 'false/true threads=1 rows-unchanged',
678
+ 'thread-only disposition: two same-key create_or_find_thread calls create one thread and write no task, event, delivery or message');
660
679
  select * from finish();
661
680
  rollback;
@@ -291,7 +291,9 @@ select is((select count(*)::int from pg_proc p,aclexplode(coalesce(p.proacl,acld
291
291
 
292
292
  select isnt(obj_description(to_regprocedure('agent_board._board_memberships_last_owner_guard()'),'pg_proc'),null,'CLASS-trigger COMMENT exists');
293
293
 
294
- select is((select md5(prosrc) from pg_proc where oid=to_regprocedure('agent_board.grant_board_role(uuid,uuid,text,uuid)')),'de7d1079623e95dcc376e1881492a44b','CLASS-main grant body unchanged'); -- pgtap-allow-raise-checked: non-raising catalog identity lookup; no RPC is executed.
294
+ -- Re-pinned by #669 PR-B (20261124000100): the only body change is the step-up helper call before
295
+ -- the final return; agent_board_step_up.test.sql EC-SU-2 pins that edit and its placement.
296
+ select is((select md5(prosrc) from pg_proc where oid=to_regprocedure('agent_board.grant_board_role(uuid,uuid,text,uuid)')),'f0532a5864ed03f5d432c0846fa8acba','CLASS-main grant body unchanged'); -- pgtap-allow-raise-checked: non-raising catalog identity lookup; no RPC is executed.
295
297
 
296
298
  select ok(strpos(agent_board_test.stripped_body('agent_board.update_board_membership(uuid,uuid,text,jsonb)'::regprocedure),'agent_board._lock_board_authority_ceiling(')>0 and strpos(agent_board_test.stripped_body('agent_board.update_board_membership(uuid,uuid,text,jsonb)'::regprocedure),'agent_board._lock_board_authority_ceiling(')<strpos(agent_board_test.stripped_body('agent_board.update_board_membership(uuid,uuid,text,jsonb)'::regprocedure),'for update'),'CLASS-departure advisory before membership row lock');
297
299
 
@@ -20,12 +20,14 @@
20
20
  -- * Mutation labels: SO-M<n> is the assertion the D11 mutant M<n> must turn red (M9 and M10 are
21
21
  -- isolation controls, tests/isolation/specs/send_outcome_*.spec). Receipts are in
22
22
  -- plans/evidence/670/.
23
+ -- SO-M3-DM, SO-M3-MC and SO-M18 (#780, #778) are the targets of mutants M3-DM, M3-MC and
24
+ -- M18a/M18b.
23
25
  create extension if not exists pgtap with schema extensions;
24
26
  set search_path = extensions, public, agent_board;
25
27
 
26
28
  begin;
27
29
 
28
- select plan(100);
30
+ select plan(104);
29
31
 
30
32
  grant usage on schema extensions to authenticated, service_role, anon;
31
33
  do $$
@@ -801,5 +803,41 @@ select is((select count(*)::int from agent_board.send_outcomes where author_agen
801
803
  select is(pg_temp.read('O', 'TY', 'K1'), pg_temp.confirmed('M.O.TY', 'post_board_message', 'Y'),
802
804
  'SO-D5-2: the other author reads its own same-key receipt confirmed');
803
805
 
806
+ -- ===========================================================================
807
+ -- Follow-ups #778 and #780. Appended here so the assertion numbers above do not move.
808
+ -- ===========================================================================
809
+ -- #778: p_operation's SQL default. Every read above passes three arguments, so none of them
810
+ -- reaches the default. This is the named two-argument form a PostgREST caller sends. Without the
811
+ -- default it is 42883 (mutant M18a); with another default it reads K1 under the wrong operation
812
+ -- (mutant M18b).
813
+ select lives_ok(
814
+ format('select pg_temp.raise_as(%L, %L)', 'A',
815
+ format('select * from agent_board.get_send_outcome(p_thread_id => %L::uuid, p_idempotency_key => %L)', pg_temp.v('TX'), 'K1')),
816
+ 'SO-DEF-1: a named two-argument read (no p_operation) lives');
817
+ select is(
818
+ pg_temp.val('A', format('select r::text from agent_board.get_send_outcome(p_thread_id => %L::uuid, p_idempotency_key => %L) r', pg_temp.v('TX'), 'K1')),
819
+ pg_temp.confirmed('M.K1', 'post_board_message', 'X'),
820
+ 'SO-M18: a named two-argument read defaults p_operation to post_board_message and reads confirmed');
821
+
822
+ -- #780: SO-M3's replay claim for the two private cores (mutants M3-DM, M3-MC). service_role
823
+ -- creates a keyed direct and a keyed multicast message naming A; A's session then replays each
824
+ -- with the same key and the same recipients, which #717 F2b permits because every recipient
825
+ -- already holds the private delivery. The replay must return the original id and mint nothing.
826
+ -- The leading uuid check keeps two identical errors from reading as "the same id".
827
+ select pg_temp.put('M.RPD.svc', pg_temp.val('SVC', pg_temp.dm('A', 'TD', 'R', 'KRPD')));
828
+ select pg_temp.put('M.RPD.session', pg_temp.val('A', pg_temp.dm('A', 'TD', 'R', 'KRPD')));
829
+ select is(
830
+ (pg_temp.u('M.RPD.svc') is not null)::text || ' ' || (pg_temp.v('M.RPD.session') = pg_temp.v('M.RPD.svc'))::text
831
+ || ' ' || pg_temp.receipts_key('A', 'KRPD') || ' ' || pg_temp.read('A', 'TD', 'KRPD', 'send_direct_message'),
832
+ 'true true 0 (unknown,,,,,)',
833
+ 'SO-M3-DM: a session replay of a service_role-created direct message returns the original id and still reads unknown');
834
+ select pg_temp.put('M.RPM.svc', pg_temp.val('SVC', pg_temp.mc('A', 'TD', 'KRPM', 'R', 'R2')));
835
+ select pg_temp.put('M.RPM.session', pg_temp.val('A', pg_temp.mc('A', 'TD', 'KRPM', 'R', 'R2')));
836
+ select is(
837
+ (pg_temp.u('M.RPM.svc') is not null)::text || ' ' || (pg_temp.v('M.RPM.session') = pg_temp.v('M.RPM.svc'))::text
838
+ || ' ' || pg_temp.receipts_key('A', 'KRPM') || ' ' || pg_temp.read('A', 'TD', 'KRPM', 'send_multicast_message'),
839
+ 'true true 0 (unknown,,,,,)',
840
+ 'SO-M3-MC: a session replay of a service_role-created multicast message returns the original id and still reads unknown');
841
+
804
842
  select * from finish();
805
843
  rollback;
@@ -157,6 +157,11 @@ select is((select count(*) from _sid_readmit_result), 0::bigint,
157
157
  delete from agent_board.fleet_revocation_events where revocation_reason = 'sid-readmit-owner-ledger-control'
158
158
  and subject_id = (select id from agent_board.agents where auth_user_id = (select owner_auth from _sid_readmit_root));
159
159
  set local role authenticated;
160
+ -- #669 PR-B (D4): readmitting above member is step-up gated. The human owner is a LOCALAUTH
161
+ -- principal, so it presents a fresh allowlisted amr (totp) in request.jwt.claims; auth.uid() still
162
+ -- comes from the legacy sub GUC set above. agent_board_step_up.test.sql pins the gate itself (R-15).
163
+ select set_config('request.jwt.claims', json_build_object('amr', json_build_array(json_build_object(
164
+ 'method', 'totp', 'timestamp', floor(extract(epoch from clock_timestamp()))::bigint)))::text, true);
160
165
  select lives_ok($q$select pg_temp.sid_readmit('fork', 'allowed', '["read"]', 'admin')$q$,
161
166
  'EC-SIDSCHEMA-5-readmit-owner: authenticated human owner mints the selected successor');
162
167
  reset role;