@fuzdev/fuz_app 0.143.0 → 0.144.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 (49) hide show
  1. package/dist/auth/CLAUDE.md +8 -0
  2. package/dist/auth/cell_action_specs.d.ts +13 -0
  3. package/dist/auth/cell_action_specs.d.ts.map +1 -1
  4. package/dist/auth/cell_action_specs.js +13 -0
  5. package/dist/auth/cell_actions.d.ts +7 -0
  6. package/dist/auth/cell_actions.d.ts.map +1 -1
  7. package/dist/auth/cell_actions.js +30 -0
  8. package/dist/auth/cell_ref_admission.d.ts +51 -0
  9. package/dist/auth/cell_ref_admission.d.ts.map +1 -0
  10. package/dist/auth/cell_ref_admission.js +69 -0
  11. package/dist/auth/deps.d.ts +6 -3
  12. package/dist/auth/deps.d.ts.map +1 -1
  13. package/dist/db/CLAUDE.md +34 -21
  14. package/dist/db/cell_ddl.d.ts +3 -2
  15. package/dist/db/cell_ddl.d.ts.map +1 -1
  16. package/dist/db/cell_ddl.js +3 -2
  17. package/dist/db/cell_queries.d.ts +31 -6
  18. package/dist/db/cell_queries.d.ts.map +1 -1
  19. package/dist/db/cell_queries.js +45 -18
  20. package/dist/db/fact_ddl.d.ts +29 -4
  21. package/dist/db/fact_ddl.d.ts.map +1 -1
  22. package/dist/db/fact_ddl.js +43 -4
  23. package/dist/db/fact_holder_queries.d.ts +66 -0
  24. package/dist/db/fact_holder_queries.d.ts.map +1 -0
  25. package/dist/db/fact_holder_queries.js +75 -0
  26. package/dist/db/fact_queries.d.ts +9 -7
  27. package/dist/db/fact_queries.d.ts.map +1 -1
  28. package/dist/db/fact_store.d.ts +65 -9
  29. package/dist/db/fact_store.d.ts.map +1 -1
  30. package/dist/db/fact_store.js +49 -20
  31. package/dist/server/serve_fact_route.d.ts +24 -4
  32. package/dist/server/serve_fact_route.d.ts.map +1 -1
  33. package/dist/server/serve_fact_route.js +24 -4
  34. package/dist/testing/CLAUDE.md +25 -1
  35. package/dist/testing/cross_backend/cell_crud.d.ts.map +1 -1
  36. package/dist/testing/cross_backend/cell_crud.js +6 -3
  37. package/dist/testing/cross_backend/cell_gated_create.d.ts.map +1 -1
  38. package/dist/testing/cross_backend/cell_gated_create.js +25 -16
  39. package/dist/testing/cross_backend/cell_ref_admission.d.ts +4 -0
  40. package/dist/testing/cross_backend/cell_ref_admission.d.ts.map +1 -0
  41. package/dist/testing/cross_backend/cell_ref_admission.js +268 -0
  42. package/dist/testing/cross_backend/expected_schema.json +66 -10
  43. package/dist/testing/cross_backend/fact_serving.d.ts +19 -1
  44. package/dist/testing/cross_backend/fact_serving.d.ts.map +1 -1
  45. package/dist/testing/cross_backend/fact_serving.js +31 -9
  46. package/dist/testing/cross_backend/testing_reset_actions.d.ts +6 -2
  47. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  48. package/dist/testing/cross_backend/testing_reset_actions.js +13 -3
  49. package/package.json +1 -1
@@ -0,0 +1,268 @@
1
+ import '../assert_dev_env.js';
2
+ /**
3
+ * Cross-backend parity suite for **possession-gated cell ref admission** — a
4
+ * non-admin `cell_create` / `cell_update` / `cell_clone` may introduce a fact
5
+ * ref only to a fact its acting actor holds (a `fact_holder` row, recorded on
6
+ * every put that names the actor), else `403` with reason
7
+ * `cell_ref_not_held`. Twins the Rust `fuz_cell_actions` `cell_authz` cases of
8
+ * the same names, over real HTTP:
9
+ *
10
+ * - **create admits a new ref only for a holder** — a stored fact the caller
11
+ * never put and a hash nothing is stored under are refused with one
12
+ * identical answer (status + error body — no existence oracle), as is a
13
+ * system-put fact; the uploader's public cell serves the bytes to anyone; a
14
+ * second actor putting identical bytes becomes a holder;
15
+ * - **update keeps existing refs** — an editor keeps refs another writer
16
+ * introduced, and adding an unheld one (or dropping a ref and adding it
17
+ * back) is refused;
18
+ * - **clone carries source refs per row** — a shallow and a deep clone carry
19
+ * each row's source refs without holding them; a patch adding an unheld
20
+ * ref, or carrying a child's ref onto the root, is refused;
21
+ * - **a global admin is not gated**;
22
+ * - **a revoked grantee can't re-reference** — a reader who saw a hash through
23
+ * a granted cell can't name it in a cell of its own, before or after the
24
+ * revoke (a known hash is not a read capability);
25
+ * - **extraction parity** — a ref is a whole string value exactly matching
26
+ * `blake3:` + 64 lowercase hex: a hash in prose or markup, `blake3:zz`, an
27
+ * uppercase digest, and an object key are not refs on either spine;
28
+ * - **admission answers after the masks** — an update of a hidden cell, a
29
+ * create under a hidden parent, and a clone of a hidden source answer `404`
30
+ * whatever their `data` names.
31
+ *
32
+ * Facts are put through `_testing_put_fact`, with `holder` naming the actor a
33
+ * real upload would record. Gated on `capabilities.fact_serving` (the
34
+ * seeder + the serve routes); runs under every `cross_backend_*` project.
35
+ *
36
+ * @module
37
+ */
38
+ import { describe, assert } from 'vitest';
39
+ import { CellCloneOutput, CellCreateOutput, CellGetOutput, CellUpdateOutput } from '../../auth/cell_action_specs.js';
40
+ import { CellGrantCreateOutput } from '../../auth/cell_grant_action_specs.js';
41
+ import { create_rpc_post_init } from '../rpc_helpers.js';
42
+ import { test_if } from './capabilities.js';
43
+ import { cross_rpc_call, error_reason, expect_output } from './cell_cross_helpers.js';
44
+ import { cross_put_fact } from './fact_serving.js';
45
+ import { SPINE_RPC_PATH } from './spine_surface_constants.js';
46
+ /** The admission refusal's reason, on both spines. */
47
+ const CELL_REF_NOT_HELD = 'cell_ref_not_held';
48
+ /** A well-formed hash no fact is stored under. */
49
+ const UNSTORED_HASH = `blake3:${'e'.repeat(64)}`;
50
+ /** The status + error of a refused RPC call, for comparing two refusals byte for byte. */
51
+ const refusal = async (transport, rpc_path, method, params, headers) => {
52
+ const init = create_rpc_post_init(method, params);
53
+ Object.assign(init.headers, headers);
54
+ const res = await transport(rpc_path, init);
55
+ const body = (await res.json());
56
+ assert.ok(body.error !== undefined, `expected a refusal, got ${JSON.stringify(body)}`);
57
+ return { status: res.status, error: body.error };
58
+ };
59
+ const assert_not_held = (r, label) => {
60
+ assert.ok(!r.ok, `${label}: expected a refusal, got ${JSON.stringify(r.result)}`);
61
+ assert.strictEqual(error_reason(r), CELL_REF_NOT_HELD, `${label}: ${JSON.stringify(r.error)}`);
62
+ };
63
+ export const describe_cell_ref_admission_cross_tests = (options) => {
64
+ const { setup_test, capabilities } = options;
65
+ const rpc_path = options.rpc_path ?? SPINE_RPC_PATH;
66
+ describe('cell ref admission parity (possession-gated refs)', () => {
67
+ test_if(capabilities.fact_serving, 'create admits a new ref only for a holder; refusals are identical for stored and unstored hashes', async () => {
68
+ const fixture = await setup_test();
69
+ const alice = await fixture.create_account({ username: 'ref_alice' });
70
+ const bob = await fixture.create_account({ username: 'ref_bob' });
71
+ const t = fixture.fresh_transport();
72
+ const bob_headers = bob.create_session_headers();
73
+ const uploaded = await cross_put_fact(fixture, rpc_path, {
74
+ content: 'alice photo bytes',
75
+ holder: alice.actor.id
76
+ });
77
+ const seeded = await cross_put_fact(fixture, rpc_path, { content: 'seeded bytes' });
78
+ // Bob names a stored fact he never put, and a hash nothing is stored
79
+ // under: both refused, with one identical answer.
80
+ const stored = await refusal(t, rpc_path, 'cell_create', { kind: 'doc', data: { cover: uploaded }, visibility: 'public' }, bob_headers);
81
+ const unstored = await refusal(t, rpc_path, 'cell_create', { kind: 'doc', data: { cover: UNSTORED_HASH }, visibility: 'public' }, bob_headers);
82
+ assert.strictEqual(stored.status, 403);
83
+ assert.deepStrictEqual(stored, unstored, 'stored vs unstored refusal differs');
84
+ assert.strictEqual(stored.error.data?.reason, CELL_REF_NOT_HELD);
85
+ assert.strictEqual(stored.error.message, 'cell data references a fact the caller does not hold');
86
+ // A system-put fact has no holder at all.
87
+ assert_not_held(await cross_rpc_call(t, rpc_path, 'cell_create', { data: { files: [seeded] } }, bob_headers), 'system-put ref');
88
+ // The uploader holds it — her public cell serves the bytes to anyone.
89
+ const created = expect_output(await cross_rpc_call(t, rpc_path, 'cell_create', { kind: 'doc', data: { cover: uploaded }, visibility: 'public' }, alice.create_session_headers()), CellCreateOutput);
90
+ assert.deepStrictEqual(created.cell.refs, [uploaded]);
91
+ const anon = fixture.fresh_transport({ origin: null });
92
+ const served = await anon(`/api/cells/${created.cell.id}/facts/${uploaded}`, {
93
+ method: 'GET'
94
+ });
95
+ assert.strictEqual(served.status, 200, 'the uploader’s public cell did not serve');
96
+ assert.strictEqual(await served.text(), 'alice photo bytes');
97
+ // Bob puts identical bytes himself: possession, so he holds it too.
98
+ assert.strictEqual(await cross_put_fact(fixture, rpc_path, {
99
+ content: 'alice photo bytes',
100
+ holder: bob.actor.id
101
+ }), uploaded);
102
+ expect_output(await cross_rpc_call(t, rpc_path, 'cell_create', { data: { cover: uploaded } }, bob_headers), CellCreateOutput);
103
+ });
104
+ test_if(capabilities.fact_serving, 'update keeps existing refs and refuses new unheld ones', async () => {
105
+ const fixture = await setup_test();
106
+ const alice = await fixture.create_account({ username: 'ref_upd_alice' });
107
+ const bob = await fixture.create_account({ username: 'ref_upd_bob' });
108
+ const t = fixture.fresh_transport();
109
+ const alice_headers = alice.create_session_headers();
110
+ const bob_headers = bob.create_session_headers();
111
+ const alices = await cross_put_fact(fixture, rpc_path, {
112
+ content: 'alice cover bytes',
113
+ holder: alice.actor.id
114
+ });
115
+ const alices_other = await cross_put_fact(fixture, rpc_path, {
116
+ content: 'alice other bytes',
117
+ holder: alice.actor.id
118
+ });
119
+ const bobs = await cross_put_fact(fixture, rpc_path, {
120
+ content: 'bob file bytes',
121
+ holder: bob.actor.id
122
+ });
123
+ // Alice's cell carries her ref; Bob edits it through an editor grant.
124
+ const cell_id = expect_output(await cross_rpc_call(t, rpc_path, 'cell_create', { data: { cover: alices } }, alice_headers), CellCreateOutput).cell.id;
125
+ expect_output(await cross_rpc_call(t, rpc_path, 'cell_grant_create', { cell_id, level: 'editor', principal: { kind: 'actor', actor_id: bob.actor.id } }, alice_headers), CellGrantCreateOutput);
126
+ // Keeping Alice's ref — beside an edit and a ref Bob holds — is admitted.
127
+ const kept = expect_output(await cross_rpc_call(t, rpc_path, 'cell_update', { cell_id, data: { cover: alices, label: 'edited', file: bobs } }, bob_headers), CellUpdateOutput);
128
+ assert.deepStrictEqual(kept.cell.refs, [alices, bobs].sort());
129
+ // Adding one he doesn't hold is refused.
130
+ for (const added of [alices_other, UNSTORED_HASH]) {
131
+ assert_not_held(await cross_rpc_call(t, rpc_path, 'cell_update', { cell_id, data: { cover: alices, file: added } }, bob_headers), `update adding ${added}`);
132
+ }
133
+ // Dropping a ref and adding it back is a new ref — the base is what
134
+ // the cell carries now.
135
+ expect_output(await cross_rpc_call(t, rpc_path, 'cell_update', { cell_id, data: { label: 'dropped' } }, bob_headers), CellUpdateOutput);
136
+ assert_not_held(await cross_rpc_call(t, rpc_path, 'cell_update', { cell_id, data: { cover: alices } }, bob_headers), 'update restoring a dropped ref');
137
+ });
138
+ test_if(capabilities.fact_serving, 'clone carries source refs per row without holding them', async () => {
139
+ const fixture = await setup_test();
140
+ const alice = await fixture.create_account({ username: 'ref_clone_alice' });
141
+ const bob = await fixture.create_account({ username: 'ref_clone_bob' });
142
+ const t = fixture.fresh_transport();
143
+ const alice_headers = alice.create_session_headers();
144
+ const bob_headers = bob.create_session_headers();
145
+ const cover = await cross_put_fact(fixture, rpc_path, {
146
+ content: 'cover bytes',
147
+ holder: alice.actor.id
148
+ });
149
+ const attachment = await cross_put_fact(fixture, rpc_path, {
150
+ content: 'attachment bytes',
151
+ holder: alice.actor.id
152
+ });
153
+ const create = async (data) => expect_output(await cross_rpc_call(t, rpc_path, 'cell_create', { data, visibility: 'public' }, alice_headers), CellCreateOutput).cell.id;
154
+ const source = await create({ cover });
155
+ const child = await create({ file: attachment });
156
+ const inserted = await cross_rpc_call(t, rpc_path, 'cell_item_insert', { parent_id: source, child_id: child, position: 'a0' }, alice_headers);
157
+ assert.ok(inserted.ok, JSON.stringify(inserted.error));
158
+ // Shallow: the root row carries the source's ref.
159
+ const shallow = expect_output(await cross_rpc_call(t, rpc_path, 'cell_clone', { source_id: source }, bob_headers), CellCloneOutput);
160
+ assert.deepStrictEqual(shallow.cell.refs, [cover]);
161
+ assert.strictEqual(shallow.cell.created_by, bob.actor.id);
162
+ // Deep: each child row is checked against its own source row, so the
163
+ // child's ref — not on the root — is carried too.
164
+ const deep = expect_output(await cross_rpc_call(t, rpc_path, 'cell_clone', { source_id: source, deep: true }, bob_headers), CellCloneOutput);
165
+ assert.deepStrictEqual(deep.cell.refs, [cover]);
166
+ const bundle = expect_output(await cross_rpc_call(t, rpc_path, 'cell_get', { id: deep.cell.id }, bob_headers), CellGetOutput);
167
+ assert.strictEqual(bundle.items.length, 1, 'the deep clone dropped its child');
168
+ const cloned_child = expect_output(await cross_rpc_call(t, rpc_path, 'cell_get', { id: bundle.items[0].child_id }, bob_headers), CellGetOutput);
169
+ assert.notStrictEqual(cloned_child.cell.id, child);
170
+ assert.deepStrictEqual(cloned_child.cell.refs, [attachment]);
171
+ // A patch introducing an unheld ref is refused, deep or shallow.
172
+ assert_not_held(await cross_rpc_call(t, rpc_path, 'cell_clone', { source_id: source, deep: true, with_data_patch: { extra: UNSTORED_HASH } }, bob_headers), 'deep clone with an unheld patch ref');
173
+ // The child's ref is not on the root: carrying it onto the root through
174
+ // a patch is a new ref there.
175
+ assert_not_held(await cross_rpc_call(t, rpc_path, 'cell_clone', { source_id: source, with_data_patch: { extra: attachment } }, bob_headers), 'clone moving a child ref onto the root');
176
+ });
177
+ test_if(capabilities.fact_serving, 'a global admin is not gated on refs', async () => {
178
+ const fixture = await setup_test();
179
+ const t = fixture.fresh_transport();
180
+ const seeded = await cross_put_fact(fixture, rpc_path, { content: 'admin seeded bytes' });
181
+ // The keeper holds the global admin grant.
182
+ for (const named of [seeded, UNSTORED_HASH]) {
183
+ const created = expect_output(await cross_rpc_call(t, rpc_path, 'cell_create', { data: { cover: named } }, fixture.create_session_headers()), CellCreateOutput);
184
+ assert.deepStrictEqual(created.cell.refs, [named]);
185
+ }
186
+ });
187
+ test_if(capabilities.fact_serving, 'a revoked grantee cannot re-reference a fact it read', async () => {
188
+ const fixture = await setup_test();
189
+ const alice = await fixture.create_account({ username: 'ref_rev_alice' });
190
+ const bob = await fixture.create_account({ username: 'ref_rev_bob' });
191
+ const t = fixture.fresh_transport();
192
+ const alice_headers = alice.create_session_headers();
193
+ const bob_headers = bob.create_session_headers();
194
+ const hash = await cross_put_fact(fixture, rpc_path, {
195
+ content: 'alice private bytes',
196
+ holder: alice.actor.id
197
+ });
198
+ const cell_id = expect_output(await cross_rpc_call(t, rpc_path, 'cell_create', { data: { file: hash }, visibility: 'private' }, alice_headers), CellCreateOutput).cell.id;
199
+ const grant = expect_output(await cross_rpc_call(t, rpc_path, 'cell_grant_create', { cell_id, level: 'viewer', principal: { kind: 'actor', actor_id: bob.actor.id } }, alice_headers), CellGrantCreateOutput).grant;
200
+ // Bob reads the bytes through the granted cell, so he has seen the hash…
201
+ const read = await t(`/api/cells/${cell_id}/facts/${hash}`, {
202
+ method: 'GET',
203
+ headers: bob_headers
204
+ });
205
+ assert.strictEqual(read.status, 200, 'the grantee could not read the fact');
206
+ // …but naming it in a public cell of his own is refused, now and after
207
+ // the revoke: seeing a hash is not holding the bytes.
208
+ const republish = { data: { file: hash }, visibility: 'public' };
209
+ assert_not_held(await cross_rpc_call(t, rpc_path, 'cell_create', republish, bob_headers), 'grantee republish');
210
+ const revoked = await cross_rpc_call(t, rpc_path, 'cell_grant_revoke', { grant_id: grant.id }, alice_headers);
211
+ assert.ok(revoked.ok, JSON.stringify(revoked.error));
212
+ assert_not_held(await cross_rpc_call(t, rpc_path, 'cell_create', republish, bob_headers), 'revoked grantee republish');
213
+ // The revoked grant also closes the clone path.
214
+ const clone = await cross_rpc_call(t, rpc_path, 'cell_clone', { source_id: cell_id }, bob_headers);
215
+ assert.strictEqual(error_reason(clone), 'cell_not_found');
216
+ });
217
+ test_if(capabilities.fact_serving, 'a ref is a whole exact hash string — prose, markup, malformed, and uppercase are not refs', async () => {
218
+ const fixture = await setup_test();
219
+ const bob = await fixture.create_account({ username: 'ref_grammar_bob' });
220
+ const t = fixture.fresh_transport();
221
+ const exact = `blake3:${'0123456789abcdef'.repeat(4)}`;
222
+ const not_refs = {
223
+ prose: `see ${exact} for details`,
224
+ markup: `![cover](${exact})`,
225
+ padded: ` ${exact}`,
226
+ newline: `${exact}\n`,
227
+ short: 'blake3:zz',
228
+ empty_digest: 'blake3:',
229
+ long: `blake3:${'a'.repeat(65)}`,
230
+ upper: `blake3:${'0123456789ABCDEF'.repeat(4)}`,
231
+ other_algo: `sha256:${'a'.repeat(64)}`,
232
+ keyed: { [exact]: 1 }
233
+ };
234
+ // The keeper's write is ungated, so the derived refs show the grammar
235
+ // alone: none of the near-misses is a ref, the exact hash is.
236
+ const keeper = fixture.create_session_headers();
237
+ const none = expect_output(await cross_rpc_call(t, rpc_path, 'cell_create', { data: not_refs }, keeper), CellCreateOutput);
238
+ assert.strictEqual(none.cell.refs, null, JSON.stringify(none.cell.refs));
239
+ const one = expect_output(await cross_rpc_call(t, rpc_path, 'cell_create', { data: { ...not_refs, file: exact } }, keeper), CellCreateOutput);
240
+ assert.deepStrictEqual(one.cell.refs, [exact]);
241
+ // Not a ref, so a non-admin needs no holding to write it.
242
+ const prose = expect_output(await cross_rpc_call(t, rpc_path, 'cell_create', { data: not_refs }, bob.create_session_headers()), CellCreateOutput);
243
+ assert.strictEqual(prose.cell.refs, null);
244
+ });
245
+ test_if(capabilities.fact_serving, 'ref admission answers after the 404 masks', async () => {
246
+ const fixture = await setup_test();
247
+ const alice = await fixture.create_account({ username: 'ref_mask_alice' });
248
+ const bob = await fixture.create_account({ username: 'ref_mask_bob' });
249
+ const t = fixture.fresh_transport();
250
+ const bob_headers = bob.create_session_headers();
251
+ const alices = await cross_put_fact(fixture, rpc_path, {
252
+ content: 'alice hidden bytes',
253
+ holder: alice.actor.id
254
+ });
255
+ const hidden = expect_output(await cross_rpc_call(t, rpc_path, 'cell_create', { data: { file: alices }, visibility: 'private' }, alice.create_session_headers()), CellCreateOutput).cell.id;
256
+ // An update of a hidden cell answers its mask whatever `data` names —
257
+ // an unheld new ref or the hidden cell's own ref alike.
258
+ for (const named of [UNSTORED_HASH, alices]) {
259
+ const r = await cross_rpc_call(t, rpc_path, 'cell_update', { cell_id: hidden, data: { file: named } }, bob_headers);
260
+ assert.strictEqual(error_reason(r), 'cell_not_found', `update naming ${named}`);
261
+ }
262
+ const under = await cross_rpc_call(t, rpc_path, 'cell_create', { data: { file: UNSTORED_HASH }, parent_id: hidden }, bob_headers);
263
+ assert.strictEqual(error_reason(under), 'cell_not_found', 'create under a hidden parent');
264
+ const clone = await cross_rpc_call(t, rpc_path, 'cell_clone', { source_id: hidden, with_data_patch: { extra: UNSTORED_HASH } }, bob_headers);
265
+ assert.strictEqual(error_reason(clone), 'cell_not_found', 'clone of a hidden source');
266
+ });
267
+ });
268
+ };
@@ -33,7 +33,12 @@
33
33
  "scope",
34
34
  "token_hash"
35
35
  ],
36
- "app_settings": ["id", "open_signup", "updated_at", "updated_by"],
36
+ "app_settings": [
37
+ "id",
38
+ "open_signup",
39
+ "updated_at",
40
+ "updated_by"
41
+ ],
37
42
  "audit_log": [
38
43
  "account_id",
39
44
  "actor_id",
@@ -47,8 +52,16 @@
47
52
  "target_account_id",
48
53
  "target_actor_id"
49
54
  ],
50
- "auth_session": ["account_id", "created_at", "expires_at", "id"],
51
- "bootstrap_lock": ["bootstrapped", "id"],
55
+ "auth_session": [
56
+ "account_id",
57
+ "created_at",
58
+ "expires_at",
59
+ "id"
60
+ ],
61
+ "bootstrap_lock": [
62
+ "bootstrapped",
63
+ "id"
64
+ ],
52
65
  "cell": [
53
66
  "created_at",
54
67
  "created_by",
@@ -65,7 +78,12 @@
65
78
  "updated_by",
66
79
  "visibility"
67
80
  ],
68
- "cell_field": ["created_at", "name", "source_id", "target_id"],
81
+ "cell_field": [
82
+ "created_at",
83
+ "name",
84
+ "source_id",
85
+ "target_id"
86
+ ],
69
87
  "cell_grant": [
70
88
  "actor_id",
71
89
  "cell_id",
@@ -76,11 +94,44 @@
76
94
  "role",
77
95
  "scope_id"
78
96
  ],
79
- "cell_item": ["child_id", "created_at", "parent_id", "position"],
80
- "fact": ["bytes", "content_type", "created_at", "external_url", "hash", "size"],
81
- "fact_ref": ["source_hash", "target_hash"],
82
- "invite": ["claimed_at", "claimed_by", "created_at", "created_by", "email", "id", "username"],
83
- "memo": ["created_at", "fn_id", "input_hash", "output_hash"],
97
+ "cell_item": [
98
+ "child_id",
99
+ "created_at",
100
+ "parent_id",
101
+ "position"
102
+ ],
103
+ "fact": [
104
+ "bytes",
105
+ "content_type",
106
+ "created_at",
107
+ "external_url",
108
+ "hash",
109
+ "size"
110
+ ],
111
+ "fact_holder": [
112
+ "actor_id",
113
+ "created_at",
114
+ "hash"
115
+ ],
116
+ "fact_ref": [
117
+ "source_hash",
118
+ "target_hash"
119
+ ],
120
+ "invite": [
121
+ "claimed_at",
122
+ "claimed_by",
123
+ "created_at",
124
+ "created_by",
125
+ "email",
126
+ "id",
127
+ "username"
128
+ ],
129
+ "memo": [
130
+ "created_at",
131
+ "fn_id",
132
+ "input_hash",
133
+ "output_hash"
134
+ ],
84
135
  "role_grant": [
85
136
  "actor_id",
86
137
  "created_at",
@@ -114,5 +165,10 @@
114
165
  "to_account_id",
115
166
  "to_actor_id"
116
167
  ],
117
- "schema_version": ["applied_at", "name", "namespace", "sequence"]
168
+ "schema_version": [
169
+ "applied_at",
170
+ "name",
171
+ "namespace",
172
+ "sequence"
173
+ ]
118
174
  }
@@ -1,5 +1,5 @@
1
1
  import '../assert_dev_env.js';
2
- import type { RpcPathCapabilityGatedCrossSuiteOptions, SetupTest } from './setup.js';
2
+ import type { RpcPathCapabilityGatedCrossSuiteOptions, SetupTest, TestFixture } from './setup.js';
3
3
  /**
4
4
  * The fact suite adds one optional knob to the shared cell options: a setup
5
5
  * variant whose keeper carries a **second actor**. Only the multi-actor case
@@ -9,5 +9,23 @@ import type { RpcPathCapabilityGatedCrossSuiteOptions, SetupTest } from './setup
9
9
  export interface FactServingCrossTestOptions extends RpcPathCapabilityGatedCrossSuiteOptions {
10
10
  readonly setup_test_multi_actor?: SetupTest;
11
11
  }
12
+ /** Input for `cross_put_fact` — `_testing_put_fact`'s params. */
13
+ export interface CrossPutFactInput {
14
+ readonly content: string;
15
+ readonly content_type?: string;
16
+ /** The actor the put is on behalf of — recorded as a holder. Omit for a system put. */
17
+ readonly holder?: string;
18
+ }
19
+ /**
20
+ * Seed an embedded fact over the daemon channel via `_testing_put_fact`;
21
+ * returns its `blake3:` hash. A `holder` is recorded in `fact_holder` (a
22
+ * deduplicated put included), as a real upload records its uploader.
23
+ *
24
+ * @param fixture - the test fixture (its daemon token drives the backdoor)
25
+ * @param rpc_path - the backend's RPC path
26
+ * @param input - the content, optional content type, and optional holder
27
+ * @returns the fact hash
28
+ */
29
+ export declare const cross_put_fact: (fixture: Pick<TestFixture, "fresh_transport" | "create_daemon_token_headers">, rpc_path: string, input: CrossPutFactInput) => Promise<string>;
12
30
  export declare const describe_fact_serving_cross_tests: (options: FactServingCrossTestOptions) => void;
13
31
  //# sourceMappingURL=fact_serving.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fact_serving.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/fact_serving.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA8C9B,OAAO,KAAK,EAAE,uCAAuC,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAErF;;;;;GAKG;AACH,MAAM,WAAW,2BAA4B,SAAQ,uCAAuC;IAC3F,QAAQ,CAAC,sBAAsB,CAAC,EAAE,SAAS,CAAC;CAC5C;AA8BD,eAAO,MAAM,iCAAiC,GAAI,SAAS,2BAA2B,KAAG,IAiOxF,CAAC"}
1
+ {"version":3,"file":"fact_serving.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/fact_serving.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAiD9B,OAAO,KAAK,EAAE,uCAAuC,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAElG;;;;;GAKG;AACH,MAAM,WAAW,2BAA4B,SAAQ,uCAAuC;IAC3F,QAAQ,CAAC,sBAAsB,CAAC,EAAE,SAAS,CAAC;CAC5C;AAgBD,iEAAiE;AACjE,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,uFAAuF;IACvF,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,GAC1B,SAAS,IAAI,CAAC,WAAW,EAAE,iBAAiB,GAAG,6BAA6B,CAAC,EAC7E,UAAU,MAAM,EAChB,OAAO,iBAAiB,KACtB,OAAO,CAAC,MAAM,CAaV,CAAC;AAgBR,eAAO,MAAM,iCAAiC,GAAI,SAAS,2BAA2B,KAAG,IAgOxF,CAAC"}
@@ -26,7 +26,10 @@ import '../assert_dev_env.js';
26
26
  *
27
27
  * Facts are seeded **embedded** via `_testing_put_fact` (the cross-process
28
28
  * driver has no DB handle); the referencing cell via the `cell_create` RPC
29
- * (`extract_refs` lifts the `blake3:` hash in `data` into `cell.refs`). Gated
29
+ * (the hash, a whole string value in `data`, is derived into `cell.refs`). A
30
+ * non-admin owner's cell may reference only a fact it holds, so a fact a
31
+ * non-admin references is put with that owner as its `holder` (the keeper is
32
+ * a global admin, whom ref admission doesn't gate). Gated
30
33
  * on `capabilities.fact_serving`; runs under every `cross_backend_*` project —
31
34
  * the TS spine binary and the Rust `testing_spine_stub` both mount the serve
32
35
  * routes + the seeder.
@@ -52,6 +55,21 @@ const NIL_UUID = '00000000-0000-0000-0000-000000000000';
52
55
  * fails here rather than silently downstream.
53
56
  */
54
57
  const TestingPutFactOutput = z.strictObject({ hash: FactHashSchema });
58
+ /**
59
+ * Seed an embedded fact over the daemon channel via `_testing_put_fact`;
60
+ * returns its `blake3:` hash. A `holder` is recorded in `fact_holder` (a
61
+ * deduplicated put included), as a real upload records its uploader.
62
+ *
63
+ * @param fixture - the test fixture (its daemon token drives the backdoor)
64
+ * @param rpc_path - the backend's RPC path
65
+ * @param input - the content, optional content type, and optional holder
66
+ * @returns the fact hash
67
+ */
68
+ export const cross_put_fact = async (fixture, rpc_path, input) => expect_output(await cross_rpc_call(
69
+ // Origin-free transport — the daemon-token middleware discards the
70
+ // credential when an `Origin` / `Referer` is present (browser
71
+ // context), and cross-process `fixture.transport` auto-adds `Origin`.
72
+ fixture.fresh_transport({ origin: null }), rpc_path, '_testing_put_fact', input, fixture.create_daemon_token_headers()), TestingPutFactOutput).hash;
55
73
  /** GET a fact over a cross-process `FetchTransport`; returns `{status, content_type, text}`. */
56
74
  const fact_get = async (transport, path, headers) => {
57
75
  const res = await transport(path, { method: 'GET', headers });
@@ -64,12 +82,8 @@ const fact_get = async (transport, path, headers) => {
64
82
  export const describe_fact_serving_cross_tests = (options) => {
65
83
  const { setup_test, setup_test_multi_actor, capabilities } = options;
66
84
  const rpc_path = options.rpc_path ?? SPINE_RPC_PATH;
67
- /** Seed an embedded fact over the daemon channel; returns its `blake3:` hash. */
68
- const put_fact = async (fixture, content, content_type) => expect_output(await cross_rpc_call(
69
- // Origin-free transport — the daemon-token middleware discards the
70
- // credential when an `Origin` / `Referer` is present (browser
71
- // context), and cross-process `fixture.transport` auto-adds `Origin`.
72
- fixture.fresh_transport({ origin: null }), rpc_path, '_testing_put_fact', content_type === undefined ? { content } : { content, content_type }, fixture.create_daemon_token_headers()), TestingPutFactOutput).hash;
85
+ /** Seed an embedded system-put fact; returns its `blake3:` hash. */
86
+ const put_fact = (fixture, content, content_type) => cross_put_fact(fixture, rpc_path, content_type === undefined ? { content } : { content, content_type });
73
87
  /**
74
88
  * Create a cell referencing `hash` (`extract_refs` lifts it into `cell.refs`).
75
89
  * Pass `acting` when the caller's account holds more than one actor —
@@ -96,8 +110,16 @@ export const describe_fact_serving_cross_tests = (options) => {
96
110
  const fixture = await setup_test();
97
111
  const a = await fixture.create_account({ username: 'fact_owner_a' });
98
112
  const b = await fixture.create_account({ username: 'fact_owner_b' });
99
- // One fact, identical bytes from both owners — deduped to a single row.
100
- const hash = await put_fact(fixture, 'shared-deduped-bytes');
113
+ // One fact, identical bytes put by both owners — deduped to a single
114
+ // row, each owner a holder.
115
+ const hash = await cross_put_fact(fixture, rpc_path, {
116
+ content: 'shared-deduped-bytes',
117
+ holder: a.actor.id
118
+ });
119
+ assert.strictEqual(await cross_put_fact(fixture, rpc_path, {
120
+ content: 'shared-deduped-bytes',
121
+ holder: b.actor.id
122
+ }), hash);
101
123
  const t = fixture.fresh_transport();
102
124
  const a_cell = await create_cell_with_ref(t, a.create_session_headers(), hash, 'private');
103
125
  const b_cell = await create_cell_with_ref(t, b.create_session_headers(), hash, 'public');
@@ -261,8 +261,11 @@ export declare const create_testing_drain_effects_action: (audit: AuditEmitter)
261
261
  * cross-process fact-serving suite, which drives over real HTTP and has no
262
262
  * `PgFactStore` to call. Hashes the UTF-8 `content` (blake3, via
263
263
  * `fact_hash_bytes` — the same hash the Rust `_testing_put_fact` computes),
264
- * inserts the row idempotently, and returns `{hash}`. The referencing cell is
265
- * seeded separately via the `cell_create` RPC. Embedded-only is enough for the
264
+ * inserts the row idempotently, and returns `{hash}`. `holder` names the actor
265
+ * the put is on behalf of — recorded in `fact_holder` (deduplicated puts
266
+ * included), as a real upload records its uploader, so the suites can drive
267
+ * cell ref admission; absent, the put is a system put with no holder. The
268
+ * referencing cell is seeded separately via the `cell_create` RPC. Embedded-only is enough for the
266
269
  * authz assertions (cell-scoped admit, cross-owner-no-leak, 404-mask, bare-hash
267
270
  * admin-only); external / X-Accel parity stays covered by the forge's own gate.
268
271
  *
@@ -283,6 +286,7 @@ export declare const testing_put_fact_action_spec: {
283
286
  readonly input: z.ZodObject<{
284
287
  content: z.ZodString;
285
288
  content_type: z.ZodOptional<z.ZodString>;
289
+ holder: z.ZodOptional<z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">>;
286
290
  }, z.core.$strict>;
287
291
  readonly output: z.ZodObject<{
288
292
  hash: z.ZodString & z.ZodType<import("@fuzdev/fuz_util/hash_schemas.js").FactHash, string, z.core.$ZodTypeInternals<import("@fuzdev/fuz_util/hash_schemas.js").FactHash, string>>;
@@ -1 +1 @@
1
- {"version":3,"file":"testing_reset_actions.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/testing_reset_actions.ts"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"testing_reset_actions.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/testing_reset_actions.ts"],"names":[],"mappings":"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"}
@@ -83,6 +83,7 @@ import { jsonrpc_errors } from '../../http/jsonrpc_errors.js';
83
83
  import { emit_after_commit } from '../../http/pending_effects.js';
84
84
  import { protocol_action_specs } from '../../actions/protocol.js';
85
85
  import { query_put_fact } from '../../db/fact_queries.js';
86
+ import { query_put_fact_holder } from '../../db/fact_holder_queries.js';
86
87
  import { ROLE_ADMIN, ROLE_KEEPER } from '../../auth/role_schema.js';
87
88
  import { query_schema_snapshot, SchemaSnapshot, query_migration_tracker, MigrationTracker } from '../schema_introspect.js';
88
89
  import { ActionManifest, build_action_manifest } from './action_manifest.js';
@@ -262,8 +263,11 @@ export const create_testing_drain_effects_action = (audit) => rpc_action(testing
262
263
  * cross-process fact-serving suite, which drives over real HTTP and has no
263
264
  * `PgFactStore` to call. Hashes the UTF-8 `content` (blake3, via
264
265
  * `fact_hash_bytes` — the same hash the Rust `_testing_put_fact` computes),
265
- * inserts the row idempotently, and returns `{hash}`. The referencing cell is
266
- * seeded separately via the `cell_create` RPC. Embedded-only is enough for the
266
+ * inserts the row idempotently, and returns `{hash}`. `holder` names the actor
267
+ * the put is on behalf of — recorded in `fact_holder` (deduplicated puts
268
+ * included), as a real upload records its uploader, so the suites can drive
269
+ * cell ref admission; absent, the put is a system put with no holder. The
270
+ * referencing cell is seeded separately via the `cell_create` RPC. Embedded-only is enough for the
267
271
  * authz assertions (cell-scoped admit, cross-owner-no-leak, 404-mask, bare-hash
268
272
  * admin-only); external / X-Accel parity stays covered by the forge's own gate.
269
273
  *
@@ -279,7 +283,8 @@ export const testing_put_fact_action_spec = {
279
283
  side_effects: true,
280
284
  input: z.strictObject({
281
285
  content: z.string(),
282
- content_type: z.string().optional()
286
+ content_type: z.string().optional(),
287
+ holder: Uuid.optional()
283
288
  }),
284
289
  output: z.strictObject({ hash: FactHashSchema }),
285
290
  async: true,
@@ -719,6 +724,11 @@ export const create_testing_actions = (deps, options) => {
719
724
  content_type: input.content_type ?? null,
720
725
  size: bytes.length
721
726
  });
727
+ // the holder row, on a dedup hit too (`PgFactStore`'s put records it the
728
+ // same way); an unknown actor fails the FK
729
+ if (input.holder !== undefined) {
730
+ await query_put_fact_holder({ db: ctx.db }, input.holder, hash);
731
+ }
722
732
  return { hash };
723
733
  }),
724
734
  create_testing_drain_effects_action(deps.audit),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fuzdev/fuz_app",
3
- "version": "0.143.0",
3
+ "version": "0.144.0",
4
4
  "description": "fullstack app library",
5
5
  "glyph": "🗝",
6
6
  "logo": "logo.svg",