-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmongo-init.js
More file actions
548 lines (524 loc) · 24.3 KB
/
Copy pathmongo-init.js
File metadata and controls
548 lines (524 loc) · 24.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
// Benthos Mongo bootstrap — runs ONCE on first container init.
// Schema changes after first init require a migration plan (Stage 2+).
// Defense-in-depth: $jsonSchema validators mirror the Pydantic models in
// benthos_api/models/. Drift is a known risk; lockstep is enforced by review.
const dbName = process.env.MONGO_INITDB_DATABASE || "benthos";
const appPassword = process.env.MONGO_APP_PASSWORD;
const vaultPassword = process.env.MONGO_VAULT_PASSWORD;
if (!appPassword || !vaultPassword) {
throw new Error("MONGO_APP_PASSWORD and MONGO_VAULT_PASSWORD must be set");
}
const target = db.getSiblingDB(dbName);
const numericTypes = ["double", "int", "long", "decimal"];
const optionalNumeric = numericTypes.concat(["null"]);
// ---------------------------------------------------------------------------
// catch_events — Stage 1 fishing trip records (camada bot, L2)
// ---------------------------------------------------------------------------
target.createCollection("catch_events", {
validator: {
$jsonSchema: {
bsonType: "object",
required: [
"schema_version", "catch_event_id", "community", "fisher_pseudo_id",
"event_date", "consent_record_id",
"catch_species", "catch_weight_kg", "catch_count",
"fishing_effort_hours", "cpue_kg_per_hour", "created_at"
],
additionalProperties: false,
properties: {
_id: {},
schema_version: { enum: ["1.0.0"] },
catch_event_id: { bsonType: "string", pattern: "^cev_[a-f0-9]{16}$" },
community: { bsonType: "string", pattern: "^[a-z]{2}-[a-z0-9-]+$" },
fisher_pseudo_id: { bsonType: "string", pattern: "^psd_[a-f0-9]{16}$" },
event_date: { bsonType: "date" },
consent_record_id: { bsonType: "string", pattern: "^csr_[A-Za-z0-9_-]+$" },
catch_species: { bsonType: "string", minLength: 1, maxLength: 200 },
vernacular_name: { bsonType: ["string", "null"], maxLength: 200 },
catch_weight_kg: { bsonType: numericTypes, minimum: 0, maximum: 100000 },
catch_count: { bsonType: ["int", "long"], minimum: 0 },
catch_price_per_kg: { bsonType: optionalNumeric, minimum: 0 },
catch_price_currency: { bsonType: ["string", "null"], pattern: "^[A-Z]{3}$" },
fishing_effort_hours: { bsonType: numericTypes, minimum: 0, exclusiveMinimum: true, maximum: 720 },
cpue_kg_per_hour: { bsonType: numericTypes, minimum: 0 },
created_at: { bsonType: "date" }
}
}
},
validationLevel: "strict",
validationAction: "error"
});
// ---------------------------------------------------------------------------
// consent_records — vault collection (CARE-aligned)
// ---------------------------------------------------------------------------
target.createCollection("consent_records", {
validator: {
$jsonSchema: {
bsonType: "object",
required: [
"schema_version", "consent_record_id", "community",
"self_identification_frame", "consent_scope", "approved_categories",
"data_custodian_entity", "prior_informed_consent_date",
"approved_by", "data_retention_period_months",
"withdrawal_mechanism", "revoked", "created_at"
],
additionalProperties: false,
properties: {
_id: {},
schema_version: { enum: ["1.0.0"] },
consent_record_id: { bsonType: "string", pattern: "^csr_[A-Za-z0-9_-]+$" },
community: { bsonType: "string", pattern: "^[a-z]{2}-[a-z0-9-]+$" },
self_identification_frame: {
enum: [
"indigenous",
"traditional_knowledge_custodian",
"territorial_steward",
"artisanal_producer_collective"
]
},
consent_scope: {
enum: ["internal_only", "aggregate_research", "aggregate_funder", "named_public"]
},
approved_categories: {
bsonType: "array",
minItems: 1,
uniqueItems: true,
items: {
enum: ["identity", "location", "catch", "observation",
"governance", "mett_score", "carbon_finance",
"traditional_knowledge", "community_voice"]
}
},
data_custodian_entity: { bsonType: "string", minLength: 1, maxLength: 500 },
prior_informed_consent_date: { bsonType: "date" },
approved_by: {
bsonType: "array",
minItems: 1,
items: { bsonType: "string", minLength: 1, maxLength: 500 }
},
data_retention_period_months: { bsonType: ["int", "long"], minimum: 1, maximum: 1200 },
withdrawal_mechanism: {
bsonType: "object",
required: ["sla_remove_external_days", "sla_remove_internal", "audit_log_retention"],
additionalProperties: false,
properties: {
sla_remove_external_days: { bsonType: ["int", "long"], minimum: 0, maximum: 365 },
sla_remove_internal: { enum: ["immediate", "scheduled"] },
audit_log_retention: { enum: ["permanent", "time_limited"] }
}
},
// Optional CARE fields (Stage 1 pragmatic subset; populated when available)
ethical_framework_source: { bsonType: ["string", "null"], maxLength: 500 },
relationship_custodian_name: { bsonType: ["string", "null"], maxLength: 500 },
conflict_resolution_mechanism: { bsonType: ["string", "null"], maxLength: 2000 },
benefit_sharing_mechanism: {
enum: [null, "direct_revenue", "capacity_building",
"knowledge_access", "policy_influence"]
},
local_language_primary: { bsonType: ["string", "null"], pattern: "^[a-z]{2}(-[A-Z]{2})?$" },
revoked: { bsonType: "bool" },
revoked_at: { bsonType: ["date", "null"] },
created_at: { bsonType: "date" }
}
}
},
validationLevel: "strict",
validationAction: "error"
});
// ---------------------------------------------------------------------------
// external_release_logs — append-only public audit trail
// ---------------------------------------------------------------------------
target.createCollection("external_release_logs", {
validator: {
$jsonSchema: {
bsonType: "object",
required: [
"schema_version", "release_id", "community",
"requested_by", "legal_basis", "purpose",
"field_set", "record_count",
"privacy_method", "privacy_params",
"quorum_signatures", "consent_record_ids", "released_at"
],
additionalProperties: false,
properties: {
_id: {},
schema_version: { enum: ["1.0.0"] },
release_id: { bsonType: "string", pattern: "^rel_[A-Za-z0-9_-]+$" },
community: { bsonType: "string", pattern: "^[a-z]{2}-[a-z0-9-]+$" },
requested_by: { bsonType: "string", minLength: 1, maxLength: 500 },
legal_basis: {
enum: [
"dsgvo_art_6_1_a_consent",
"dsgvo_art_6_1_e_public_interest",
"dsgvo_art_89_research",
"lgpd_art_7_consent",
"lgpd_art_11_sensitive_consent"
]
},
purpose: { bsonType: "string", minLength: 1, maxLength: 2000 },
field_set: {
bsonType: "array", minItems: 1, uniqueItems: true,
items: { bsonType: "string", minLength: 1 }
},
record_count: { bsonType: ["int", "long"], minimum: 0 },
privacy_method: { enum: ["k_anonymity", "differential_privacy"] },
privacy_params: {
bsonType: "object",
additionalProperties: false,
properties: {
k: { bsonType: ["int", "long"], minimum: 1 },
epsilon: { bsonType: numericTypes, minimum: 0, exclusiveMinimum: true }
}
},
quorum_signatures: {
bsonType: "array", minItems: 2,
items: {
bsonType: "object",
required: ["role", "signer", "signed_at"],
additionalProperties: false,
properties: {
role: { bsonType: "string", minLength: 1, maxLength: 100 },
signer: { bsonType: "string", minLength: 1, maxLength: 500 },
signed_at: { bsonType: "date" }
}
}
},
consent_record_ids: {
bsonType: "array", minItems: 1, uniqueItems: true,
items: { bsonType: "string", pattern: "^csr_[A-Za-z0-9_-]+$" }
},
released_at: { bsonType: "date" }
}
}
},
validationLevel: "strict",
validationAction: "error"
});
// ---------------------------------------------------------------------------
// fisher_identity_map — vault-strict pseudo↔real mapping.
// Stage 1: collection provisioned, no API endpoint populates it. Helpers in
// privacy.py mint pseudo IDs; population flow lives outside this service.
// ---------------------------------------------------------------------------
target.createCollection("fisher_identity_map", {
validator: {
$jsonSchema: {
bsonType: "object",
required: ["schema_version", "fisher_pseudo_id", "community",
"real_identifier", "created_at"],
additionalProperties: false,
properties: {
_id: {},
schema_version: { enum: ["1.0.0"] },
fisher_pseudo_id: { bsonType: "string", pattern: "^psd_[a-f0-9]{16}$" },
community: { bsonType: "string", pattern: "^[a-z]{2}-[a-z0-9-]+$" },
real_identifier: { bsonType: "string", minLength: 1 },
created_at: { bsonType: "date" }
}
}
},
validationLevel: "strict",
validationAction: "error"
});
// ---------------------------------------------------------------------------
// fisher_identities — Stage 2 operational consent registry (app-readable).
// Stores phone_hash (sha256) + pseudonym + per-fisher consent_scope. The
// vault map (fisher_identity_map) holds the plain real_identifier; this
// collection never carries it. Dual-write atomicity is via two-phase
// commit in routes/identity.py (Atlas M0 has no multi-doc transactions).
// ---------------------------------------------------------------------------
target.createCollection("fisher_identities", {
validator: {
$jsonSchema: {
bsonType: "object",
required: [
"schema_version", "fisher_pseudo_id", "phone_hash", "pseudonym",
"community", "consent_scope", "consent_record_id",
"granted_at", "revoked"
],
additionalProperties: false,
properties: {
_id: {},
schema_version: { enum: ["1.0.0"] },
fisher_pseudo_id: { bsonType: "string", pattern: "^psd_[a-f0-9]{16}$" },
phone_hash: { bsonType: "string", pattern: "^[a-f0-9]{64}$" },
pseudonym: {
bsonType: "string",
pattern: "^(tatu|siri|garoupa|robalo|tainha|caranguejo|caica|gaivota|baleia|caranha)-(azul|verde|vermelho|amarelo|preto|branco|rosa|cinza)-[0-9]{2}$"
},
community: { bsonType: "string", pattern: "^[a-z]{2}-[a-z0-9-]+$" },
consent_scope: {
bsonType: "array",
minItems: 1,
uniqueItems: true,
items: {
enum: ["info_access", "tk_preservation",
"civic_voice", "catch_contribution"]
}
},
consent_record_id: { bsonType: "string", pattern: "^csr_[A-Za-z0-9_-]+$" },
custodian_pseudo_id: { bsonType: ["string", "null"], pattern: "^psd_[a-f0-9]{16}$" },
granted_at: { bsonType: "date" },
revoked: { bsonType: "bool" },
revoked_at: { bsonType: ["date", "null"] }
}
}
},
validationLevel: "strict",
validationAction: "error"
});
// ---------------------------------------------------------------------------
// audit_log — append-only mutation ledger.
// 1:1 with mutating routes: each successful POST emits exactly one event.
// entity_id pattern is laxly validated here (oneOf the 3 entity-id prefixes);
// strict cross-field check (entity_type ↔ entity_id) lives in Pydantic.
// ---------------------------------------------------------------------------
target.createCollection("audit_log", {
validator: {
$jsonSchema: {
bsonType: "object",
required: [
"schema_version", "audit_event_id", "event_type",
"entity_type", "entity_id", "community", "recorded_at"
],
additionalProperties: false,
properties: {
_id: {},
schema_version: { enum: ["1.0.0"] },
audit_event_id: { bsonType: "string", pattern: "^aud_[a-f0-9]{16}$" },
event_type: {
enum: ["catch_event_recorded", "consent_granted",
"consent_revoked", "release_recorded",
"tk_event_recorded", "community_voice_event_recorded",
"identity_granted", "identity_revoked"]
},
entity_type: {
enum: ["catch_event", "consent_record", "external_release",
"tk_event", "community_voice_event", "fisher_identity"]
},
entity_id: {
bsonType: "string",
oneOf: [
{ pattern: "^cev_[a-f0-9]{16}$" },
{ pattern: "^csr_[A-Za-z0-9_-]+$" },
{ pattern: "^rel_[A-Za-z0-9_-]+$" },
{ pattern: "^tke_[a-f0-9]{16}$" },
{ pattern: "^cmv_[a-f0-9]{16}$" },
{ pattern: "^psd_[a-f0-9]{16}$" }
]
},
community: { bsonType: "string", pattern: "^[a-z]{2}-[a-z0-9-]+$" },
recorded_at: { bsonType: "date" }
}
}
},
validationLevel: "strict",
validationAction: "error"
});
// ---------------------------------------------------------------------------
// traditional_knowledge_events — Stage 1.5 knowledge custodian recordings.
// Append-only. Custodian identity reuses the fisher_identity_map registry
// (same psd_<16hex> pattern); `custodian_pseudo_id` is a contextual label.
// ---------------------------------------------------------------------------
target.createCollection("traditional_knowledge_events", {
validator: {
$jsonSchema: {
bsonType: "object",
required: [
"schema_version", "tk_event_id", "community", "custodian_pseudo_id",
"event_date", "consent_record_id",
"knowledge_domain", "medium", "transcription_pseudonymized",
"language_primary", "created_at"
],
additionalProperties: false,
properties: {
_id: {},
schema_version: { enum: ["1.0.0"] },
tk_event_id: { bsonType: "string", pattern: "^tke_[a-f0-9]{16}$" },
community: { bsonType: "string", pattern: "^[a-z]{2}-[a-z0-9-]+$" },
custodian_pseudo_id: { bsonType: "string", pattern: "^psd_[a-f0-9]{16}$" },
event_date: { bsonType: "date" },
consent_record_id: { bsonType: "string", pattern: "^csr_[A-Za-z0-9_-]+$" },
knowledge_domain: {
enum: ["technique", "species_lore", "calendar", "place_name", "other"]
},
medium: { enum: ["audio", "text", "photo"] },
transcription_pseudonymized: { bsonType: "string", minLength: 1, maxLength: 10000 },
language_primary: { bsonType: "string", pattern: "^[a-z]{2}(-[A-Z]{2})?$" },
created_at: { bsonType: "date" }
}
}
},
validationLevel: "strict",
validationAction: "error"
});
// ---------------------------------------------------------------------------
// community_voice_events — Stage 1.5 civic incident reports.
// Append-only. Reporter identity reuses fisher_pseudo_id (Stage 1.5 piggy-back;
// a future stage will generalize to informant_pseudo_id for non-fisher
// reporters). PublicView strips fisher_pseudo_id; only vault-role GET exposes it.
// ---------------------------------------------------------------------------
target.createCollection("community_voice_events", {
validator: {
$jsonSchema: {
bsonType: "object",
required: [
"schema_version", "community_voice_event_id", "community",
"fisher_pseudo_id", "event_date", "consent_record_id",
"incident_type", "location_sector", "severity",
"evidence_pseudonymized", "escalation_optin", "created_at"
],
additionalProperties: false,
properties: {
_id: {},
schema_version: { enum: ["1.0.0"] },
community_voice_event_id: { bsonType: "string", pattern: "^cmv_[a-f0-9]{16}$" },
community: { bsonType: "string", pattern: "^[a-z]{2}-[a-z0-9-]+$" },
fisher_pseudo_id: { bsonType: "string", pattern: "^psd_[a-f0-9]{16}$" },
event_date: { bsonType: "date" },
consent_record_id: { bsonType: "string", pattern: "^csr_[A-Za-z0-9_-]+$" },
incident_type: {
enum: ["illegal_fishing", "oil_spill", "unauthorized_construction",
"unauthorized_extraction", "other"]
},
location_sector: { bsonType: "string", minLength: 1, maxLength: 500 },
severity: { enum: ["low", "medium", "high", "critical"] },
evidence_pseudonymized: { bsonType: "string", minLength: 1, maxLength: 10000 },
escalation_optin: { bsonType: "bool" },
escalation_target: { bsonType: ["string", "null"], minLength: 1, maxLength: 500 },
created_at: { bsonType: "date" }
}
}
},
validationLevel: "strict",
validationAction: "error"
});
// ---------------------------------------------------------------------------
// Indexes
// ---------------------------------------------------------------------------
target.catch_events.createIndex({ catch_event_id: 1 }, { unique: true });
target.catch_events.createIndex({ community: 1, event_date: -1 });
target.catch_events.createIndex({ fisher_pseudo_id: 1, event_date: -1 });
target.catch_events.createIndex({ consent_record_id: 1 });
// Idempotency: same fisher cannot record duplicate catch on same instant for same species.
target.catch_events.createIndex(
{ community: 1, fisher_pseudo_id: 1, event_date: 1, catch_species: 1 },
{ unique: true, name: "uq_catch_event_natural_key" }
);
target.consent_records.createIndex({ consent_record_id: 1 }, { unique: true });
target.consent_records.createIndex({ community: 1, revoked: 1 });
target.external_release_logs.createIndex({ release_id: 1 }, { unique: true });
target.external_release_logs.createIndex({ community: 1, released_at: -1 });
target.fisher_identity_map.createIndex({ fisher_pseudo_id: 1 }, { unique: true });
target.fisher_identity_map.createIndex({ community: 1 });
// fisher_identities — uniqueness partial-filtered on revoked=false so a
// fisher who revokes can re-register with a new pseudo_id/pseudonym.
target.fisher_identities.createIndex(
{ phone_hash: 1 },
{ unique: true,
partialFilterExpression: { revoked: false },
name: "uq_identity_phone_hash_active" }
);
target.fisher_identities.createIndex(
{ fisher_pseudo_id: 1 },
{ unique: true,
partialFilterExpression: { revoked: false },
name: "uq_identity_pseudo_id_active" }
);
target.fisher_identities.createIndex(
{ community: 1, pseudonym: 1 },
{ unique: true,
partialFilterExpression: { revoked: false },
name: "uq_identity_pseudonym_per_community_active" }
);
target.fisher_identities.createIndex(
{ community: 1, granted_at: -1 },
{ name: "ix_identity_community_granted_at" }
);
target.audit_log.createIndex({ audit_event_id: 1 }, { unique: true });
target.audit_log.createIndex({ entity_type: 1, entity_id: 1, recorded_at: -1 });
target.audit_log.createIndex({ community: 1, recorded_at: -1 });
target.audit_log.createIndex({ event_type: 1, recorded_at: -1 });
target.traditional_knowledge_events.createIndex({ tk_event_id: 1 }, { unique: true });
target.traditional_knowledge_events.createIndex({ community: 1, event_date: -1 });
target.traditional_knowledge_events.createIndex({ custodian_pseudo_id: 1, event_date: -1 });
target.traditional_knowledge_events.createIndex({ consent_record_id: 1 });
target.traditional_knowledge_events.createIndex(
{ community: 1, custodian_pseudo_id: 1, event_date: 1, knowledge_domain: 1 },
{ unique: true, name: "uq_tk_event_natural_key" }
);
target.community_voice_events.createIndex({ community_voice_event_id: 1 }, { unique: true });
target.community_voice_events.createIndex({ community: 1, event_date: -1 });
target.community_voice_events.createIndex({ fisher_pseudo_id: 1, event_date: -1 });
target.community_voice_events.createIndex({ consent_record_id: 1 });
target.community_voice_events.createIndex(
{ community: 1, fisher_pseudo_id: 1, event_date: 1, incident_type: 1 },
{ unique: true, name: "uq_community_voice_event_natural_key" }
);
// ---------------------------------------------------------------------------
// Roles + users (defense-in-depth on top of Pydantic-side authorization)
// ---------------------------------------------------------------------------
target.createRole({
role: "benthosAppRole",
privileges: [
// catch_events: append-only.
{ resource: { db: dbName, collection: "catch_events" },
actions: ["find", "insert", "createIndex", "listIndexes", "listCollections"] },
// external_release_logs: append-only public log.
{ resource: { db: dbName, collection: "external_release_logs" },
actions: ["find", "insert", "createIndex", "listIndexes", "listCollections"] },
// consent_records: read-only — needed to verify consent before accepting
// catch events or external releases. App cannot create or revoke consents.
{ resource: { db: dbName, collection: "consent_records" },
actions: ["find", "listIndexes", "listCollections"] },
// audit_log: append-only ledger — emitted by catch and release routes.
{ resource: { db: dbName, collection: "audit_log" },
actions: ["find", "insert", "createIndex", "listIndexes", "listCollections"] },
// traditional_knowledge_events: append-only (Stage 1.5).
{ resource: { db: dbName, collection: "traditional_knowledge_events" },
actions: ["find", "insert", "createIndex", "listIndexes", "listCollections"] },
// community_voice_events: append-only (Stage 1.5). App role POSTs and serves
// the public GET (PublicView strips fisher_pseudo_id).
{ resource: { db: dbName, collection: "community_voice_events" },
actions: ["find", "insert", "createIndex", "listIndexes", "listCollections"] },
// fisher_identities: find-only (Stage 2). App role serves the whitelist
// lookup (GET /v1/identities/by-phone-hash) and the public listing.
// Writes go through vault role (POST /v1/identities + revoke).
{ resource: { db: dbName, collection: "fisher_identities" },
actions: ["find", "listIndexes", "listCollections"] }
// fisher_identity_map: NO access for app role. Vault only.
],
roles: []
});
target.createRole({
role: "benthosVaultRole",
privileges: [
{ resource: { db: dbName, collection: "consent_records" },
actions: ["find", "insert", "update", "createIndex", "listIndexes", "listCollections"] },
{ resource: { db: dbName, collection: "fisher_identity_map" },
actions: ["find", "insert", "update", "createIndex", "listIndexes", "listCollections"] },
// audit_log: append-only ledger — emitted by consent routes.
{ resource: { db: dbName, collection: "audit_log" },
actions: ["find", "insert", "createIndex", "listIndexes", "listCollections"] },
// community_voice_events: find-only (Stage 1.5). Vault never inserts —
// POST goes through app role. Used by GET /v1/community-voice-events/vault
// to expose the full event with reporter identity for privileged operators.
{ resource: { db: dbName, collection: "community_voice_events" },
actions: ["find", "listIndexes", "listCollections"] },
// fisher_identities: full RW (Stage 2). Phase 1 of dual-write on POST
// /v1/identities + revoke + vault-only by-pseudonym operator lookup.
{ resource: { db: dbName, collection: "fisher_identities" },
actions: ["find", "insert", "update", "createIndex", "listIndexes", "listCollections"] }
],
roles: []
});
target.createUser({
user: "benthos_app",
pwd: appPassword,
roles: [{ role: "benthosAppRole", db: dbName }]
});
target.createUser({
user: "benthos_vault",
pwd: vaultPassword,
roles: [{ role: "benthosVaultRole", db: dbName }]
});
print("[benthos] init complete: collections, validators, indexes, roles, users provisioned for db '" + dbName + "'");