@fuzdev/fuz_app 0.182.0 → 0.183.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 (191) hide show
  1. package/README.md +2 -0
  2. package/dist/actions/CLAUDE.md +4 -4
  3. package/dist/auth/CLAUDE.md +58 -34
  4. package/dist/auth/account_routes.d.ts +5 -3
  5. package/dist/auth/account_routes.d.ts.map +1 -1
  6. package/dist/auth/account_routes.js +71 -66
  7. package/dist/auth/admin_actions.d.ts.map +1 -1
  8. package/dist/auth/admin_actions.js +22 -17
  9. package/dist/auth/audit_emitter.d.ts +75 -84
  10. package/dist/auth/audit_emitter.d.ts.map +1 -1
  11. package/dist/auth/audit_emitter.js +83 -71
  12. package/dist/auth/audit_log_schema.d.ts +10 -5
  13. package/dist/auth/audit_log_schema.d.ts.map +1 -1
  14. package/dist/auth/audit_log_schema.js +22 -6
  15. package/dist/auth/bootstrap_account.d.ts +31 -13
  16. package/dist/auth/bootstrap_account.d.ts.map +1 -1
  17. package/dist/auth/bootstrap_account.js +34 -15
  18. package/dist/auth/bootstrap_routes.d.ts +1 -1
  19. package/dist/auth/bootstrap_routes.d.ts.map +1 -1
  20. package/dist/auth/bootstrap_routes.js +7 -14
  21. package/dist/auth/deps.d.ts +8 -5
  22. package/dist/auth/deps.d.ts.map +1 -1
  23. package/dist/auth/deps.js +3 -2
  24. package/dist/auth/resolved_auth.d.ts +7 -7
  25. package/dist/auth/resolved_auth.d.ts.map +1 -1
  26. package/dist/auth/resolved_auth.js +4 -4
  27. package/dist/auth/role_grant_offer_actions.d.ts +25 -1
  28. package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
  29. package/dist/auth/role_grant_offer_actions.js +40 -33
  30. package/dist/auth/role_grant_offer_queries.d.ts +60 -4
  31. package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
  32. package/dist/auth/role_grant_offer_queries.js +79 -5
  33. package/dist/auth/role_grant_queries.d.ts +3 -52
  34. package/dist/auth/role_grant_queries.d.ts.map +1 -1
  35. package/dist/auth/role_grant_queries.js +5 -80
  36. package/dist/auth/self_service_role_actions.d.ts.map +1 -1
  37. package/dist/auth/self_service_role_actions.js +11 -22
  38. package/dist/auth/session_queries.d.ts +6 -3
  39. package/dist/auth/session_queries.d.ts.map +1 -1
  40. package/dist/auth/session_queries.js +20 -11
  41. package/dist/auth/signup_routes.d.ts.map +1 -1
  42. package/dist/auth/signup_routes.js +90 -38
  43. package/dist/db/sql_columns.d.ts +1 -1
  44. package/dist/db/sql_columns.js +1 -1
  45. package/dist/http/CLAUDE.md +15 -10
  46. package/dist/http/db_routes.d.ts +7 -22
  47. package/dist/http/db_routes.d.ts.map +1 -1
  48. package/dist/http/db_routes.js +72 -72
  49. package/dist/http/pending_effects.d.ts +42 -4
  50. package/dist/http/pending_effects.d.ts.map +1 -1
  51. package/dist/http/pending_effects.js +34 -4
  52. package/dist/server/app_server.d.ts +43 -2
  53. package/dist/server/app_server.d.ts.map +1 -1
  54. package/dist/server/app_server.js +57 -3
  55. package/dist/testing/CLAUDE.md +255 -786
  56. package/dist/testing/adversarial_404.d.ts +6 -1
  57. package/dist/testing/adversarial_404.d.ts.map +1 -1
  58. package/dist/testing/adversarial_404.js +38 -17
  59. package/dist/testing/app_server.d.ts +20 -140
  60. package/dist/testing/app_server.d.ts.map +1 -1
  61. package/dist/testing/app_server.js +45 -124
  62. package/dist/testing/audit_drift_guard.d.ts +11 -6
  63. package/dist/testing/audit_drift_guard.d.ts.map +1 -1
  64. package/dist/testing/audit_drift_guard.js +15 -8
  65. package/dist/testing/cross_backend/audit_cross_helpers.d.ts +12 -9
  66. package/dist/testing/cross_backend/audit_cross_helpers.d.ts.map +1 -1
  67. package/dist/testing/cross_backend/audit_cross_helpers.js +13 -14
  68. package/dist/testing/cross_backend/capabilities.d.ts +9 -6
  69. package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
  70. package/dist/testing/cross_backend/capabilities.js +11 -7
  71. package/dist/testing/cross_backend/capability_mounts.d.ts +103 -0
  72. package/dist/testing/cross_backend/capability_mounts.d.ts.map +1 -0
  73. package/dist/testing/cross_backend/capability_mounts.js +423 -0
  74. package/dist/testing/cross_backend/cell_moderate.js +2 -2
  75. package/dist/testing/cross_backend/cell_relations.d.ts.map +1 -1
  76. package/dist/testing/cross_backend/cell_relations.js +12 -11
  77. package/dist/testing/cross_backend/conformance_principal.d.ts +54 -0
  78. package/dist/testing/cross_backend/conformance_principal.d.ts.map +1 -0
  79. package/dist/testing/cross_backend/conformance_principal.js +283 -0
  80. package/dist/testing/cross_backend/conformance_table.d.ts +2 -50
  81. package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
  82. package/dist/testing/cross_backend/conformance_table.js +2 -270
  83. package/dist/testing/cross_backend/credential_deadline.d.ts.map +1 -1
  84. package/dist/testing/cross_backend/credential_deadline.js +2 -0
  85. package/dist/testing/cross_backend/credential_wire.d.ts +1 -1
  86. package/dist/testing/cross_backend/credential_wire.d.ts.map +1 -1
  87. package/dist/testing/cross_backend/db_state_diff.d.ts +72 -0
  88. package/dist/testing/cross_backend/db_state_diff.d.ts.map +1 -0
  89. package/dist/testing/cross_backend/db_state_diff.js +444 -0
  90. package/dist/testing/cross_backend/declared_skips.d.ts +68 -0
  91. package/dist/testing/cross_backend/declared_skips.d.ts.map +1 -0
  92. package/dist/testing/cross_backend/declared_skips.js +132 -0
  93. package/dist/testing/cross_backend/differential.d.ts +11 -2
  94. package/dist/testing/cross_backend/differential.d.ts.map +1 -1
  95. package/dist/testing/cross_backend/differential.js +35 -11
  96. package/dist/testing/cross_backend/differential_normalize.d.ts +12 -0
  97. package/dist/testing/cross_backend/differential_normalize.d.ts.map +1 -1
  98. package/dist/testing/cross_backend/differential_normalize.js +16 -0
  99. package/dist/testing/cross_backend/in_process_setup.d.ts +22 -12
  100. package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
  101. package/dist/testing/cross_backend/in_process_setup.js +151 -134
  102. package/dist/testing/cross_backend/login_security.d.ts +12 -0
  103. package/dist/testing/cross_backend/login_security.d.ts.map +1 -1
  104. package/dist/testing/cross_backend/login_security.js +21 -4
  105. package/dist/testing/cross_backend/request_target_conformance_wire.d.ts +0 -2
  106. package/dist/testing/cross_backend/request_target_conformance_wire.d.ts.map +1 -1
  107. package/dist/testing/cross_backend/request_target_conformance_wire.js +3 -1
  108. package/dist/testing/cross_backend/revocation_drivers.d.ts +18 -5
  109. package/dist/testing/cross_backend/revocation_drivers.d.ts.map +1 -1
  110. package/dist/testing/cross_backend/revocation_drivers.js +18 -10
  111. package/dist/testing/cross_backend/role_grant_cross_helpers.d.ts +1 -1
  112. package/dist/testing/cross_backend/role_grant_cross_helpers.d.ts.map +1 -1
  113. package/dist/testing/cross_backend/role_grant_offer_lifecycle.d.ts.map +1 -1
  114. package/dist/testing/cross_backend/role_grant_offer_lifecycle.js +33 -1
  115. package/dist/testing/cross_backend/role_grant_participation.js +4 -4
  116. package/dist/testing/cross_backend/rpc_adversarial.js +1 -1
  117. package/dist/testing/cross_backend/session_cap.d.ts +2 -2
  118. package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
  119. package/dist/testing/cross_backend/session_cap.js +22 -11
  120. package/dist/testing/cross_backend/setup.d.ts +31 -1
  121. package/dist/testing/cross_backend/setup.d.ts.map +1 -1
  122. package/dist/testing/cross_backend/setup.js +32 -1
  123. package/dist/testing/cross_backend/spine_suites.d.ts +123 -12
  124. package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
  125. package/dist/testing/cross_backend/spine_suites.js +454 -57
  126. package/dist/testing/cross_backend/spine_surface_constants.d.ts +1 -1
  127. package/dist/testing/cross_backend/spine_surface_constants.d.ts.map +1 -1
  128. package/dist/testing/cross_backend/spine_surface_constants.js +1 -0
  129. package/dist/testing/cross_backend/sse_round_trip.d.ts +9 -1
  130. package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
  131. package/dist/testing/cross_backend/sse_round_trip.js +123 -27
  132. package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
  133. package/dist/testing/cross_backend/testing_backdoor.js +4 -2
  134. package/dist/testing/cross_backend/testing_reset_actions.d.ts +59 -27
  135. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  136. package/dist/testing/cross_backend/testing_reset_actions.js +66 -42
  137. package/dist/testing/cross_backend/transport_composition.d.ts +1 -1
  138. package/dist/testing/cross_backend/transport_composition.d.ts.map +1 -1
  139. package/dist/testing/cross_backend/transport_composition.js +7 -3
  140. package/dist/testing/cross_backend/ws_round_trip.d.ts +5 -0
  141. package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
  142. package/dist/testing/cross_backend/ws_round_trip.js +54 -8
  143. package/dist/testing/data_exposure.d.ts.map +1 -1
  144. package/dist/testing/data_exposure.js +3 -0
  145. package/dist/testing/db.d.ts +0 -32
  146. package/dist/testing/db.d.ts.map +1 -1
  147. package/dist/testing/db.js +0 -86
  148. package/dist/testing/db_entities.d.ts +14 -0
  149. package/dist/testing/db_entities.d.ts.map +1 -1
  150. package/dist/testing/db_entities.js +17 -0
  151. package/dist/testing/db_invariant_queries.d.ts +259 -0
  152. package/dist/testing/db_invariant_queries.d.ts.map +1 -0
  153. package/dist/testing/db_invariant_queries.js +400 -0
  154. package/dist/testing/db_invariants.d.ts +106 -0
  155. package/dist/testing/db_invariants.d.ts.map +1 -0
  156. package/dist/testing/db_invariants.gen.sql.d.ts +11 -0
  157. package/dist/testing/db_invariants.gen.sql.d.ts.map +1 -0
  158. package/dist/testing/db_invariants.gen.sql.js +13 -0
  159. package/dist/testing/db_invariants.js +141 -0
  160. package/dist/testing/db_invariants.sql +152 -0
  161. package/dist/testing/describe_db.d.ts +36 -0
  162. package/dist/testing/describe_db.d.ts.map +1 -0
  163. package/dist/testing/describe_db.js +71 -0
  164. package/dist/testing/integration.d.ts +6 -9
  165. package/dist/testing/integration.d.ts.map +1 -1
  166. package/dist/testing/integration.js +9 -13
  167. package/dist/testing/integration_helpers.d.ts +1 -1
  168. package/dist/testing/integration_helpers.d.ts.map +1 -1
  169. package/dist/testing/rate_limiting.d.ts +1 -1
  170. package/dist/testing/rate_limiting.d.ts.map +1 -1
  171. package/dist/testing/rate_limiting.js +3 -2
  172. package/dist/testing/role_grant_helpers.d.ts +1 -1
  173. package/dist/testing/role_grant_helpers.d.ts.map +1 -1
  174. package/dist/testing/round_trip.d.ts.map +1 -1
  175. package/dist/testing/round_trip.js +3 -0
  176. package/dist/testing/rpc_attack_surface.d.ts +8 -6
  177. package/dist/testing/rpc_attack_surface.d.ts.map +1 -1
  178. package/dist/testing/rpc_attack_surface.js +69 -6
  179. package/dist/testing/rpc_round_trip.d.ts +1 -1
  180. package/dist/testing/rpc_round_trip.d.ts.map +1 -1
  181. package/dist/testing/rpc_round_trip.js +3 -0
  182. package/dist/testing/sse_round_trip.d.ts +1 -1
  183. package/dist/testing/sse_round_trip.d.ts.map +1 -1
  184. package/dist/testing/sse_round_trip.js +13 -4
  185. package/dist/testing/stubs.d.ts +4 -2
  186. package/dist/testing/stubs.d.ts.map +1 -1
  187. package/dist/testing/stubs.js +10 -5
  188. package/dist/testing/test_app.d.ts +166 -0
  189. package/dist/testing/test_app.d.ts.map +1 -0
  190. package/dist/testing/test_app.js +124 -0
  191. package/package.json +1 -1
@@ -0,0 +1,106 @@
1
+ import './assert_dev_env.js';
2
+ /**
3
+ * The per-test database invariant check — the hooks `create_test_app` and the
4
+ * cross-process setup register, over the invariants and their statement in
5
+ * `db_invariant_queries.ts`. In-process the check queries the test app's own
6
+ * `Db` (`assert_db_invariants`); cross-process it reads the backend's
7
+ * `_testing_db_invariants` backdoor (`assert_db_invariant_rows`).
8
+ *
9
+ * @module
10
+ */
11
+ import { type RunnerTask } from 'vitest';
12
+ import type { QueryDeps } from '../db/query_deps.js';
13
+ import { type DbInvariantExclusions, type DbInvariantRow } from './db_invariant_queries.js';
14
+ /**
15
+ * Validate a setup's exclusions and log them, one line naming each with its
16
+ * reason, so a run shows what it leaves unchecked. Validates on every call
17
+ * and logs a label's set once per module instance, since a direct
18
+ * `create_test_app` caller builds an app per test. Silent when there are none.
19
+ *
20
+ * @param exclude - the setup's exclusions
21
+ * @param label - names the setup
22
+ * @throws Error on an unknown invariant or an empty reason
23
+ */
24
+ export declare const announce_db_invariant_exclusions: (exclude: DbInvariantExclusions | undefined, label: string) => void;
25
+ /**
26
+ * Throw when any row not excluded breaks an invariant — the check over rows
27
+ * a backend's `_testing_db_invariants` answered.
28
+ *
29
+ * @param rows - every violating row
30
+ * @param label - names the database in the message
31
+ * @param exclude - invariants to skip, each with its reason
32
+ * @throws Error listing every broken invariant and its rows
33
+ */
34
+ export declare const assert_db_invariant_rows: (rows: ReadonlyArray<DbInvariantRow>, label: string, exclude?: DbInvariantExclusions) => void;
35
+ /**
36
+ * Throw when any invariant not excluded is broken.
37
+ *
38
+ * @param deps - the database to read
39
+ * @param label - names the database in the message
40
+ * @param exclude - invariants to skip, each with its reason
41
+ * @throws Error listing every broken invariant and its rows
42
+ */
43
+ export declare const assert_db_invariants: (deps: QueryDeps, label: string, exclude?: DbInvariantExclusions) => Promise<void>;
44
+ /**
45
+ * Run `check` when the current test finishes — the per-test hook
46
+ * `create_test_app` registers when it builds an app (in-process, and so every
47
+ * `default_in_process_setup` fixture) and the cross-process setup registers
48
+ * from `setup_test()`, with `check` the app's or fixture's
49
+ * `assert_db_invariants`.
50
+ *
51
+ * Runs after the test body and its `afterEach` hooks, before the next test's
52
+ * setup resets the database. A test that already failed is left as it
53
+ * failed: its state proves nothing more. Outside a test — an app or fixture built in
54
+ * `beforeAll`, shared by a describe's tests — nothing is registered, and the
55
+ * suite checks the fixture once its tests are done
56
+ * (`check_db_invariants_after_all`).
57
+ *
58
+ * Under `describe.concurrent` the hook attaches to whichever test vitest
59
+ * names current, and two tests' rows share one database, so a violation can
60
+ * fail a sibling of the test that left it; the shipped concurrent suite
61
+ * builds its fixture in `beforeAll` and is checked once after all its tests.
62
+ *
63
+ * @param check - throws on a violation
64
+ * @returns whether a hook was registered — `false` outside a test
65
+ */
66
+ export declare const register_db_invariants_check: (check: () => Promise<void>) => boolean;
67
+ /**
68
+ * Check a describe-scoped fixture's database now, unless a test of `suite`
69
+ * failed or no fixture was built — the body of the suite-level check, for a
70
+ * describe's own `afterAll` that runs it ahead of its cleanup (a
71
+ * `create_test_app` app the describe closes, a database its factory closes):
72
+ *
73
+ * ```ts
74
+ * afterAll(async ({}, suite) => {
75
+ * try {
76
+ * await check_db_invariants_after_suite(suite, test_app);
77
+ * } finally {
78
+ * await test_app.cleanup();
79
+ * }
80
+ * });
81
+ * ```
82
+ *
83
+ * @param suite - the describe's task, the `afterAll` hook's second argument
84
+ * @param fixture - the shared fixture or test app, `null` or `undefined` until built
85
+ * @throws Error listing every broken invariant and its rows
86
+ */
87
+ export declare const check_db_invariants_after_suite: (suite: RunnerTask, fixture: {
88
+ readonly assert_db_invariants: () => Promise<void>;
89
+ } | null | undefined) => Promise<void>;
90
+ /**
91
+ * Check a describe-scoped fixture's database once the describe's tests are
92
+ * done — the suite-level twin of the per-test hook, for a fixture built in
93
+ * `beforeAll` and shared by the describe (the per-describe round-trip and
94
+ * exposure suites), or a `create_test_app` app built there, which registers
95
+ * no per-test hook. Skipped when a test of the describe failed, or when no
96
+ * fixture was built. Call inside the `describe`, at collection. It registers
97
+ * an `afterAll` of its own, so it reads a fixture nothing closes in another
98
+ * `afterAll`; a describe that closes its app or database there calls
99
+ * `check_db_invariants_after_suite` in that hook, ahead of the close.
100
+ *
101
+ * @param get_fixture - the shared fixture, `null` or `undefined` until built
102
+ */
103
+ export declare const check_db_invariants_after_all: (get_fixture: () => {
104
+ readonly assert_db_invariants: () => Promise<void>;
105
+ } | null | undefined) => void;
106
+ //# sourceMappingURL=db_invariants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"db_invariants.d.ts","sourceRoot":"","sources":["../../src/lib/testing/db_invariants.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAE7B;;;;;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invariants.sql`, the statement `DB_INVARIANTS_SQL` composes —
5
+ * the copy the Rust spine's `fuz_testing` embeds byte for byte for its
6
+ * `_testing_db_invariants` backdoor.
7
+ *
8
+ * @nodocs
9
+ */
10
+ export declare const gen: Gen;
11
+ //# sourceMappingURL=db_invariants.gen.sql.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"db_invariants.gen.sql.d.ts","sourceRoot":"","sources":["../../src/lib/testing/db_invariants.gen.sql.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAI9C;;;;;;GAMG;AACH,eAAO,MAAM,GAAG,EAAE,GAGhB,CAAC"}
@@ -0,0 +1,13 @@
1
+ import './assert_dev_env.js';
2
+ import { DB_INVARIANTS_SQL } from './db_invariant_queries.js';
3
+ /**
4
+ * Writes `db_invariants.sql`, the statement `DB_INVARIANTS_SQL` composes —
5
+ * the copy the Rust spine's `fuz_testing` embeds byte for byte for its
6
+ * `_testing_db_invariants` backdoor.
7
+ *
8
+ * @nodocs
9
+ */
10
+ export const gen = ({ origin_path }) => ({
11
+ content: `-- generated by ${origin_path}: the database invariants, $1 the keeper role and $2 the admin role\n${DB_INVARIANTS_SQL}\n`,
12
+ format: false
13
+ });
@@ -0,0 +1,141 @@
1
+ import './assert_dev_env.js';
2
+ /**
3
+ * The per-test database invariant check — the hooks `create_test_app` and the
4
+ * cross-process setup register, over the invariants and their statement in
5
+ * `db_invariant_queries.ts`. In-process the check queries the test app's own
6
+ * `Db` (`assert_db_invariants`); cross-process it reads the backend's
7
+ * `_testing_db_invariants` backdoor (`assert_db_invariant_rows`).
8
+ *
9
+ * @module
10
+ */
11
+ import { afterAll, onTestFinished, TestRunner } from 'vitest';
12
+ import { format_db_invariant_violations, query_db_invariant_violations, to_db_invariant_violations, validate_db_invariant_exclusions } from './db_invariant_queries.js';
13
+ /** The exclusion sets already logged, by label and set — the log's dedupe. */
14
+ const announced_db_invariant_exclusions = new Set();
15
+ /**
16
+ * Validate a setup's exclusions and log them, one line naming each with its
17
+ * reason, so a run shows what it leaves unchecked. Validates on every call
18
+ * and logs a label's set once per module instance, since a direct
19
+ * `create_test_app` caller builds an app per test. Silent when there are none.
20
+ *
21
+ * @param exclude - the setup's exclusions
22
+ * @param label - names the setup
23
+ * @throws Error on an unknown invariant or an empty reason
24
+ */
25
+ export const announce_db_invariant_exclusions = (exclude, label) => {
26
+ validate_db_invariant_exclusions(exclude, label);
27
+ const entries = Object.entries(exclude ?? {});
28
+ if (entries.length === 0)
29
+ return;
30
+ const key = JSON.stringify([label, entries.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))]);
31
+ if (announced_db_invariant_exclusions.has(key))
32
+ return;
33
+ announced_db_invariant_exclusions.add(key);
34
+ console.log(`[db invariants] ${label} excludes ${entries.map(([name, reason]) => `${name} (${reason})`).join('; ')}`);
35
+ };
36
+ /**
37
+ * Throw when any row not excluded breaks an invariant — the check over rows
38
+ * a backend's `_testing_db_invariants` answered.
39
+ *
40
+ * @param rows - every violating row
41
+ * @param label - names the database in the message
42
+ * @param exclude - invariants to skip, each with its reason
43
+ * @throws Error listing every broken invariant and its rows
44
+ */
45
+ export const assert_db_invariant_rows = (rows, label, exclude) => {
46
+ const violations = to_db_invariant_violations(rows, exclude);
47
+ if (violations.length > 0)
48
+ throw new Error(format_db_invariant_violations(violations, label));
49
+ };
50
+ /**
51
+ * Throw when any invariant not excluded is broken.
52
+ *
53
+ * @param deps - the database to read
54
+ * @param label - names the database in the message
55
+ * @param exclude - invariants to skip, each with its reason
56
+ * @throws Error listing every broken invariant and its rows
57
+ */
58
+ export const assert_db_invariants = async (deps, label, exclude) => {
59
+ const violations = await query_db_invariant_violations(deps, exclude);
60
+ if (violations.length > 0)
61
+ throw new Error(format_db_invariant_violations(violations, label));
62
+ };
63
+ /**
64
+ * Run `check` when the current test finishes — the per-test hook
65
+ * `create_test_app` registers when it builds an app (in-process, and so every
66
+ * `default_in_process_setup` fixture) and the cross-process setup registers
67
+ * from `setup_test()`, with `check` the app's or fixture's
68
+ * `assert_db_invariants`.
69
+ *
70
+ * Runs after the test body and its `afterEach` hooks, before the next test's
71
+ * setup resets the database. A test that already failed is left as it
72
+ * failed: its state proves nothing more. Outside a test — an app or fixture built in
73
+ * `beforeAll`, shared by a describe's tests — nothing is registered, and the
74
+ * suite checks the fixture once its tests are done
75
+ * (`check_db_invariants_after_all`).
76
+ *
77
+ * Under `describe.concurrent` the hook attaches to whichever test vitest
78
+ * names current, and two tests' rows share one database, so a violation can
79
+ * fail a sibling of the test that left it; the shipped concurrent suite
80
+ * builds its fixture in `beforeAll` and is checked once after all its tests.
81
+ *
82
+ * @param check - throws on a violation
83
+ * @returns whether a hook was registered — `false` outside a test
84
+ */
85
+ export const register_db_invariants_check = (check) => {
86
+ if (!TestRunner.getCurrentTest())
87
+ return false;
88
+ onTestFinished(async ({ task }) => {
89
+ if (task.result?.state === 'fail')
90
+ return;
91
+ await check();
92
+ });
93
+ return true;
94
+ };
95
+ /** Whether `task` or any task under it failed. */
96
+ const task_failed = (task) => task.result?.state === 'fail' || (task.type === 'suite' && task.tasks.some(task_failed));
97
+ /**
98
+ * Check a describe-scoped fixture's database now, unless a test of `suite`
99
+ * failed or no fixture was built — the body of the suite-level check, for a
100
+ * describe's own `afterAll` that runs it ahead of its cleanup (a
101
+ * `create_test_app` app the describe closes, a database its factory closes):
102
+ *
103
+ * ```ts
104
+ * afterAll(async ({}, suite) => {
105
+ * try {
106
+ * await check_db_invariants_after_suite(suite, test_app);
107
+ * } finally {
108
+ * await test_app.cleanup();
109
+ * }
110
+ * });
111
+ * ```
112
+ *
113
+ * @param suite - the describe's task, the `afterAll` hook's second argument
114
+ * @param fixture - the shared fixture or test app, `null` or `undefined` until built
115
+ * @throws Error listing every broken invariant and its rows
116
+ */
117
+ export const check_db_invariants_after_suite = async (suite, fixture) => {
118
+ if (!fixture || task_failed(suite))
119
+ return;
120
+ await fixture.assert_db_invariants();
121
+ };
122
+ /**
123
+ * Check a describe-scoped fixture's database once the describe's tests are
124
+ * done — the suite-level twin of the per-test hook, for a fixture built in
125
+ * `beforeAll` and shared by the describe (the per-describe round-trip and
126
+ * exposure suites), or a `create_test_app` app built there, which registers
127
+ * no per-test hook. Skipped when a test of the describe failed, or when no
128
+ * fixture was built. Call inside the `describe`, at collection. It registers
129
+ * an `afterAll` of its own, so it reads a fixture nothing closes in another
130
+ * `afterAll`; a describe that closes its app or database there calls
131
+ * `check_db_invariants_after_suite` in that hook, ahead of the close.
132
+ *
133
+ * @param get_fixture - the shared fixture, `null` or `undefined` until built
134
+ */
135
+ export const check_db_invariants_after_all = (get_fixture) => {
136
+ // vitest requires the hook's context argument to be a destructuring pattern
137
+ // eslint-disable-next-line no-empty-pattern
138
+ afterAll(async ({}, suite) => {
139
+ await check_db_invariants_after_suite(suite, get_fixture());
140
+ });
141
+ };
@@ -0,0 +1,152 @@
1
+ -- generated by src/lib/testing/db_invariants.gen.sql.ts: the database invariants, $1 the keeper role and $2 the admin role
2
+ WITH
3
+ role_param AS (SELECT $1::text AS keeper, $2::text AS admin),
4
+ removal AS (
5
+ SELECT target_account_id AS account_id, event_type, seq, created_at
6
+ FROM audit_log
7
+ WHERE outcome = 'success'
8
+ AND event_type IN ('account_delete', 'account_purge')
9
+ AND target_account_id IS NOT NULL
10
+ ),
11
+ offer_party AS (
12
+ SELECT o.id, o.from_actor_id, fa.account_id AS from_account_id, o.to_account_id,
13
+ o.to_actor_id, o.created_at,
14
+ (SELECT MIN(al.seq) FROM audit_log al
15
+ WHERE al.event_type = 'role_grant_offer_create' AND al.outcome = 'success'
16
+ AND al.metadata->>'offer_id' = o.id::text) AS create_seq
17
+ FROM role_grant_offer o
18
+ JOIN actor fa ON fa.id = o.from_actor_id
19
+ WHERE o.accepted_at IS NULL AND o.declined_at IS NULL AND o.retracted_at IS NULL AND o.superseded_at IS NULL
20
+ ),
21
+ invite_issuer AS (
22
+ SELECT i.id, i.created_by, i.created_at, a.deleted_at IS NOT NULL AS actor_dead,
23
+ COALESCE(a.account_id, (SELECT al.account_id FROM audit_log al
24
+ WHERE al.event_type = 'invite_create' AND al.outcome = 'success'
25
+ AND al.metadata->>'invite_id' = i.id::text
26
+ ORDER BY al.seq LIMIT 1)) AS issuer_account_id,
27
+ (SELECT MIN(al.seq) FROM audit_log al
28
+ WHERE al.event_type = 'invite_create' AND al.outcome = 'success'
29
+ AND al.metadata->>'invite_id' = i.id::text) AS create_seq
30
+ FROM invite i
31
+ LEFT JOIN actor a ON a.id = i.created_by
32
+ WHERE i.claimed_at IS NULL
33
+ ),
34
+ token_issued AS (
35
+ SELECT t.id, t.account_id, t.created_at,
36
+ (SELECT MIN(al.seq) FROM audit_log al
37
+ WHERE al.event_type = 'token_create' AND al.outcome = 'success'
38
+ AND al.metadata->>'token_id' = t.id) AS create_seq
39
+ FROM api_token t
40
+ )
41
+ SELECT 'credential_of_tombstoned_account' AS invariant, jsonb_build_object('kind', v.kind, 'id', v.id, 'account_id', v.account_id)::text AS row FROM (SELECT 'auth_session' AS kind, LEFT(s.id, 12) AS id, s.account_id
42
+ FROM auth_session s JOIN account ac ON ac.id = s.account_id
43
+ WHERE ac.deleted_at IS NOT NULL
44
+ UNION ALL
45
+ SELECT 'api_token' AS kind, t.id, t.account_id
46
+ FROM api_token t JOIN account ac ON ac.id = t.account_id
47
+ WHERE ac.deleted_at IS NOT NULL) v
48
+ UNION ALL
49
+ SELECT 'pending_offer_with_dead_party' AS invariant, jsonb_build_object('id', v.id, 'from_actor_id', v.from_actor_id, 'from_account_id', v.from_account_id, 'to_account_id', v.to_account_id, 'to_actor_id', v.to_actor_id, 'from_actor_dead', v.from_actor_dead, 'from_account_dead', v.from_account_dead, 'to_account_dead', v.to_account_dead, 'to_actor_dead', v.to_actor_dead)::text AS row FROM (SELECT op.id, op.from_actor_id, op.from_account_id, op.to_account_id, op.to_actor_id,
50
+ fa.deleted_at IS NOT NULL AS from_actor_dead,
51
+ fac.deleted_at IS NOT NULL AS from_account_dead,
52
+ ta.deleted_at IS NOT NULL AS to_account_dead,
53
+ COALESCE(tac.deleted_at IS NOT NULL, false) AS to_actor_dead
54
+ FROM offer_party op
55
+ JOIN actor fa ON fa.id = op.from_actor_id
56
+ JOIN account fac ON fac.id = op.from_account_id
57
+ JOIN account ta ON ta.id = op.to_account_id
58
+ LEFT JOIN actor tac ON tac.id = op.to_actor_id
59
+ WHERE fa.deleted_at IS NOT NULL OR fac.deleted_at IS NOT NULL
60
+ OR ta.deleted_at IS NOT NULL OR tac.deleted_at IS NOT NULL) v
61
+ UNION ALL
62
+ SELECT 'unclaimed_invite_of_dead_issuer' AS invariant, jsonb_build_object('id', v.id, 'created_by', v.created_by, 'issuer_account_id', v.issuer_account_id, 'actor_dead', v.actor_dead, 'issuer_purged', v.issuer_purged)::text AS row FROM (SELECT ii.id, ii.created_by, ii.issuer_account_id,
63
+ ii.actor_dead, ac.id IS NULL AS issuer_purged
64
+ FROM invite_issuer ii
65
+ LEFT JOIN account ac ON ac.id = ii.issuer_account_id
66
+ WHERE ii.issuer_account_id IS NOT NULL
67
+ AND (ii.actor_dead OR ac.id IS NULL OR ac.deleted_at IS NOT NULL)) v
68
+ UNION ALL
69
+ SELECT 'bootstrapped_without_live_keeper' AS invariant, jsonb_build_object('bootstrapped', v.bootstrapped)::text AS row FROM (SELECT true AS bootstrapped FROM bootstrap_lock
70
+ WHERE bootstrapped AND NOT EXISTS (
71
+ SELECT 1 FROM role_grant rg
72
+ JOIN actor a ON a.id = rg.actor_id
73
+ JOIN account ac ON ac.id = a.account_id
74
+ WHERE rg.role = (SELECT keeper FROM role_param)
75
+ AND rg.scope_id IS NULL
76
+ AND rg.revoked_at IS NULL AND (rg.expires_at IS NULL OR rg.expires_at > NOW())
77
+ AND a.deleted_at IS NULL
78
+ AND ac.deleted_at IS NULL
79
+ )) v
80
+ UNION ALL
81
+ SELECT 'bootstrapped_without_live_admin' AS invariant, jsonb_build_object('bootstrapped', v.bootstrapped)::text AS row FROM (SELECT true AS bootstrapped FROM bootstrap_lock
82
+ WHERE bootstrapped AND NOT EXISTS (
83
+ SELECT 1 FROM role_grant rg
84
+ JOIN actor a ON a.id = rg.actor_id
85
+ JOIN account ac ON ac.id = a.account_id
86
+ WHERE rg.role = (SELECT admin FROM role_param)
87
+ AND rg.scope_id IS NULL
88
+ AND rg.revoked_at IS NULL AND (rg.expires_at IS NULL OR rg.expires_at > NOW())
89
+ AND a.deleted_at IS NULL
90
+ AND ac.deleted_at IS NULL
91
+ )) v
92
+ UNION ALL
93
+ SELECT 'account_without_bootstrap' AS invariant, jsonb_build_object('account_id', v.account_id)::text AS row FROM (SELECT ac.id AS account_id FROM account ac
94
+ WHERE NOT EXISTS (SELECT 1 FROM bootstrap_lock WHERE bootstrapped)) v
95
+ UNION ALL
96
+ SELECT 'actor_tombstone_disagrees_with_account' AS invariant, jsonb_build_object('actor_id', v.actor_id, 'account_id', v.account_id, 'actor_dead', v.actor_dead, 'account_dead', v.account_dead)::text AS row FROM (SELECT a.id AS actor_id, a.account_id,
97
+ a.deleted_at IS NOT NULL AS actor_dead, ac.deleted_at IS NOT NULL AS account_dead
98
+ FROM actor a JOIN account ac ON ac.id = a.account_id
99
+ WHERE (a.deleted_at IS NULL) <> (ac.deleted_at IS NULL)) v
100
+ UNION ALL
101
+ SELECT 'offer_to_actor_outside_to_account' AS invariant, jsonb_build_object('id', v.id, 'to_account_id', v.to_account_id, 'to_actor_id', v.to_actor_id, 'to_actor_account_id', v.to_actor_account_id)::text AS row FROM (SELECT o.id, o.to_account_id, o.to_actor_id, a.account_id AS to_actor_account_id
102
+ FROM role_grant_offer o JOIN actor a ON a.id = o.to_actor_id
103
+ WHERE a.account_id <> o.to_account_id) v
104
+ UNION ALL
105
+ SELECT 'invite_claimed_by_without_claimed_at' AS invariant, jsonb_build_object('id', v.id, 'claimed_by', v.claimed_by)::text AS row FROM (SELECT i.id, i.claimed_by FROM invite i
106
+ WHERE i.claimed_by IS NOT NULL AND i.claimed_at IS NULL) v
107
+ UNION ALL
108
+ SELECT 'pending_offer_outlived_party_removal' AS invariant, jsonb_build_object('id', v.id, 'from_actor_id', v.from_actor_id, 'from_account_id', v.from_account_id, 'to_account_id', v.to_account_id)::text AS row FROM (SELECT op.id, op.from_actor_id, op.from_account_id, op.to_account_id
109
+ FROM offer_party op
110
+ WHERE EXISTS (
111
+ SELECT 1 FROM removal r
112
+ WHERE r.account_id = op.from_account_id
113
+ AND r.event_type IN ('account_delete')
114
+ AND CASE WHEN op.create_seq IS NULL THEN r.created_at >= op.created_at
115
+ ELSE r.seq > op.create_seq END
116
+ )
117
+ OR EXISTS (
118
+ SELECT 1 FROM removal r
119
+ WHERE r.account_id = op.to_account_id
120
+ AND r.event_type IN ('account_delete')
121
+ AND CASE WHEN op.create_seq IS NULL THEN r.created_at >= op.created_at
122
+ ELSE r.seq > op.create_seq END
123
+ )) v
124
+ UNION ALL
125
+ SELECT 'unclaimed_invite_outlived_issuer_removal' AS invariant, jsonb_build_object('id', v.id, 'created_by', v.created_by, 'issuer_account_id', v.issuer_account_id)::text AS row FROM (SELECT ii.id, ii.created_by, ii.issuer_account_id
126
+ FROM invite_issuer ii
127
+ WHERE EXISTS (
128
+ SELECT 1 FROM removal r
129
+ WHERE r.account_id = ii.issuer_account_id
130
+ AND r.event_type IN ('account_delete', 'account_purge')
131
+ AND CASE WHEN ii.create_seq IS NULL THEN r.created_at >= ii.created_at
132
+ ELSE r.seq > ii.create_seq END
133
+ )) v
134
+ UNION ALL
135
+ SELECT 'credential_outlived_account_removal' AS invariant, jsonb_build_object('kind', v.kind, 'id', v.id, 'account_id', v.account_id)::text AS row FROM (SELECT 'auth_session' AS kind, LEFT(s.id, 12) AS id, s.account_id
136
+ FROM auth_session s
137
+ WHERE EXISTS (
138
+ SELECT 1 FROM removal r
139
+ WHERE r.account_id = s.account_id
140
+ AND r.event_type IN ('account_delete')
141
+ AND r.created_at >= s.created_at
142
+ )
143
+ UNION ALL
144
+ SELECT 'api_token' AS kind, ti.id, ti.account_id
145
+ FROM token_issued ti
146
+ WHERE EXISTS (
147
+ SELECT 1 FROM removal r
148
+ WHERE r.account_id = ti.account_id
149
+ AND r.event_type IN ('account_delete')
150
+ AND CASE WHEN ti.create_seq IS NULL THEN r.created_at >= ti.created_at
151
+ ELSE r.seq > ti.create_seq END
152
+ )) v
@@ -0,0 +1,36 @@
1
+ import './assert_dev_env.js';
2
+ import type { Db } from '../db/db.js';
3
+ import type { DbFactory } from './db.js';
4
+ /**
5
+ * Create a `describe_db` function bound to specific factories and truncate tables.
6
+ *
7
+ * Returns a 2-arg `(name, fn)` function that runs the test suite against each
8
+ * factory. Each factory gets its own `describe` block with a shared database
9
+ * instance, automatic `beforeEach` truncation, and `afterAll` cleanup.
10
+ * Skipped factories use `describe.skip`.
11
+ *
12
+ * @param factories - one or more database factories to run suites against
13
+ * @param truncate_tables - tables to truncate between tests (children first for FK safety)
14
+ * @mutates the underlying database between tests — `beforeEach` issues
15
+ * `TRUNCATE <truncate_tables> CASCADE` against the shared instance.
16
+ */
17
+ export declare const create_describe_db: (factories: DbFactory | Array<DbFactory>, truncate_tables: Array<string>) => ((name: string, fn: (get_db: () => Db) => void) => void);
18
+ /**
19
+ * Assert a `*_COLUMNS` projection const names exactly the live columns of
20
+ * `table` — the drift guard for an exported const (`ACCOUNT_COLUMNS`,
21
+ * `CELL_COLUMNS`, a consumer's own).
22
+ *
23
+ * This is the reverse of the fail-loud read: a named projection makes a
24
+ * *dropped* column fail loud at query time, but a column *added* to the table
25
+ * and not to the projection would silently vanish from every row read. Both
26
+ * directions are covered by the equality here. It guards one const; it can't
27
+ * see a table that has *no* const — for that, keep a table → const registry
28
+ * and assert its key set against `query_public_columns` (fuz_app's own is
29
+ * `src/test/db/column_projections.db.test.ts`).
30
+ *
31
+ * @param db - a bootstrapped test database
32
+ * @param table - the `public`-schema table the const projects
33
+ * @param columns - the projection const's column names
34
+ */
35
+ export declare const assert_columns_match_live: (db: Db, table: string, columns: ReadonlyArray<string>) => Promise<void>;
36
+ //# sourceMappingURL=describe_db.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"describe_db.d.ts","sourceRoot":"","sources":["../../src/lib/testing/describe_db.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAa7B,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAGtC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,kBAAkB,GAC9B,WAAW,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC,EACvC,iBAAiB,KAAK,CAAC,MAAM,CAAC,KAC5B,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,IAAI,KAAK,IAAI,CAwBzD,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,yBAAyB,GACrC,IAAI,EAAE,EACN,OAAO,MAAM,EACb,SAAS,aAAa,CAAC,MAAM,CAAC,KAC5B,OAAO,CAAC,IAAI,CAId,CAAC"}
@@ -0,0 +1,71 @@
1
+ import './assert_dev_env.js';
2
+ /**
3
+ * The vitest-bound database test helpers: `create_describe_db`, which runs a
4
+ * suite once per `DbFactory` (`testing/db.ts`), and `assert_columns_match_live`,
5
+ * the named-projection drift guard. Apart from `testing/db.ts` so the
6
+ * factories stay vitest-free for the spawned spine binary.
7
+ *
8
+ * @module
9
+ */
10
+ import { describe, beforeAll, beforeEach, afterAll, assert } from 'vitest';
11
+ import { assert_valid_sql_identifier } from '../db/sql_identifier.js';
12
+ import { query_public_columns } from '../db/schema_ready.js';
13
+ /**
14
+ * Create a `describe_db` function bound to specific factories and truncate tables.
15
+ *
16
+ * Returns a 2-arg `(name, fn)` function that runs the test suite against each
17
+ * factory. Each factory gets its own `describe` block with a shared database
18
+ * instance, automatic `beforeEach` truncation, and `afterAll` cleanup.
19
+ * Skipped factories use `describe.skip`.
20
+ *
21
+ * @param factories - one or more database factories to run suites against
22
+ * @param truncate_tables - tables to truncate between tests (children first for FK safety)
23
+ * @mutates the underlying database between tests — `beforeEach` issues
24
+ * `TRUNCATE <truncate_tables> CASCADE` against the shared instance.
25
+ */
26
+ export const create_describe_db = (factories, truncate_tables) => {
27
+ const factory_list = Array.isArray(factories) ? factories : [factories];
28
+ return (name, fn) => {
29
+ for (const factory of factory_list) {
30
+ const describe_fn = factory.skip ? describe.skip : describe;
31
+ describe_fn(`${name} (${factory.name})`, () => {
32
+ let db;
33
+ beforeAll(async () => {
34
+ db = await factory.create();
35
+ });
36
+ beforeEach(async () => {
37
+ if (db && truncate_tables.length > 0) {
38
+ await db.query(`TRUNCATE ${truncate_tables.map(assert_valid_sql_identifier).join(', ')} CASCADE`);
39
+ }
40
+ });
41
+ afterAll(async () => {
42
+ if (db)
43
+ await factory.close(db);
44
+ });
45
+ fn(() => db);
46
+ });
47
+ }
48
+ };
49
+ };
50
+ /**
51
+ * Assert a `*_COLUMNS` projection const names exactly the live columns of
52
+ * `table` — the drift guard for an exported const (`ACCOUNT_COLUMNS`,
53
+ * `CELL_COLUMNS`, a consumer's own).
54
+ *
55
+ * This is the reverse of the fail-loud read: a named projection makes a
56
+ * *dropped* column fail loud at query time, but a column *added* to the table
57
+ * and not to the projection would silently vanish from every row read. Both
58
+ * directions are covered by the equality here. It guards one const; it can't
59
+ * see a table that has *no* const — for that, keep a table → const registry
60
+ * and assert its key set against `query_public_columns` (fuz_app's own is
61
+ * `src/test/db/column_projections.db.test.ts`).
62
+ *
63
+ * @param db - a bootstrapped test database
64
+ * @param table - the `public`-schema table the const projects
65
+ * @param columns - the projection const's column names
66
+ */
67
+ export const assert_columns_match_live = async (db, table, columns) => {
68
+ const live = await query_public_columns(db, { table });
69
+ assert.ok(live[table], `table "${table}" is not in the live public schema`);
70
+ assert.deepEqual([...columns].sort(), live[table]);
71
+ };
@@ -96,15 +96,12 @@ export interface StandardIntegrationTestOptions {
96
96
  * message if the consumer's route specs are misconfigured.
97
97
  *
98
98
  * The two signup-invite-edge-case tests call `invite_create_action_spec`
99
- * (admin-gated) over the fixture's session, so consumers wiring signup +
100
- * admin actions must thread `extra_keeper_roles: [ROLE_ADMIN]` through
101
- * either `default_in_process_suite_options` or
102
- * `default_cross_process_setup(handle, {extra_keeper_roles:
103
- * [ROLE_ADMIN]})`. In both modes the fixture's `fixture.account` is the
104
- * fresh keeper, and the extra-keeper-roles list grants the bootstrapped
105
- * keeper additional roles inline (cross-process via `_testing_reset`'s
106
- * bootstrap-time seeding; in-process via `bootstrap_test_keeper`) — no
107
- * per-role RPC cost, no offer/accept round-trip. The tests run against
99
+ * (admin-gated) over the fixture's session. In both modes the fixture's
100
+ * `fixture.account` is the fresh keeper, holding `ROLE_KEEPER` and
101
+ * `ROLE_ADMIN` as a production bootstrap grants them (cross-process via
102
+ * `_testing_reset`'s seeding; in-process via `bootstrap_test_keeper` with
103
+ * `DEFAULT_TEST_KEEPER_ROLES`), so the invite is admitted with no
104
+ * per-role RPC cost or offer/accept round-trip. The tests run against
108
105
  * the production `open_signup: false` default — the cross-process
109
106
  * per-test secondary mint via `fixture.create_account()` is
110
107
  * invite-gated (keeper drives `invite_create` before signup) so the
@@ -1 +1 @@
1
- {"version":3,"file":"integration.d.ts","sourceRoot":"","sources":["../../src/lib/testing/integration.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAuB7B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAMhE,OAAO,EAKN,KAAK,uBAAuB,EAC5B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAIN,KAAK,cAAc,EACnB,MAAM,qBAAqB,CAAC;AAa7B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAW,KAAK,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAKpF,OAAO,KAAK,EAAE,SAAS,EAAE,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;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC9C;;;;OAIG;IACH,UAAU,EAAE,SAAS,CAAC;IACtB;;;;;;;;;OASG;IACH,cAAc,EAAE,cAAc,CAAC;IAC/B,kEAAkE;IAClE,YAAY,EAAE,mBAAmB,CAAC;IAClC;;;;OAIG;IACH,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACxC;;;;;;;;;;;OAWG;IACH,aAAa,EAAE,uBAAuB,CAAC;IACvC;;;;;;;OAOG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;;;;OAKG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;;;;OAKG;IACH,sBAAsB,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,IAAI,CAAC;CACpE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,mCAAmC,GAC/C,SAAS,8BAA8B,KACrC,IA+/CF,CAAC"}
@@ -45,15 +45,12 @@ import { assert_middleware_gate_refusal, format_middleware_gate_probe, plan_midd
45
45
  * message if the consumer's route specs are misconfigured.
46
46
  *
47
47
  * The two signup-invite-edge-case tests call `invite_create_action_spec`
48
- * (admin-gated) over the fixture's session, so consumers wiring signup +
49
- * admin actions must thread `extra_keeper_roles: [ROLE_ADMIN]` through
50
- * either `default_in_process_suite_options` or
51
- * `default_cross_process_setup(handle, {extra_keeper_roles:
52
- * [ROLE_ADMIN]})`. In both modes the fixture's `fixture.account` is the
53
- * fresh keeper, and the extra-keeper-roles list grants the bootstrapped
54
- * keeper additional roles inline (cross-process via `_testing_reset`'s
55
- * bootstrap-time seeding; in-process via `bootstrap_test_keeper`) — no
56
- * per-role RPC cost, no offer/accept round-trip. The tests run against
48
+ * (admin-gated) over the fixture's session. In both modes the fixture's
49
+ * `fixture.account` is the fresh keeper, holding `ROLE_KEEPER` and
50
+ * `ROLE_ADMIN` as a production bootstrap grants them (cross-process via
51
+ * `_testing_reset`'s seeding; in-process via `bootstrap_test_keeper` with
52
+ * `DEFAULT_TEST_KEEPER_ROLES`), so the invite is admitted with no
53
+ * per-role RPC cost or offer/accept round-trip. The tests run against
57
54
  * the production `open_signup: false` default — the cross-process
58
55
  * per-test secondary mint via `fixture.create_account()` is
59
56
  * invite-gated (keeper drives `invite_create` before signup) so the
@@ -1156,10 +1153,9 @@ export const describe_standard_integration_tests = (options) => {
1156
1153
  // Drive the admin-gated `invite_create` over the fixture's
1157
1154
  // session. In both modes the fixture is the fresh keeper,
1158
1155
  // holding `[ROLE_KEEPER, ROLE_ADMIN, ...extra_keeper_roles]`
1159
- // from the bootstrap-equivalent seed step — `extra_keeper_roles:
1160
- // [ROLE_ADMIN]` is technically redundant for the admin suite
1161
- // but harmless. `fixture.create_session_headers()` resolves to
1162
- // a session with admin role.
1156
+ // from the bootstrap-equivalent seed step, so
1157
+ // `fixture.create_session_headers()` resolves to a session with
1158
+ // the admin role.
1163
1159
  // `open_signup` stays at production default (`false`) across both
1164
1160
  // in-process (per-test bootstrap default) and cross-process (the
1165
1161
  // invite-gated `mint_account` flow doesn't need it flipped), so
@@ -2,7 +2,7 @@ import './assert_dev_env.js';
2
2
  import type { RouteSpec, RouteMethod } from '../http/route_spec.js';
3
3
  import { type RouteErrorMap } from '../http/route_errors.js';
4
4
  import { type RouteAuth } from '../http/auth_shape.js';
5
- import type { TestAccount } from './app_server.js';
5
+ import type { TestAccount } from './test_app.js';
6
6
  import type { RpcTestTransport } from './rpc_helpers.js';
7
7
  /**
8
8
  * Find the route spec a request reaches: the first in list (mount) order
@@ -1 +1 @@
1
- {"version":3,"file":"integration_helpers.d.ts","sourceRoot":"","sources":["../../src/lib/testing/integration_helpers.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAW7B,OA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