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:
| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 000 | 54 52 4F 4E | magic TRON |
| 004 | 2C 3F65 | txt "?e" |
| 007 | 0E 0D 00 0100 010000 00 04000000 | array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @4 |
| 014 | 2C 3F65 | txt "?e" |
| 017 | 4C 6B696E64 | txt "kind" |
| 01C | 6C 6170694B6579 | txt "apiKey" |
| 023 | 0E 15 00 0700 030000 00 14000000 170000 00 1C000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @14 → @17 → @1C |
| 038 | 2C 3F65 | txt "?e" |
| 03B | 5C 6F776E6572 | txt "owner" |
| 041 | 9C 3F6B65794F776E 6572 | txt "?keyOwner" |
| 04B | 0E 15 00 0700 030000 00 38000000 3B0000 00 41000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @38 → @3B → @41 |
| 060 | 1C 3D | txt "=" |
| 062 | 9C 3F6B65794F776E 6572 | txt "?keyOwner" |
| 06C | 6C 3F6F776E6572 | txt "?owner" |
| 073 | 0E 15 00 0700 030000 00 60000000 620000 00 6C000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @60 → @62 → @6C |
| 088 | 0E 15 00 0700 030000 00 23000000 4B0000 00 73000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @23 → @4B → @73 |
| 09D | 5C 7768657265 | txt "where" |
| 0A3 | 0F 0A 9D000000 8800 0000 | map leaf, size 10: @9D → @88 |
| 0AD | 4C 66696E64 | txt "find" |
| 0B2 | 0F 0A AD000000 0700 0000 | map leaf, size 10: @AD → @7 |
| 0BC | 07 0E 0A000000 A300 0000 B2000000 | map branch, size 14, depth 0 (root), slots 1, 3: @A3 → @B2 |
| 0CA | 4C 6C697374 | txt "list" |
| 0CF | 5C 3F73656564 | txt "?seed" |
| 0D5 | 6C 3F76616C7565 | txt "?value" |
| 0DC | 0E 15 00 0700 030000 00 CA000000 CF0000 00 D5000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @CA → @CF → @D5 |
| 0F1 | 4C 68617368 | txt "hash" |
| 0F6 | 0E 11 00 0300 020000 00 F1000000 DC0000 00 | array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @F1 → @DC |
| 107 | 6C 736563726574 | txt "secret" |
| 10E | 00 | nil |
| 10F | 0F 0A 07010000 0E01 0000 | map leaf, size 10: @107 → @10E |
| 119 | 4C 6E6F7465 | txt "note" |
| 11E | 8C 72656461637465 64 | txt "redacted" |
| 127 | 0F 0A 19010000 1E01 0000 | map leaf, size 10: @119 → @11E |
| 131 | 5C 746F6B656E | txt "token" |
| 137 | 0F 0A 31010000 F600 0000 | map leaf, size 10: @131 → @F6 |
| 141 | 07 12 00380000 0F01 0000 27010000 3701 0000 | map branch, size 18, depth 0 (root), slots 11, 12, 13: @10F → @127 → @137 |
| 153 | 2C 3F65 | txt "?e" |
| 156 | 0F 0A 53010000 4101 0000 | map leaf, size 10: @153 → @141 |
| 160 | 5C 7175657279 | txt "query" |
| 166 | 0F 0A 60010000 BC00 0000 | map leaf, size 10: @160 → @BC |
| 170 | 5C 7061746368 | txt "patch" |
| 176 | 0F 0A 70010000 5601 0000 | map leaf, size 10: @170 → @156 |
| 180 | 07 0E 40020000 6601 0000 76010000 | map branch, size 14, depth 2, slots 6, 9: @166 → @176 |
| 18E | 07 0A 01000000 8001 0000 | map branch, size 10, depth 1, slots 0: @180 |
| 198 | 07 0A 80000000 8E01 0000 | map branch, size 10, depth 0 (root), slots 7: @18E |
| 1A2 | 98010000 00000000 | root → @198; previous: none |
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:
| Value | Effect on every assertion of the field |
|---|---|
null | Turns the assertion into a retraction. The field disappears from current and historical records. |
| An expression | Replaces 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.
Whole entities and incoming links
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:
| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 000 | 54 52 4F 4E | magic TRON |
| 004 | 2C 3F65 | txt "?e" |
| 007 | 0E 0D 00 0100 010000 00 04000000 | array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @4 |
| 014 | 2C 3F65 | txt "?e" |
| 017 | 4C 6B696E64 | txt "kind" |
| 01C | 6C 706572736F6E | txt "person" |
| 023 | 0E 15 00 0700 030000 00 14000000 170000 00 1C000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @14 → @17 → @1C |
| 038 | 1C 3D | txt "=" |
| 03A | 2C 3F65 | txt "?e" |
| 03D | 7C 3F656E74697479 | txt "?entity" |
| 045 | 0E 15 00 0700 030000 00 38000000 3A0000 00 3D000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @38 → @3A → @3D |
| 05A | 0E 11 00 0300 020000 00 23000000 450000 00 | array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @23 → @45 |
| 06B | 5C 7768657265 | txt "where" |
| 071 | 0F 0A 6B000000 5A00 0000 | map leaf, size 10: @6B → @5A |
| 07B | 4C 66696E64 | txt "find" |
| 080 | 0F 0A 7B000000 0700 0000 | map leaf, size 10: @7B → @7 |
| 08A | 07 0E 0A000000 7100 0000 80000000 | map branch, size 14, depth 0 (root), slots 1, 3: @71 → @80 |
| 098 | 2C 3F65 | txt "?e" |
| 09B | 00 | nil |
| 09C | 0F 0A 98000000 9B00 0000 | map leaf, size 10: @98 → @9B |
| 0A6 | 8C 696E636F6D696E 67 | txt "incoming" |
| 0AF | 6C 72656D6F7665 | txt "remove" |
| 0B6 | 0F 0A A6000000 AF00 0000 | map leaf, size 10: @A6 → @AF |
| 0C0 | 5C 7175657279 | txt "query" |
| 0C6 | 0F 0A C0000000 8A00 0000 | map leaf, size 10: @C0 → @8A |
| 0D0 | 5C 7061746368 | txt "patch" |
| 0D6 | 0F 0A D0000000 9C00 0000 | map leaf, size 10: @D0 → @9C |
| 0E0 | 07 0E 40020000 C600 0000 D6000000 | map branch, size 14, depth 2, slots 6, 9: @C6 → @D6 |
| 0EE | 5C 6C696E6B73 | txt "links" |
| 0F4 | 0F 0A EE000000 B600 0000 | map leaf, size 10: @EE → @B6 |
| 0FE | 07 0E 01100000 E000 0000 F4000000 | map branch, size 14, depth 1, slots 0, 12: @E0 → @F4 |
| 10C | 07 0A 80000000 FE00 0000 | map branch, size 10, depth 0 (root), slots 7: @FE |
| 116 | 0C010000 00000000 | root → @10C; previous: none |
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:
| Variable | Value |
|---|---|
?value | The original typed value. |
?entity | The numeric entity ID. |
?field | The field name. |
?transaction | The assertion's transaction ID. |
?seed | A private random seed for the whole operation. |
Other ?variables | The 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:
| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 00 | 54 52 4F 4E | magic TRON |
| 04 | 5C 236C696E6B | txt "#link" |
| 0A | 02 07000000000000 00 | i64 7 |
| 13 | 0F 0A 04000000 0A00 0000 | map leaf, size 10: @4 → @A |
| 1D | 6C 3F6F776E6572 | txt "?owner" |
| 24 | 0F 0A 1D000000 1300 0000 | map leaf, size 10: @1D → @13 |
| 2E | AC 706172616D6574 657273 | txt "parameters" |
| 39 | 0F 0A 2E000000 2400 0000 | map leaf, size 10: @2E → @24 |
| 43 | 9C 626C61636B686F 6C65 | txt "blackhole" |
| 4D | BC 6B6579732F6C65 616B6564 | txt "keys/leaked" |
| 59 | 0F 0A 43000000 4D00 0000 | map leaf, size 10: @43 → @4D |
| 63 | 07 0E 20040000 3900 0000 59000000 | map branch, size 14, depth 0 (root), slots 5, 10: @39 → @59 |
| 71 | 63000000 00000000 | root → @63; previous: none |
| Member | Value | Meaning |
|---|---|---|
blackhole | Text | The definition path. |
parameters | Object | Optional. Merged over the query's declared parameters, as for a stored query run. |
Preview results use these members. Public results omit empty collections.
| Member | Meaning |
|---|---|
digest | A SHA-256 value {#sha256 ...} identifying what execution may change. |
targets | The number of selected entity fields. |
matched | The number of assertions the operation rewrites. |
replacements | The number of assertions replaced. |
removals | The number of assertions turned into retractions. |
confirm | The text execute must repeat. |
samples | Up to ten records with entity, field, transaction and replacement. |
affected | Maps 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
| Resource | Limit |
|---|---|
| Selected entity fields | 100,000 in one operation. |
| Rewritten assertions | 1,048,576 in one operation. |
| Authored program | 64 KiB. |
| Expanded program | 64 KiB. |
| Evaluation work | 10,000,000 counted expression operations in one operation. |
| Evaluation CPU | Five seconds of thread CPU time in one operation. |
| Whole-entity and incoming-reference selection | 10,000,000 history rows and five seconds of thread CPU time per expansion. |
| Definition copies, selection bindings, expression state and planned replacements | The database memory budget. |
Repeated planning shares the same work and CPU limits. These failures change no history:
| Status | Code | Cause |
|---|---|---|
invalid_argument | invalid_request | The request is malformed. |
invalid_argument | invalid_parameters | The parameters do not fit the query. |
invalid_argument | invalid_definition | The stored definition is not a valid blackhole. |
invalid_argument | invalid_query | The query cannot run. |
invalid_argument | target_not_entity | A patch variable bound something other than an entity. |
invalid_argument | unbound_variable | An expression reads a variable a row does not bind. |
invalid_argument | conflicting_targets | Two rows give one entity field different changes. |
invalid_argument | incoming_links | An entity selected for erasure has incoming references, but the definition omits links {incoming remove}. |
invalid_argument | protected_link | A protected system field references an entity selected for erasure. |
invalid_argument | invalid_target | A selected entity is not a data entity. |
invalid_argument | invalid_expression | An expression is invalid or exceeds its size limit. |
not_found | not_found | No definition has the path. |
not_found | no_match | The selection has no assertion to rewrite. |
evaluation_failed | expression_failed | Evaluation fails. |
evaluation_failed | work_limit | Evaluation exceeds its work or CPU limit. |
out_of_memory | exhausted | The 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:
| Member | Value |
|---|---|
digest | The SHA-256 value {#sha256 ...} from the approved preview. |
confirm | The exact confirmation text from that preview. |
actor | Nonblank text identifying who requested the operation. |
reason | Nonblank text explaining the operation. |
Copy digest and confirm from your actual preview. The digest below is only an example:
| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 000 | 54 52 4F 4E | magic TRON |
| 004 | 5C 236C696E6B | txt "#link" |
| 00A | 02 07000000000000 00 | i64 7 |
| 013 | 0F 0A 04000000 0A00 0000 | map leaf, size 10: @4 → @A |
| 01D | 6C 3F6F776E6572 | txt "?owner" |
| 024 | 0F 0A 1D000000 1300 0000 | map leaf, size 10: @1D → @13 |
| 02E | 7C 23736861323536 | txt "#sha256" |
| 036 | 14 40 356230666434 6131633665396232 6438613337633065 3431663964356136 6238633365376632 3039313464366138 3562376331653066 3361396432346236 6338 | txt "5b0fd4a1c6e9b2d8a37c0e41…" |
| 078 | 0F 0A 2E000000 3600 0000 | map leaf, size 10: @2E → @36 |
| 082 | AC 706172616D6574 657273 | txt "parameters" |
| 08D | 0F 0A 82000000 2400 0000 | map leaf, size 10: @82 → @24 |
| 097 | 6C 646967657374 | txt "digest" |
| 09E | 0F 0A 97000000 7800 0000 | map leaf, size 10: @97 → @78 |
| 0A8 | 5C 6163746F72 | txt "actor" |
| 0AE | 3C 6F7073 | txt "ops" |
| 0B2 | 0F 0A A8000000 AE00 0000 | map leaf, size 10: @A8 → @AE |
| 0BC | 07 0E 00240000 9E00 0000 B2000000 | map branch, size 14, depth 1, slots 10, 13: @9E → @B2 |
| 0CA | 9C 626C61636B686F 6C65 | txt "blackhole" |
| 0D4 | BC 6B6579732F6C65 616B6564 | txt "keys/leaked" |
| 0E0 | 0F 0A CA000000 D400 0000 | map leaf, size 10: @CA → @D4 |
| 0EA | 7C 636F6E6669726D | txt "confirm" |
| 0F2 | 14 27 5045524D414E 454E544C59205245 5752495445204849 53544F525920414E 44204241434B5550 53 | txt "PERMANENTLY REWRITE HIST…" |
| 11B | 0F 0A EA000000 F200 0000 | map leaf, size 10: @EA → @F2 |
| 125 | 6C 726561736F6E | txt "reason" |
| 12C | 14 14 457261737572 6520726571756573 742032323931 | txt "Erasure request 2291" |
| 142 | 0F 0A 25010000 2C01 0000 | map leaf, size 10: @125 → @12C |
| 14C | 07 0E 01080000 1B01 0000 42010000 | map branch, size 14, depth 1, slots 0, 11: @11B → @142 |
| 15A | 07 16 200E0000 8D00 0000 BC000000 E000 0000 4C010000 | map branch, size 22, depth 0 (root), slots 5, 9, 10, 11: @8D → @BC → @E0 → @14C |
| 170 | 5A010000 00000000 | root → @15A; previous: none |
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:
| Member | Meaning |
|---|---|
stage | complete, or recovering if the rewrite committed but backup or recovery-record cleanup remains. |
transaction | The rewrite transaction ID. Its metadata contains the immutable audit. |
cutoff | The approved transaction cutoff. |
targets | The number of selected entity fields. |
matched | The number of assertions rewritten. |
replacements | The number of assertions replaced. |
removals | The number of assertions turned into retractions. |
requestDigest | A SHA-256 value {#sha256 ...} identifying the targets with their expressions and row bindings. |
effectDigest | A 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:
- The rewrite, its transaction audit, the rebuilt indexes and a recovery record commit together.
- Every target replaces its history from the first changed transaction with the rewritten history.
- 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:
| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 00 | 54 52 4F 4E | magic TRON |
| 04 | 3C 313031 | txt "101" |
| 08 | 09 | bit true |
| 09 | 0F 0A 04000000 0800 0000 | map leaf, size 10: @4 → @8 |
| 13 | 3C 323030 | txt "200" |
| 17 | 09 | bit true |
| 18 | 0F 0A 13000000 1700 0000 | map leaf, size 10: @13 → @17 |
| 22 | 7C 6D616E61676572 | txt "manager" |
| 2A | 0F 0A 22000000 1800 0000 | map leaf, size 10: @22 → @18 |
| 34 | 8C 656E7469746965 73 | txt "entities" |
| 3D | 0F 0A 34000000 0900 0000 | map leaf, size 10: @34 → @9 |
| 47 | 6C 6669656C6473 | txt "fields" |
| 4E | 0F 0A 47000000 2A00 0000 | map leaf, size 10: @47 → @2A |
| 58 | 07 0E 09000000 3D00 0000 4E000000 | map branch, size 14, depth 0 (root), slots 0, 3: @3D → @4E |
| 66 | 8C 61666665637465 64 | txt "affected" |
| 6F | 0F 0A 66000000 5800 0000 | map leaf, size 10: @66 → @58 |
| 79 | 6F000000 00000000 | root → @6F; previous: none |
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
| Operation | Returns | Summary |
|---|---|---|
| blackholes_preview | document | blackholes.preview(request) selects and plans a stored blackhole definition and returns an owned document with the digest to approve. |
| blackholes_execute | document | blackholes.execute(request) permanently rewrites the approved history and returns an owned completion record. |
| blackholes_audit | document | blackholes.audit(options) returns an owned array document of transaction audits in ascending transaction order. |
| blackholes_status | document | blackholes.status() returns an owned document describing the runtime. |
blackholes_preview
blackholes_preview :: proc(
db: Database,
request: Document,
allocator := context.allocator,
) -> (
Document,
Error,
)Parameters
| Parameter | Type | Ownership | Default | Meaning |
|---|---|---|---|---|
db | Database | Borrowed for the call | Required | The blackholes owner for this operation. Keep it alive during the call. |
request | Document | Borrowed for the call | Required | The borrowed preview request: {blackhole [parameters]}. |
allocator | mem.Allocator | Value | context.allocator | Allocator for copied return values and diagnostics. The caller releases them with the same allocator. |
Errors
| Status | When |
|---|---|
.Invalid_Argument | the request is malformed, the parameters do not fit the query, a selected target is a reserved field or not a data entity, or rows disagree about one entity field |
.Not_Found | no definition has the path (code not_found), or the selection has no assertion to rewrite (code no_match) |
.Evaluation_Failed | a replacement expression fails or exceeds its work limit. History stays unchanged |
.Unavailable | the database does not enable the blackholes plugin |
.Closed | the database is closed |
.Out_Of_Memory | native memory is exhausted |
Notes
See preview for the request and result fields.
Examples
Store a blackhole definition and preview it
definition := stardust.parse("{query {find [?e] where [[?e name Ada]]} patch {?e {name null}}}", .DUST) or_return
defer stardust.close(&definition)
stored := stardust.patch_definition(db, "blackholes", "people/erase-ada", definition) or_return
stardust.close(&stored)
request := stardust.parse("{blackhole people/erase-ada}", .DUST) or_return
defer stardust.close(&request)
result := stardust.blackholes_preview(db, request) or_return
defer stardust.close(&result)| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 000 | 54 52 4F 4E | magic TRON |
| 004 | 7C 23736861323536 | txt "#sha256" |
| 00C | 14 40 383632313166 3763346165303161 3964353264393661 6265313261666238 3731656134623932 6631656431383164 3063346331373330 3765363232613538 3337 | txt "86211f7c4ae01a9d52d96abe…" |
| 04E | 0F 0A 04000000 0C00 0000 | map leaf, size 10: @4 → @C |
| 058 | 1C 31 | txt "1" |
| 05A | 09 | bit true |
| 05B | 0F 0A 58000000 5A00 0000 | map leaf, size 10: @58 → @5A |
| 065 | 4C 6E616D65 | txt "name" |
| 06A | 0F 0A 65000000 5B00 0000 | map leaf, size 10: @65 → @5B |
| 074 | 6C 6669656C6473 | txt "fields" |
| 07B | 0F 0A 74000000 6A00 0000 | map leaf, size 10: @74 → @6A |
| 085 | CC 7265706C616365 6D656E7473 | txt "replacements" |
| 092 | 02 00000000000000 00 | i64 0 |
| 09B | 0F 0A 85000000 9200 0000 | map leaf, size 10: @85 → @92 |
| 0A5 | 7C 74617267657473 | txt "targets" |
| 0AD | 02 01000000000000 00 | i64 1 |
| 0B6 | 0F 0A A5000000 AD00 0000 | map leaf, size 10: @A5 → @AD |
| 0C0 | 07 0E 08200000 9B00 0000 B6000000 | map branch, size 14, depth 1, slots 3, 13: @9B → @B6 |
| 0CE | 7C 6D617463686564 | txt "matched" |
| 0D6 | 02 01000000000000 00 | i64 1 |
| 0DF | 0F 0A CE000000 D600 0000 | map leaf, size 10: @CE → @D6 |
| 0E9 | 6C 646967657374 | txt "digest" |
| 0F0 | 0F 0A E9000000 4E00 0000 | map leaf, size 10: @E9 → @4E |
| 0FA | 7C 636F6E6669726D | txt "confirm" |
| 102 | 14 27 5045524D414E 454E544C59205245 5752495445204849 53544F525920414E 44204241434B5550 53 | txt "PERMANENTLY REWRITE HIST…" |
| 12B | 0F 0A FA000000 0201 0000 | map leaf, size 10: @FA → @102 |
| 135 | 8C 72656D6F76616C 73 | txt "removals" |
| 13E | 02 01000000000000 00 | i64 1 |
| 147 | 0F 0A 35010000 3E01 0000 | map leaf, size 10: @135 → @13E |
| 151 | 07 0E 01080000 2B01 0000 47010000 | map branch, size 14, depth 1, slots 0, 11: @12B → @147 |
| 15F | 8C 61666665637465 64 | txt "affected" |
| 168 | 0F 0A 5F010000 7B00 0000 | map leaf, size 10: @15F → @7B |
| 172 | 07 1A 308A0000 C000 0000 DF000000 F000 0000 51010000 6801 0000 | map branch, size 26, depth 0 (root), slots 4, 5, 9, 11, 15: @C0 → @DF → @F0 → @151 → @168 |
| 18C | 72010000 00000000 | root → @172; previous: none |
C exports: stardust_db_plugin_call, stardust_result_take_document, stardust_result_error, stardust_result_release
blackholes_execute
blackholes_execute :: proc(
db: Database,
request: Document,
allocator := context.allocator,
) -> (
Document,
Error,
)Parameters
| Parameter | Type | Ownership | Default | Meaning |
|---|---|---|---|---|
db | Database | Borrowed for the call | Required | The blackholes owner for this operation. Keep it alive during the call. |
request | Document | Borrowed for the call | Required | The borrowed execute request: {blackhole [parameters] digest confirm actor reason}. |
allocator | mem.Allocator | Value | context.allocator | Allocator for copied return values and diagnostics. The caller releases them with the same allocator. |
Errors
| Status | When |
|---|---|
.Invalid_Argument | the request is malformed, confirm is wrong, the parameters do not fit the query, a selected target is a reserved field or not a data entity, or rows disagree about one entity field |
.Not_Found | no definition has the path (code not_found), or the selection has no assertion to rewrite (code no_match) |
.Conflict | the definition, parameters, selection or history changed since the preview, or the digest names another request |
.Evaluation_Failed | a replacement expression fails or exceeds its work limit. History stays unchanged |
.Unavailable | the database does not enable the blackholes plugin, an earlier execution is still recovering, an index covers a selected field and cannot be repaired, or a backup target cannot take the blackhole |
.Closed | the database is closed |
.Out_Of_Memory | native memory is exhausted |
Notes
Obtain approval before execution. The plugin cannot undo a committed rewrite. An output allocation failure can occur after commit. Read the audit or reopen before retrying. See execution.
Examples
Execute a blackhole with the approved preview
Approval :: struct {
digest: map[string]string,
confirm: string,
}
Request :: struct {
blackhole, confirm, actor, reason: string,
digest: map[string]string,
}
definition := stardust.parse("{query {find [?e] where [[?e name Ada]]} patch {?e {name null}}}", .DUST) or_return
defer stardust.close(&definition)
stored := stardust.patch_definition(db, "blackholes", "people/erase-ada", definition) or_return
stardust.close(&stored)
target := stardust.parse("{blackhole people/erase-ada}", .DUST) or_return
defer stardust.close(&target)
preview := stardust.blackholes_preview(db, target) or_return
defer stardust.close(&preview)
approval := typed.decode(preview, Approval) or_return
defer typed.destroy(&approval)
request := typed.encode(Request {
blackhole = "people/erase-ada",
digest = approval.digest,
confirm = approval.confirm,
actor = "ops",
reason = "Erasure request",
}) or_return
defer stardust.close(&request)
result := stardust.blackholes_execute(db, request) or_return
defer stardust.close(&result)| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 000 | 54 52 4F 4E | magic TRON |
| 004 | 7C 23736861323536 | txt "#sha256" |
| 00C | 14 40 653133346232 6264323466646563 3961343264343261 6463366665623337 3636366635366239 6532363436386266 6634613462623739 3830643962613966 3631 | txt "e134b2bd24fdec9a42d42adc…" |
| 04E | 0F 0A 04000000 0C00 0000 | map leaf, size 10: @4 → @C |
| 058 | 7C 23736861323536 | txt "#sha256" |
| 060 | 14 40 313736303466 6137386363663365 3664636632303265 6639346563646132 3739643165393666 3035326664373039 6561666435326663 3033306161663031 3936 | txt "17604fa78ccf3e6dcf202ef9…" |
| 0A2 | 0F 0A 58000000 6000 0000 | map leaf, size 10: @58 → @60 |
| 0AC | CC 65666665637444 6967657374 | txt "effectDigest" |
| 0B9 | 0F 0A AC000000 A200 0000 | map leaf, size 10: @AC → @A2 |
| 0C3 | CC 7265706C616365 6D656E7473 | txt "replacements" |
| 0D0 | 02 00000000000000 00 | i64 0 |
| 0D9 | 0F 0A C3000000 D000 0000 | map leaf, size 10: @C3 → @D0 |
| 0E3 | 7C 74617267657473 | txt "targets" |
| 0EB | 02 01000000000000 00 | i64 1 |
| 0F4 | 0F 0A E3000000 EB00 0000 | map leaf, size 10: @E3 → @EB |
| 0FE | 07 0E 08200000 D900 0000 F4000000 | map branch, size 14, depth 1, slots 3, 13: @D9 → @F4 |
| 10C | 7C 6D617463686564 | txt "matched" |
| 114 | 02 01000000000000 00 | i64 1 |
| 11D | 0F 0A 0C010000 1401 0000 | map leaf, size 10: @10C → @114 |
| 127 | DC 72657175657374 446967657374 | txt "requestDigest" |
| 135 | 0F 0A 27010000 4E00 0000 | map leaf, size 10: @127 → @4E |
| 13F | BC 7472616E736163 74696F6E | txt "transaction" |
| 14B | 02 08000000000000 00 | i64 8 |
| 154 | 0F 0A 3F010000 4B01 0000 | map leaf, size 10: @13F → @14B |
| 15E | 6C 6375746F6666 | txt "cutoff" |
| 165 | 02 07000000000000 00 | i64 7 |
| 16E | 0F 0A 5E010000 6501 0000 | map leaf, size 10: @15E → @165 |
| 178 | 5C 7374616765 | txt "stage" |
| 17E | 8C 636F6D706C6574 65 | txt "complete" |
| 187 | 0F 0A 78010000 7E01 0000 | map leaf, size 10: @178 → @17E |
| 191 | 8C 72656D6F76616C 73 | txt "removals" |
| 19A | 02 01000000000000 00 | i64 1 |
| 1A3 | 0F 0A 91010000 9A01 0000 | map leaf, size 10: @191 → @19A |
| 1AD | 07 0E 000C0000 8701 0000 A3010000 | map branch, size 14, depth 1, slots 10, 11: @187 → @1A3 |
| 1BB | 07 22 720E0000 B900 0000 FE000000 1D01 0000 35010000 5401 0000 6E010000 AD01 0000 | map branch, size 34, depth 0 (root), slots 1, 4, 5, 6, 9, 10, 11: @B9 → @FE → @11D → @135 → @154 → @16E → @1AD |
| 1DD | BB010000 00000000 | root → @1BB; previous: none |
C exports: stardust_db_plugin_call, stardust_result_take_document, stardust_result_error, stardust_result_release
blackholes_audit
blackholes_audit :: proc(
db: Database,
options: Document = {},
allocator := context.allocator,
) -> (
Document,
Error,
)Parameters
| Parameter | Type | Ownership | Default | Meaning |
|---|---|---|---|---|
db | Database | Borrowed for the call | Required | The blackholes owner for this operation. Keep it alive during the call. |
options | Document | Borrowed for the call | {} | The borrowed options, or none: {[after] [limit]}. |
allocator | mem.Allocator | Value | context.allocator | Allocator for copied return values and diagnostics. The caller releases them with the same allocator. |
Errors
| Status | When |
|---|---|
.Invalid_Argument | options is not an object, or an option is invalid or unsupported |
.Unavailable | the database does not enable the blackholes plugin |
.Closed | the database is closed |
.Out_Of_Memory | native memory is exhausted |
Notes
The plugin does not copy removed values or invocation parameters into the audit. Keep sensitive information out of actor and reason. See the audit.
Examples
List Blackholes audit records
options := stardust.parse("{limit 100}", .DUST) or_return
defer stardust.close(&options)
result := stardust.blackholes_audit(db, options) or_return
defer stardust.close(&result)| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 00 | 54 52 4F 4E | magic TRON |
| 04 | 0E 09 00 0000 000000 00 | array leaf, size 9, shift 0, bitmap 0000, count 0 (root) |
| 0D | 04000000 00000000 | root → @4; previous: none |
C exports: stardust_db_plugin_call, stardust_result_take_document, stardust_result_error, stardust_result_release
blackholes_status
blackholes_status :: proc(
db: Database,
allocator := context.allocator,
) -> (
Document,
Error,
)Parameters
| Parameter | Type | Ownership | Default | Meaning |
|---|---|---|---|---|
db | Database | Borrowed for the call | Required | The blackholes owner for this operation. Keep it alive during the call. |
allocator | mem.Allocator | Value | context.allocator | Allocator for copied return values and diagnostics. The caller releases them with the same allocator. |
Errors
| Status | When |
|---|---|
.Unavailable | the database does not enable the blackholes plugin |
.Closed | the database is closed |
.Out_Of_Memory | native memory is exhausted |
Examples
Check Blackholes status
result := stardust.blackholes_status(db) or_return
defer stardust.close(&result)| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 00 | 54 52 4F 4E | magic TRON |
| 04 | 6C 617564697473 | txt "audits" |
| 0B | 02 00000000000000 00 | i64 0 |
| 14 | 0F 0A 04000000 0B00 0000 | map leaf, size 10: @4 → @B |
| 1E | AC 7265636F766572 696E67 | txt "recovering" |
| 29 | 01 | bit false |
| 2A | 0F 0A 1E000000 2900 0000 | map leaf, size 10: @1E → @29 |
| 34 | 7C 656E61626C6564 | txt "enabled" |
| 3C | 09 | bit true |
| 3D | 0F 0A 34000000 3C00 0000 | map leaf, size 10: @34 → @3C |
| 47 | 07 0E 50000000 2A00 0000 3D000000 | map branch, size 14, depth 1, slots 4, 6: @2A → @3D |
| 55 | 7C 6261636B757073 | txt "backups" |
| 5D | 01 | bit false |
| 5E | 0F 0A 55000000 5D00 0000 | map leaf, size 10: @55 → @5D |
| 68 | 07 12 22040000 1400 0000 47000000 5E00 0000 | map branch, size 18, depth 0 (root), slots 1, 5, 10: @14 → @47 → @5E |
| 7A | 68000000 00000000 | root → @68; previous: none |
C exports: stardust_db_plugin_call, stardust_result_take_document, stardust_result_error, stardust_result_release