Local Evaluation, PDF, SageMaker & Ledger¶
Qualify detection recall locally on your own private corpus, configure direct PDF ingestion and optional OCR, connect AWS SageMaker real-time NER endpoints, and verify audit ledger hash-chain integrity.
Local Evaluation (redactor eval)¶
redactor eval lets a buyer or design partner measure Redactor's detection recall, partial coverage, and false-positive counts locally against their own labelled corpus without sharing raw documents with Software Sushi.
Contract and privacy boundary¶
- Runs inside the buyer's environment using Redactor's actual detection, resolution, and policy stages.
- The shareable JSON report (
schema: "redactor.eval/1") is strictly content-free: it contains counts, ratios, entity types, threshold pass/fail verdicts, baseline deltas, and optional policy metadata (policy_version,policy_hash). It never contains document text, matched values, or excerpts. - Optional
--local-misses-outwrites missed/partial span offsets for local tuning (mode0600). Treat that file as sensitive and never share it externally. - Recall uses strict full-span coverage: a span counts as covered only when every non-whitespace rune of the expected span is covered by active detections of the same entity type. Partial overlaps are counted separately (
partial) rather than inflating recall.
Corpus format (JSONL)¶
One JSON object per line. Spans may specify explicit rune offsets (start/end) or value (all non-overlapping occurrences in text are resolved to rune offsets):
{"id":"note-001","text":"Patient SSN 078-05-1120, email ana@example.com.","spans":[{"entity_type":"US_SSN","value":"078-05-1120"},{"entity_type":"EMAIL_ADDRESS","value":"ana@example.com"}]}
Usage¶
Regex-only local qualification with entity recall gates:
redactor eval \
--corpus ./local-corpus.jsonl \
--min-recall US_SSN=0.98,EMAIL_ADDRESS=0.95 \
--max-partial 0 \
--out ./eval-report.json
With a local Presidio analyzer, a specific policy JSON file, and regression comparison against a previous baseline report:
redactor eval \
--corpus ./local-corpus.jsonl \
--presidio-url http://localhost:3000 \
--policy ./policy.json \
--compare ./baseline-report.json \
--min-recall US_SSN=0.98,PHONE_NUMBER=0.95 \
--out ./eval-report.json
Exit codes¶
0: evaluation completed and every configured threshold gate passed.2: evaluation completed and wrote the report, but one or more--min-recallor--max-partialgates failed.1: usage, corpus format, or I/O error.
See also Pilot success criteria for how buyers agree per-entity acceptance thresholds before launching a pilot.
PDF ingestion and optional OCR¶
Send PDFs to the HTTP ingestion endpoint with Content-Type: application/pdf.
The S3 source recognizes the .pdf suffix, the %PDF- header, or source
format: "pdf". Both paths first try local text extraction with a 10 MiB PDF
limit and a 1 MiB decoded-stream and extracted-text limit. HTTP can enforce a
lower extracted-text limit.
If local parsing succeeds and finds no text, the optional OCR provider receives the original PDF. Text PDFs bypass OCR, including mixed PDFs with some extractable text. Scanned pages in a mixed PDF therefore need separate handling if their text must be covered. Encrypted, malformed, unsupported-layout, and oversized inputs rejected by the local parser are refused before OCR. Without a provider, a PDF without extractable text fails closed.
Successful input continues through the configured detection and redaction
pipeline as UTF-8 text. The output is text with offsets into the extracted text.
Metadata carries redactor.input_format=pdf, redactor.pdf_pages, and
redactor.pdf_extraction=text or ocr. OCR runs before admission, so the HTTP
wait duration covers the subsequent wait for a decision. Empty, invalid, and
oversized OCR results are refused without admitting an item.
| Condition | HTTP status and code | S3 failure reason |
|---|---|---|
| No extractable text | 422 pdf_no_extractable_text |
pdf_no_extractable_text |
| Encrypted PDF | 422 pdf_encrypted |
pdf_encrypted |
| Malformed or unsupported input | 422 pdf_malformed |
pdf_malformed |
| Size limit exceeded | 413 body_too_large |
pdf_too_large |
| OCR provider unavailable | 503 pdf_ocr_unavailable |
pdf_ocr_unavailable |
S3 acknowledges a failed object after reporting it to the configured failure queue. If that queue is absent or the report fails, the message stays on the input queue for SQS redrive. Inspect failures and resubmit after the issue is resolved. Provider response bodies and diagnostics stay out of failure reports.
Enable a provider¶
OCR defaults to disabled. In the stock redactor executable, opt in with environment variables (or PdfOcrMode=textract in the AWS Marketplace Quick Launch template):
| Environment variable | Values / Default | Purpose |
|---|---|---|
REDACTOR_PDF_OCR_MODE |
"" (default, off), http, or textract |
Selects the optional fallback OCR provider invoked only when local text extraction finds zero text. |
REDACTOR_PDF_OCR_URL |
Required for http; optional override for textract |
HTTPS endpoint URL (credentials, query strings, and fragments are refused). |
REDACTOR_PDF_OCR_TOKEN |
Optional (http mode only) |
Bearer token sent in the Authorization header (redacted from logs and config dumps). |
REDACTOR_PDF_OCR_REGION |
Defaults to AWS_REGION / AWS_DEFAULT_REGION |
AWS signing region for textract mode. |
REDACTOR_PDF_OCR_ALLOW_HTTP |
false (default) |
Must be explicitly true to allow cleartext HTTP for a local/VPC fixture. |
REDACTOR_PDF_OCR_TIMEOUT |
30s (default) |
Per-request timeout for OCR calls. |
Go service integrators can also pass httpapi.Options.PDFOCR or s3source.Config{PDFOCR: provider} to s3source.NewWithConfig.
Configure providers before serving requests. A provider receives the full,
unredacted PDF, so its processing and retention are part of the deployment's
data boundary. Both built-in providers default to a 30-second timeout and refuse
redirects.
VPC HTTP sidecar¶
Configure pdf.HTTPOcrProvider with the trusted sidecar's URL and optional
BearerToken. HTTPS is required by default. AllowHTTP explicitly permits
cleartext. Use HTTPS for production PHI traffic and supply any bearer token from
your secret store.
The sidecar receives a POST with Content-Type: application/pdf,
Accept: application/json, and the original PDF as the body. Return a 2xx
response with {"text":"recognized text","pages":1} in UTF-8 JSON. Use empty
text to signal that no text was found. The response is bounded before decoding.
Use 503 for an unavailable sidecar. Keep request bodies and recognized text out
of sidecar logs.
AWS Textract SigV4 adapter¶
Configure pdf.TextractOCRProvider with a Region. The adapter defaults to
https://textract.<region>.amazonaws.com, uses the standard AWS credential chain
when Credentials is unset, and signs the Textract.DetectDocumentText JSON
request with SigV4. For production use an IAM workload role. The required action
for this API is textract:DetectDocumentText.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "textract:DetectDocumentText",
"Resource": "*"
}
]
}
The adapter sends base64 PDF bytes in Document.Bytes. AWS documents
Document.Bytes for PNG and JPEG, and limits synchronous PDF input to one page.
The PDF-bytes request and multi-page response assembly are covered by local
protocol tests. Use the HTTP sidecar for scanned PDFs in production. AWS may
reject PDF bytes with an unsupported-document error, which Redactor treats as
pdf_malformed. AWS Document request ·
AWS Textract limits
AWS SageMaker real-time detector¶
The SageMaker adapter sends one
window of original text per signed InvokeEndpoint request. It converts model
spans to document rune offsets and returns them for Redactor's policy to handle.
It is wired into cmd/redactor via opt-in REDACTOR_SAGEMAKER_* environment
variables (REDACTOR_SAGEMAKER_ENDPOINT, REDACTOR_SAGEMAKER_REGION,
REDACTOR_SAGEMAKER_URL, REDACTOR_SAGEMAKER_ALLOW_HTTP,
REDACTOR_SAGEMAKER_OFFSET_UNIT, REDACTOR_SAGEMAKER_LANGUAGES,
REDACTOR_SAGEMAKER_COUNTRIES, REDACTOR_SAGEMAKER_TIMEOUT).
Configure the adapter¶
detector, err := sagemaker.New(ctx, sagemaker.Config{
Enabled: true,
EndpointName: "sagemaker-br-pii",
Region: "us-east-1",
Languages: []string{"pt"},
Countries: []string{"BR"},
})
Use the endpoint name and region of your deployment. The example uses the Brazilian Personal Data Redaction model name as the endpoint name.
| Field | Behavior |
|---|---|
Enabled |
Defaults to false. Disabled scans and health checks make no endpoint requests. A configured detector can be enabled with SetAvailable(true). |
EndpointName, Region |
Required when enabled. The endpoint name follows SageMaker's alphanumeric and hyphen naming rules, up to 63 characters. The region selects the default runtime host and the signing scope. |
EndpointURL |
Defaults to https://runtime.sagemaker.<region>.amazonaws.com/endpoints/<endpoint>/invocations. A host-only override uses the same invocation path. An override with a non-root path is used verbatim as the target. Credentials, queries, and fragments are refused. |
AllowHTTP |
Defaults to false. Set it explicitly for a cleartext local fixture using synthetic text and test signing credentials. |
OffsetUnit |
Defaults to runes. Also accepts bytes for UTF-8 bytes and utf16 for UTF-16 code units. |
DefaultConfidence |
Defaults to 0.85 for unscored spans. Set an explicit value in (0, 1]. Explicit model scores of zero are preserved. |
Timeout |
Defaults to 10 seconds per invocation, including credential retrieval and response reads. An enclosing runner deadline can end the scan sooner. |
Chunk |
Defaults to 8,192 runes, 1,024 runes of overlap, and a 512-rune whitespace snap distance. Set MaxRunes, OverlapRunes, and SnapRunes together when tuning for the model's token limit. Leave overlap long enough for the largest expected entity. |
Languages, Countries |
Declared model coverage exposed by Coverage(). These declarations do not select a language or change requests. |
EntityMap |
Optional mapping from model labels to Redactor entity types. Keys are trimmed, uppercased, and stripped of a leading B- or I-. Overrides take precedence over built-ins. |
Credentials, HTTPClient |
Optional Go injection points. Defaults use the AWS SDK credential chain and Go's HTTP transport. Redirects are refused. |
Without an injected provider, the adapter uses the AWS SDK's default configuration, including workload roles such as an ECS task role or EC2 instance role. Attach an identity policy to the role that runs Redactor. Replace the account number, region, and endpoint name in this example. AWS SageMaker API permissions
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": "sagemaker:InvokeEndpoint",
"Resource": "arn:aws:sagemaker:us-east-1:111122223333:endpoint/sagemaker-br-pii"
}]
}
Health(ctx) submits a signed invocation with the fixed text
redactor health probe. It exercises the same request and validation path and
can incur inference charges. The external-processor disclosure includes the
endpoint URL, endpoint name, declared offset unit, and uncalibrated-confidence
flag. Code consuming the adapter can read the signing region via Region()
and coverage via Coverage(). The current metrics registry groups the
detector under other.
Model request and response formats¶
The request body is {"text":"..."} with JSON content and accept headers. A
custom Hugging Face handler must accept this input format. All offsets are
zero-based, half-open, and relative to the text in that invocation. Responses
are limited to 8 MiB.
- Software Sushi
sushi-sagemaker-foundryaccepts the request above and the Entity Extractor returns a code-point span envelope such as{"entities":[{"type":"person","text":"João","start":0,"end":4,"score":0.99}]}. The adapter also acceptsspansanddetectionsenvelopes. ConfigureEntityMapfor additional labels such asmoneyif the model emits them. - Hugging Face token classification can return
[{"entity_group":"B-PER","word":"João","start":0,"end":4,"score":0.98}]. The adapter also acceptsentity. Configure the model to emit aggregated spans if an entity spans several tokens. - Wrapped predictions can use
{"predictions":[{...span fields...}]}, a single nested span array, or a single record with anentities,spans, ordetectionsarray. Each invocation has one input, so a response with multiple nested records is rejected. - Software Sushi
sagemaker-br-piireturns{"results":[{"text":"[PERSON_example]","findings":[{"label":"PERSON","start":0,"end":4,"action":"replace"}]}]}. The original-text offsets and finding labels feed Redactor. The model's transformed output and actions are ignored. Userunesfor its Python code-point offsets. Qualify the specific deployed model version before enabling it in a live pipeline.
Labels such as PER, GPE, CPF, CNPJ, and DNI map to PERSON,
LOCATION, BR_CPF, BR_CNPJ, and ES_DNI_NIE. Brazilian model labels
such as CEP, CARD, and PIX_KEY map to LOCATION, CREDIT_CARD, and
BR_PIX_KEY. Unmapped labels are rejected through the shared detector
validation path and produce an invariant error. Add a mapping before enabling
a model that emits a custom label.
Verify offsets and model behavior¶
Use synthetic text with an accented character and a supplementary-plane
character before a known match, such as á😀 João. For João, the expected
range is 3,7) in runes, [7,12) in UTF-8 bytes, and [4,8) in UTF-16.
Verify the model's offsets and the resulting redaction against the original
text. Include a long input with an entity near a window boundary to confirm
the configured overlap and model context limit.
If the model echoes a non-empty exact text for a span, the adapter verifies
that the converted range slices that text. It also checks an optional value
from native Brazilian findings. A contradiction fails the window with an
invariant error and preserves the findings from earlier completed windows.
Hugging Face's word can contain normalized tokens or tokenizer markers, so it
cannot serve as an exact substring check. Health checks do not certify the
offset unit or the model's language coverage.
HTTP failures retain the status code and omit the response body. The scan stops at the first failed window and reports its incomplete coverage. The endpoint receives original text, so confirm that your model container, inference data capture, and network logging settings meet your deployment's data handling requirements. See the [detector coverage contract.
Live AWS qualification record (2026-11-21)¶
Verified in AWS us-east-1 against a live SageMaker
real-time endpoint running Software Sushi's brazilian-pii-redaction-1-0-1
model package (sagemaker-br-pii:ccbfea3, ml.m5.large), invoked end-to-end
from the compiled Linux redactor binary with native SigV4 signing
(REDACTOR_SAGEMAKER_ENDPOINT, REDACTOR_SAGEMAKER_REGION=us-east-1,
OffsetUnit=runes):
- Multibyte + 4-byte emoji offset alignment: verified on synthetic
Brazilian Portuguese prose prefixed with 4-byte emoji and accented
characters (
🏥 São José: Conversamos com Beatriz Almeida…). All returned spans (PERSON,ADDRESS→LOCATION,RG→BR_RG,CPF→BR_CPF,CNPJ→BR_CNPJ,CEP→LOCATION,PHONE→PHONE_NUMBER,EMAIL→EMAIL_ADDRESS,DATE_OF_BIRTH→DATE_TIME) aligned to exact 0-based Unicode code-point offsets with zeroinvariantrejections. - Unlabelled Portuguese prose: redacted unlabelled names and street
addresses (
Beatriz Almeida,João Pedro Nogueira,Camila Ferreira,Fernanda Costa Oliveira,Rua Augusta 1500, São Paulo - SP,Avenida Paulista 900, Bela Vista) that regex alone cannot detect. - 40-document synthetic PT-BR qualification slice (480 labeled spans):
480/480(100.0%) span removal across all 12 entity classes,40/40status=ok(0errors), measuredp50 = 627 ms,p95 = 902 msonml.m5.large. - Large-document sizing note: on
ml.m5.largeCPU instances, multi-window20 KB documents can exceed the 10 s per-invocation default timeout. Set
REDACTOR_SAGEMAKER_TIMEOUT=30s(or deployml.c5.xlarge/ GPU) when scanning long multi-chunk documents. The temporary qualification endpoint, config, and model were deleted immediately after verification.
VPC PrivateLink¶
Create an interface endpoint for com.amazonaws.<region>.sagemaker.runtime
in the region of the inference endpoint. Allow HTTPS on port 443 from the
Redactor workload to the interface endpoint. With private DNS enabled, the
default SageMaker runtime hostname resolves to the interface endpoint. If you
use an endpoint-specific DNS name, set EndpointURL to its HTTPS origin and
keep Region set to the endpoint's AWS region. Both the workload's identity
policy and any VPC endpoint policy must allow invoking the endpoint.
AWS SageMaker Runtime PrivateLink setup
Ledger integrity: the hash chain and the keyed content digest¶
Migration 0019 changed what the decision log can promise. Before it, the
ledger was tamper-resistant: BEFORE UPDATE OR DELETE triggers stop the
application role from rewriting history. It was not tamper-evident: a
table owner, a DBA, or anyone with the cloud account could disable a trigger,
delete every row belonging to one item, re-enable the trigger, and leave a
ledger indistinguishable from one that never held the item — because seq is
dense per item, removing an item whole removed the only thing that could
have shown a gap.
Since 0019 every ledger write also extends a hash chain, and the chain is what makes omission detectable.
How the chain works¶
ledger_entriesholds one row per ledger write: an item's group commit (covering theitemsrow and its initial trace records) or a post-durability record append (egress_okand friends, covering just those records). Entries sit at dense global positions, and each carriessha256(previous entry's hash || canonical payload of the covered rows). Position 0 is the genesis entry, written by the migration itself.ledger_anchorseals the row counts that existed when the chain began (see "History older than the chain" below).ledger_headis the writer's cursor — position and hash of the newest entry. It is a mutable chain table, because every writer locks itFOR UPDATEto serialise into a single chain order. It is a cache, never evidence: the entries prove themselves, and a corrupted cursor makes the next append collide loudly on the entries' primary key.
The canonical payload encoding lives in internal/decisionlog/chain.go and
is pinned by golden-vector tests; a byte of drift there invalidates every
previously written chain, which is why changing it is a versioned decision,
not a refactor.
What each tamper now looks like:
| Tamper | What the verifier reports |
|---|---|
| Rewrite any covered column (a span, an outcome, a digest) | The covering entry's hash no longer recomputes; the fault names the position, the item, and the seq range |
| Delete an item's trace rows | The covering entry finds fewer rows than it covers; named |
| Delete the item and its chain entries | A hole in the dense positions; the missing position is named |
| Insert rows outside the chain (invented history) | The item's row count exceeds its chained coverage; named |
| Rewind the anchor to cover a pre-chain deletion | The genesis hash no longer recomputes |
Running a verification¶
# Exit 0: intact. Exit 1: tampered (or unreachable), with the first fault named.
docker run --rm \
-e REDACTOR_POSTGRES_DSN="postgres://…" \
<your-redactor-image> verify-ledger
It is a one-shot subcommand on the migrate pattern, deliberately not an
admin endpoint: verification is a sequential scan proportional to ledger
size, and its value is that an auditor can run it out of band — against a
read replica or a restored snapshot, with database credentials, independent of
the service whose honesty is in question. It needs SELECT on the ledger
tables and runs in one REPEATABLE READ snapshot, so verifying a live system
is safe; writes that land mid-run are simply the next run's work.
What a clean report claims — and what it does not¶
A clean run proves every retained chained row is byte-for-byte what was committed, in commit order, with nothing inserted, deleted or reordered since. Two boundaries are deliberately called out rather than papered over:
History older than the chain. Rows written before 0019 carry no per-row
hash, and inventing one at migration time would be manufactured evidence.
What the migration can honestly seal is how many such rows existed, and it
does — into ledger_anchor, whose counts the genesis hash covers. So for
pre-chain history: a deletion is detected (the counts stop matching, and
rewinding the anchor breaks the genesis hash) but cannot be named, and a
rewrite is undetectable. The verifier reports pre-chain rows as separate
counts and the CLI prints a warning whenever they exist, so "chain intact"
is never mistaken for "all history verified". A count mismatch in the other
direction (more rows than sealed) usually means a pre-0019 binary kept
writing during a rolling deploy — real rows, but unchained; the fault message
distinguishes the two readings.
Truncation from the tail. A hash chain with no external witness cannot
distinguish "the last N writes were removed and the cursor rewound" from
"those writes never happened" — and more broadly, an adversary who can
rewrite ledger_entries wholesale can rebuild the entire chain around any
edit. This is inherent to self-contained chains, not a defect of this one.
The defence is the head hash: verify-ledger prints head_pos and
head_hash, and an operator who records them somewhere the database
credentials cannot reach — a ticket, a signed release note, a secrets
manager in a different account, a compliance officer's inbox — turns both
attacks into detectable ones: the exported position can only grow, and the
exported hash must appear in the chain at that position. Note the window is
narrow even unwitnessed: an item stops being "the newest entries" as soon as
any later write lands, which on a live deployment is milliseconds.
Write-path cost — measured, not assumed¶
The chain serialises ledger writes on one row lock (ledger_head), because a
dense, gapless chain cannot be built by two writers at once. Measured with
go test ./internal/decisionlog/postgres -bench Append -benchtime 5s -run xxx
(local Postgres 17 container, i9-10910, 8 procs), before and after the chain:
| Path | Before | After | Cost |
|---|---|---|---|
Append, the durability-gate group commit at the Writer's default batch of 64 |
2,173 items/sec | 1,953 items/sec | −10% |
AppendRecords ×8 concurrent (the per-item egress terminal record) |
2,130 appends/sec | 503 appends/sec | −76% |
Two different verdicts, deliberately reported separately:
- The durability gate is fine. The group commit takes the lock once per 64 items and writes all 64 chain entries plus the head update as one statement round trip, so the serialisation is amortised down to −10% on the one path ingress latency actually sits behind.
- The record-append path is genuinely serialised. Each terminal egress record holds the head lock across its own commit fsync, so concurrent appends collapse to one fsync at a time — that is what −76% is. This is inherent to holding a chain-head lock through COMMIT, not an implementation accident; the in-lock work is already minimised (reads happen before the lock, the entry insert and head update share one statement).
Why ~500 serialized appends/sec is acceptable to ship: sustained item
throughput is bounded far lower by detection itself (the per-document
detector budgets are milliseconds-per-KB; see internal/detect), so the
ledger is not the bottleneck in any realistic deployment. If a future
deployment does push past it, the fix is the same group-commit pattern the
durability gate already uses — a small batching writer in front of
AppendRecords, trading milliseconds of evidence latency (the records are
post-durability and already best-effort) for a ~64× amortisation — not a
weaker chain.
The content digest is keyed now¶
items.content_sha256 was a plain SHA-256 of the whole input, exposed on
GET /v1/items. That made it a confirmation oracle: anyone holding a
candidate document could hash it and learn whether it passed through the
deployment; identical submissions linked to each other across items; and
low-entropy inputs — a lone SSN, a templated form with one variable field —
were brute-forceable back to content, in an API that exists to prove content
was removed.
Since 0019 the column holds HMAC-SHA256 under
REDACTOR_CONTENT_HMAC_KEY — a per-deployment secret handled exactly like
REDACTOR_TOKEN_KEY (hex or refuse to start, 128-bit floor,
generate-per-process-and-warn when unset), and deliberately a different
secret, so one compromised key does not unlock both. The digest still proves
"this document produced this trace" to whoever holds the key; it proves
nothing to anyone else.
The column's meaning therefore changes mid-history, and each row says which
side it is on: content_hmac (also on the API as content_hmac) is true
for keyed rows and false for legacy unsalted rows — including rows a
pre-0019 binary writes during a rolling deploy, which inherit the honest
default. Two consequences to be explicit about:
- Old rows keep their unsalted digests. They are append-only evidence; rewriting them to improve them is exactly the tamper the chain now makes detectable. Their confirmation/linkage exposure is unchanged — anyone who could exploit it before 0019 still can, for those rows only.
- Old and new rows are not comparable. The same document produces
different values on either side of the boundary, so digest equality only
means "same document" within a
content_hmacclass — which is the point: cross-item linkage without the key is what was removed.
To verify a document against a keyed row:
HMAC-SHA256(hex-decoded REDACTOR_CONTENT_HMAC_KEY, full document bytes)
must equal the row's content_sha256. Against a legacy row (content_hmac
false): plain sha256(document).
Losing the key does not corrupt anything, but it demotes every keyed digest to an opaque value nobody can re-verify — treat the key with the same care as the token key, and prefer setting it explicitly over the generated-per-process fallback everywhere beyond a laptop.
90-day processing-history retention¶
Migration 0029 introduces automatic history expiration. The service attempts a cleanup at startup and hourly. It permanently deletes complete expired items, their traces, review dispositions and chain entries. This is not archival. Pipelines, policies, configuration, users and credentials are unaffected. Delivered files, external destinations, database backups and WAL have separate retention; this mechanism does not delete them.
The cutoff is database time minus 90 days. Only a contiguous chain prefix can expire: recent commits, processing timestamps, late appends and recent review activity protect an item, and cleanup retreats until no item straddles the boundary. History may therefore remain longer than 90 days. Legacy pre-chain items remain protected because their anchor proves only aggregate counts.
The runtime has no arbitrary DELETE or trigger privileges. It can call a fixed, owner-privileged function with no parameters. The function pins its trusted schema, locks the evidence tables, disables only the four deletion triggers, deletes the prefix and updates a checkpoint in one transaction, then restores the triggers. Errors roll the whole operation back. Lock acquisition times out after two seconds; the sweep times out after thirty seconds and retries on the next hourly pass. Very large backlogs may require an operator maintenance window.
The checkpoint retains the boundary position/hash, original genesis hash, cumulative expired item count and last successful sweep. Verification starts at that checkpoint and explicitly reports retained_from_pos and expired_items. It cannot re-verify deleted payloads or establish that expired history was valid. Export the checkpoint and head hash independently for protection against a DBA rewriting the trusted boundary. Retention does not repair corrupt history.
Activity shows database and history allocation and the last successful cleanup. These numbers include indexes, not WAL or host free space. PostgreSQL normally reuses deleted space after autovacuum instead of shrinking the files. A database disk-size plateau after cleanup is normal. Reports starting before the 90-day window are rejected rather than representing missing history as zero activity.
Before upgrading an existing deployment, export any history that must be kept longer: the first service start enables the 90-day cleanup.
Last updated November 22, 2026 · Suggest an improvement