Blackholes

The blackholes plugin permanently removes or replaces field values in history, including transaction history and configured backups. Use it to remove leaked secrets or personal data that ordinary deletion leaves in history. History retention controls how much history a database keeps. Enable blackholes in the plugins option when you open the database. See plugin selection for the open options.

Warning

Execution permanently changes history and backups. Review the preview and obtain approval before you execute.

Definitions

A blackhole is a stored definition of the blackholes kind. Write it with patch_definition like a query or mutation. For example, store the following definition with kind blackholes and path keys/leaked. It has a query and a patch, like a mutation:

TRON426 B
Offset (hex)Bytes (hex)Meaning
00054 52 4F 4Emagic TRON
0042C 3F65txt "?e"
0070E 0D 00 0100 010000 00 04000000array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @4
0142C 3F65txt "?e"
0174C 6B696E64txt "kind"
01C6C 6170694B6579txt "apiKey"
0230E 15 00 0700 030000 00 14000000 170000 00 1C000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @14 → @17 → @1C
0382C 3F65txt "?e"
03B5C 6F776E6572txt "owner"
0419C 3F6B65794F776E 6572txt "?keyOwner"
04B0E 15 00 0700 030000 00 38000000 3B0000 00 41000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @38 → @3B → @41
0601C 3Dtxt "="
0629C 3F6B65794F776E 6572txt "?keyOwner"
06C6C 3F6F776E6572txt "?owner"
0730E 15 00 0700 030000 00 60000000 620000 00 6C000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @60 → @62 → @6C
0880E 15 00 0700 030000 00 23000000 4B0000 00 73000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @23 → @4B → @73
09D5C 7768657265txt "where"
0A30F 0A 9D000000 8800 0000map leaf, size 10: @9D → @88
0AD4C 66696E64txt "find"
0B20F 0A AD000000 0700 0000map leaf, size 10: @AD → @7
0BC07 0E 0A000000 A300 0000 B2000000map branch, size 14, depth 0 (root), slots 1, 3: @A3 → @B2
0CA4C 6C697374txt "list"
0CF5C 3F73656564txt "?seed"
0D56C 3F76616C7565txt "?value"
0DC0E 15 00 0700 030000 00 CA000000 CF0000 00 D5000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @CA → @CF → @D5
0F14C 68617368txt "hash"
0F60E 11 00 0300 020000 00 F1000000 DC0000 00array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @F1 → @DC
1076C 736563726574txt "secret"
10E00nil
10F0F 0A 07010000 0E01 0000map leaf, size 10: @107 → @10E
1194C 6E6F7465txt "note"
11E8C 72656461637465 64txt "redacted"
1270F 0A 19010000 1E01 0000map leaf, size 10: @119 → @11E
1315C 746F6B656Etxt "token"
1370F 0A 31010000 F600 0000map leaf, size 10: @131 → @F6
14107 12 00380000 0F01 0000 27010000 3701 0000map branch, size 18, depth 0 (root), slots 11, 12, 13: @10F → @127 → @137
1532C 3F65txt "?e"
1560F 0A 53010000 4101 0000map leaf, size 10: @153 → @141
1605C 7175657279txt "query"
1660F 0A 60010000 BC00 0000map leaf, size 10: @160 → @BC
1705C 7061746368txt "patch"
1760F 0A 70010000 5601 0000map leaf, size 10: @170 → @156
18007 0E 40020000 6601 0000 76010000map branch, size 14, depth 2, slots 6, 9: @166 → @176
18E07 0A 01000000 8001 0000map branch, size 10, depth 1, slots 0: @180
19807 0A 80000000 8E01 0000map branch, size 10, depth 0 (root), slots 7: @18E

This definition selects every API key belonging to the supplied owner and names three fields on each selected entity. The query binds ?keyOwner from stored facts and compares it with the required input ?owner. The input has no default. Preview and execution fail if ?owner is omitted. The preview request below supplies owner 7.

The query selects rows from the current state by default. Temporal query clauses can select records from earlier history, including records already deleted from current state. Ordering, distinct results, aggregation and limits keep their usual query meaning. After aggregation, each patch target must still bind an individual entity. Each patch key is a ?variable that the query binds to an entity. Each field in a target is one of these:

ValueEffect on every assertion of the field
nullTurns the assertion into a retraction. The field disappears from current and historical records.
An expressionReplaces the assertion's value with the expression result. A literal such as redacted is a constant expression.

An assertion is a stored fact that gives the field a value. Existing retractions stay unchanged. Transactions keep their numbers and commit times, and other fields and entities do not change.

The definition is checked when you store it. The query and expressions must compile. Each patch target must be a query variable. After macro expansion, each expression input must be a query variable or one of the reserved inputs listed below. Patch fields in the reserved stardust/ namespace, generated _ targets and #_tx targets are refused. A refused definition reports invalid_definition.

Definition writes replace each supplied top-level member in full, including nested null values. For example, an update to query must supply the complete query. Other top-level members remain unchanged. A top-level null removes that member. Inside patch, null erases the selected field or entity throughout history.

A null at the entity position erases every historical field of that entity. For example, store this definition with kind blackholes and path people/erase:

TRON286 B
Offset (hex)Bytes (hex)Meaning
00054 52 4F 4Emagic TRON
0042C 3F65txt "?e"
0070E 0D 00 0100 010000 00 04000000array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @4
0142C 3F65txt "?e"
0174C 6B696E64txt "kind"
01C6C 706572736F6Etxt "person"
0230E 15 00 0700 030000 00 14000000 170000 00 1C000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @14 → @17 → @1C
0381C 3Dtxt "="
03A2C 3F65txt "?e"
03D7C 3F656E74697479txt "?entity"
0450E 15 00 0700 030000 00 38000000 3A0000 00 3D000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @38 → @3A → @3D
05A0E 11 00 0300 020000 00 23000000 450000 00array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @23 → @45
06B5C 7768657265txt "where"
0710F 0A 6B000000 5A00 0000map leaf, size 10: @6B → @5A
07B4C 66696E64txt "find"
0800F 0A 7B000000 0700 0000map leaf, size 10: @7B → @7
08A07 0E 0A000000 7100 0000 80000000map branch, size 14, depth 0 (root), slots 1, 3: @71 → @80
0982C 3F65txt "?e"
09B00nil
09C0F 0A 98000000 9B00 0000map leaf, size 10: @98 → @9B
0A68C 696E636F6D696E 67txt "incoming"
0AF6C 72656D6F7665txt "remove"
0B60F 0A A6000000 AF00 0000map leaf, size 10: @A6 → @AF
0C05C 7175657279txt "query"
0C60F 0A C0000000 8A00 0000map leaf, size 10: @C0 → @8A
0D05C 7061746368txt "patch"
0D60F 0A D0000000 9C00 0000map leaf, size 10: @D0 → @9C
0E007 0E 40020000 C600 0000 D6000000map branch, size 14, depth 2, slots 6, 9: @C6 → @D6
0EE5C 6C696E6B73txt "links"
0F40F 0A EE000000 B600 0000map leaf, size 10: @EE → @B6
0FE07 0E 01100000 E000 0000 F4000000map branch, size 14, depth 1, slots 0, 12: @E0 → @F4
10C07 0A 80000000 FE00 0000map branch, size 10, depth 0 (root), slots 7: @FE

Supply ?entity as an entity link in both preview and execution. The query selects entities explicitly. An outgoing link does not select its destination, regardless of the field name. To erase another entity, select it in the query and name it in the patch. Temporal query clauses can select entities already deleted from current state.

Without links {incoming remove}, an incoming reference to an erased entity refuses planning with incoming_links. With this option, every historical reference to an erased entity is removed. A field containing only that link becomes a retraction. In a map or an ordered list, only the matching reference is removed; other members and empty containers remain. The source entity stays. A self-link or a link between two selected entities does not cause further selection. References in protected system fields refuse planning with protected_link.

Selecting the same entity for whole-entity erasure and a field patch reports conflicting_targets. Preview includes the expanded scope in affected, and its digest covers that scope before execution.

Replacement expressions

An expression is evaluated once for each historical assertion. It receives these inputs:

VariableValue
?valueThe original typed value.
?entityThe numeric entity ID.
?fieldThe field name.
?transactionThe assertion's transaction ID.
?seedA private random seed for the whole operation.
Other ?variablesThe row's bindings from the query.

The reserved names take precedence over query variables with the same name. The plugin expands stored callables before it identifies the query variables an expression reads. Variables in unused macro arguments do not need row bindings. The approval digest covers the expanded expression and its row bindings.

Preview

preview selects and plans a definition without changing anything. It uses the current database transaction as its cutoff. The request is a native object. This example uses DUST:

TRON121 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
045C 236C696E6Btxt "#link"
0A02 07000000000000 00i64 7
130F 0A 04000000 0A00 0000map leaf, size 10: @4 → @A
1D6C 3F6F776E6572txt "?owner"
240F 0A 1D000000 1300 0000map leaf, size 10: @1D → @13
2EAC 706172616D6574 657273txt "parameters"
390F 0A 2E000000 2400 0000map leaf, size 10: @2E → @24
439C 626C61636B686F 6C65txt "blackhole"
4DBC 6B6579732F6C65 616B6564txt "keys/leaked"
590F 0A 43000000 4D00 0000map leaf, size 10: @43 → @4D
6307 0E 20040000 3900 0000 59000000map branch, size 14, depth 0 (root), slots 5, 10: @39 → @59
MemberValueMeaning
blackholeTextThe definition path.
parametersObjectOptional. Merged over the query's declared parameters, as for a stored query run.

Preview results use these members. Public results omit empty collections.

MemberMeaning
digestA SHA-256 value {#sha256 ...} identifying what execution may change.
targetsThe number of selected entity fields.
matchedThe number of assertions the operation rewrites.
replacementsThe number of assertions replaced.
removalsThe number of assertions turned into retractions.
confirmThe text execute must repeat.
samplesUp to ten records with entity, field, transaction and replacement.
affectedMaps of erased entities and rewritten fields, including incoming-reference cleanup. See audit metadata.

The digest covers the definition and its authored revision, the effective parameters, the cutoff, every selected entity field with its expanded expression and row bindings, and the original assertions. It does not depend on sample replacements or seeds.

Two rows can select the same entity field. They form one target when they agree: both remove the field, or both apply the same expression to the same row bindings. Rows that disagree are refused with invalid_argument and the code conflicting_targets.

Each preview generates one temporary seed and returns samples from it. Another preview can return different samples with the same approval digest. Preview does not keep operation state between calls, so preview and execution can run in different processes.

Limits and errors

ResourceLimit
Selected entity fields100,000 in one operation.
Rewritten assertions1,048,576 in one operation.
Authored program64 KiB.
Expanded program64 KiB.
Evaluation work10,000,000 counted expression operations in one operation.
Evaluation CPUFive seconds of thread CPU time in one operation.
Whole-entity and incoming-reference selection10,000,000 history rows and five seconds of thread CPU time per expansion.
Definition copies, selection bindings, expression state and planned replacementsThe database memory budget.

Repeated planning shares the same work and CPU limits. These failures change no history:

StatusCodeCause
invalid_argumentinvalid_requestThe request is malformed.
invalid_argumentinvalid_parametersThe parameters do not fit the query.
invalid_argumentinvalid_definitionThe stored definition is not a valid blackhole.
invalid_argumentinvalid_queryThe query cannot run.
invalid_argumenttarget_not_entityA patch variable bound something other than an entity.
invalid_argumentunbound_variableAn expression reads a variable a row does not bind.
invalid_argumentconflicting_targetsTwo rows give one entity field different changes.
invalid_argumentincoming_linksAn entity selected for erasure has incoming references, but the definition omits links {incoming remove}.
invalid_argumentprotected_linkA protected system field references an entity selected for erasure.
invalid_argumentinvalid_targetA selected entity is not a data entity.
invalid_argumentinvalid_expressionAn expression is invalid or exceeds its size limit.
not_foundnot_foundNo definition has the path.
not_foundno_matchThe selection has no assertion to rewrite.
evaluation_failedexpression_failedEvaluation fails.
evaluation_failedwork_limitEvaluation exceeds its work or CPU limit.
out_of_memoryexhaustedThe operation exceeds a limit or cannot allocate the memory it needs.

Error messages do not include expression diagnostics that could disclose original values or the private seed.

Execute

execute repeats the preview's blackhole and parameters. It also requires these members:

MemberValue
digestThe SHA-256 value {#sha256 ...} from the approved preview.
confirmThe exact confirmation text from that preview.
actorNonblank text identifying who requested the operation.
reasonNonblank text explaining the operation.

Copy digest and confirm from your actual preview. The digest below is only an example:

TRON376 B
Offset (hex)Bytes (hex)Meaning
00054 52 4F 4Emagic TRON
0045C 236C696E6Btxt "#link"
00A02 07000000000000 00i64 7
0130F 0A 04000000 0A00 0000map leaf, size 10: @4 → @A
01D6C 3F6F776E6572txt "?owner"
0240F 0A 1D000000 1300 0000map leaf, size 10: @1D → @13
02E7C 23736861323536txt "#sha256"
03614 40 356230666434 6131633665396232 6438613337633065 3431663964356136 6238633365376632 3039313464366138 3562376331653066 3361396432346236 6338txt "5b0fd4a1c6e9b2d8a37c0e41…"
0780F 0A 2E000000 3600 0000map leaf, size 10: @2E → @36
082AC 706172616D6574 657273txt "parameters"
08D0F 0A 82000000 2400 0000map leaf, size 10: @82 → @24
0976C 646967657374txt "digest"
09E0F 0A 97000000 7800 0000map leaf, size 10: @97 → @78
0A85C 6163746F72txt "actor"
0AE3C 6F7073txt "ops"
0B20F 0A A8000000 AE00 0000map leaf, size 10: @A8 → @AE
0BC07 0E 00240000 9E00 0000 B2000000map branch, size 14, depth 1, slots 10, 13: @9E → @B2
0CA9C 626C61636B686F 6C65txt "blackhole"
0D4BC 6B6579732F6C65 616B6564txt "keys/leaked"
0E00F 0A CA000000 D400 0000map leaf, size 10: @CA → @D4
0EA7C 636F6E6669726Dtxt "confirm"
0F214 27 5045524D414E 454E544C59205245 5752495445204849 53544F525920414E 44204241434B5550 53txt "PERMANENTLY REWRITE HIST…"
11B0F 0A EA000000 F200 0000map leaf, size 10: @EA → @F2
1256C 726561736F6Etxt "reason"
12C14 14 457261737572 6520726571756573 742032323931txt "Erasure request 2291"
1420F 0A 25010000 2C01 0000map leaf, size 10: @125 → @12C
14C07 0E 01080000 1B01 0000 42010000map branch, size 14, depth 1, slots 0, 11: @11B → @142
15A07 16 200E0000 8D00 0000 BC000000 E000 0000 4C010000map branch, size 22, depth 0 (root), slots 5, 9, 10, 11: @8D → @BC → @E0 → @14C

Execution blocks other writes, then selects and plans the definition again with a fresh 256-bit cryptographic seed. Callers cannot supply the seed, and every expression in the operation uses the same one. The plugin discards it when the operation finishes. Execution applies the rewrite only if the new digest matches the approved one. Editing the definition, changing the parameters, or any commit since the preview causes conflict. Obtain a new preview and approval before trying again.

Every selected entity field changes in one transaction. Queries and indexes read the rewritten history. Subscriptions receive an incomplete change notification and read the database again. An index that covers a selected field but cannot repair itself rejects execution with unavailable and the code index_unsupported. On macOS, execution is refused while the filesystem plugin has a mount configured. The macOS mount cannot expire files that are already open, so execute reports unsupported with the code mounted_removal_unsupported and changes nothing. To execute, reopen the database without the filesystem plugin.

The execution result contains these members:

MemberMeaning
stagecomplete, or recovering if the rewrite committed but backup or recovery-record cleanup remains.
transactionThe rewrite transaction ID. Its metadata contains the immutable audit.
cutoffThe approved transaction cutoff.
targetsThe number of selected entity fields.
matchedThe number of assertions rewritten.
replacementsThe number of assertions replaced.
removalsThe number of assertions turned into retractions.
requestDigestA SHA-256 value {#sha256 ...} identifying the targets with their expressions and row bindings.
effectDigestA SHA-256 value {#sha256 ...} identifying the changes to the assertions.

Execution results contain no samples or seed. The replacement values remain readable in the rewritten records. An expression that returns the original value or exposes the seed can disclose sensitive information. Choose expressions that remove the information you need to erase.

An output allocation failure can occur after the rewrite commits. Read the audit or reopen the database before retrying.

Backup recovery

With the backups plugin enabled, every target must be reachable and match local history before execution begins. Otherwise, execute reports unavailable and changes nothing. The operation completes these steps:

  1. The rewrite, its transaction audit, the rebuilt indexes and a recovery record commit together.
  2. Every target replaces its history from the first changed transaction with the rewritten history.
  3. The recovery record is deleted.

A failure before the first step leaves history unchanged. After that commit, cancellation, closing the database or a crash cannot undo the rewrite. A result with stage recovering confirms that the local rewrite and audit committed but recovery work remains. Until the database reopens, another execute reports unavailable with the code recovery_pending. The next database open resumes recovery before comparing local history with the targets. Opening fails while a required target is unreachable. While the backups plugin is disabled, recovery waits and status reports recovering true. Enable backups and reopen the database to finish recovery. See backup status for target progress and whether new writes are allowed.

Keep every recorded target configured with its original name and storage namespace until recovery finishes. Removing, renaming or redirecting a target prevents recovery. Restore its original configuration and reopen the database. Recovery copies the committed replacements without evaluating the expressions again. It needs no execution seed.

Audit and status

Each execution writes one immutable stardust/blackhole metadata object on its own transaction. The audit commits atomically with the rewrite. Recovery does not create or change it. Only the plugin can write this reserved field. Explicit patches cannot target transactions; incoming-reference cleanup can remove links from ordinary user transaction metadata.

The object contains definition, definitionDigest, actor, reason, cutoff, matched, requestDigest, effectDigest and affected. definition links to the named definition; definitionDigest identifies its authored source at execution. All digest fields are native SHA-256 values, written as {#sha256 ...} in DUST. affected.entities maps erased entity IDs to true. affected.fields maps each rewritten field name to a map of affected entity IDs, also with values of true. Whole-entity erasures appear in entities; their fields are not repeated in fields. Public results omit empty groups, as with other empty object members. Recovery progress is separate from transaction metadata.

For example, this scope erases entity 101 and removes incoming references from entity 200's manager field:

TRON129 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
043C 313031txt "101"
0809bit true
090F 0A 04000000 0800 0000map leaf, size 10: @4 → @8
133C 323030txt "200"
1709bit true
180F 0A 13000000 1700 0000map leaf, size 10: @13 → @17
227C 6D616E61676572txt "manager"
2A0F 0A 22000000 1800 0000map leaf, size 10: @22 → @18
348C 656E7469746965 73txt "entities"
3D0F 0A 34000000 0900 0000map leaf, size 10: @34 → @9
476C 6669656C6473txt "fields"
4E0F 0A 47000000 2A00 0000map leaf, size 10: @47 → @2A
5807 0E 09000000 3D00 0000 4E000000map branch, size 14, depth 0 (root), slots 0, 3: @3D → @4E
668C 61666665637465 64txt "affected"
6F0F 0A 66000000 5800 0000map leaf, size 10: @66 → @58

The plugin does not copy removed values or invocation parameters into the audit. Keep sensitive information out of the actor and reason text you supply.

audit lists these metadata objects with their transaction IDs in ascending transaction order. Its optional request accepts after and limit. The limit is from 1 to 1000. status reports enabled, audits, recovering and backups.

Removal limits

A blackhole changes readable history in this database and its configured backup targets. Later writes can store the fields or the same values again. Removing a field that references a binary payload does not delete that shared payload.

Removal does not overwrite freed disk pages or erase versions kept by a storage provider. Independent database copies and external snapshots require separate cleanup. Bytes already delivered to an application cannot be recalled.

Reopen mounted snapshots affected by a rewrite. Discard staged saves based on the old history and read the records again.

Operations

OperationReturnsSummary
previewUnavailableblackholes.preview(request) selects and plans a stored blackhole definition and returns an owned document with the digest to approve.
executeUnavailableblackholes.execute(request) permanently rewrites the approved history and returns an owned completion record.
auditUnavailableblackholes.audit(options) returns an owned array document of transaction audits in ascending transaction order.
statusUnavailableblackholes.status() returns an owned document describing the runtime.

preview

C calls plugin operations through stardust_db_plugin_call and stardust_db_plugin_stream_open with a request document.

Also calls: stardust_db_plugin_call, stardust_result_take_document, stardust_result_error, stardust_result_release

execute

C calls plugin operations through stardust_db_plugin_call and stardust_db_plugin_stream_open with a request document.

Also calls: stardust_db_plugin_call, stardust_result_take_document, stardust_result_error, stardust_result_release

audit

C calls plugin operations through stardust_db_plugin_call and stardust_db_plugin_stream_open with a request document.

Also calls: stardust_db_plugin_call, stardust_result_take_document, stardust_result_error, stardust_result_release

status

C calls plugin operations through stardust_db_plugin_call and stardust_db_plugin_stream_open with a request document.

Also calls: stardust_db_plugin_call, stardust_result_take_document, stardust_result_error, stardust_result_release