Trace export #
The built-in export extension makes a reviewed, redacted copy of a session's
history for download. A person starts it with /export; a local CPU tagger the
person installs on purpose redacts the copy; the person reviews the redacted
rows and approves them before anything can be downloaded. The original history
is only read.
extension.gleam
declares the command, the client binding, the service, startup recovery and
session cleanup. The HTTP contract is the export tag in
OpenAPI.
Ownership #
coordinator.gleamis the one actor per daemon that admits work: at most one model download and one scanning export at a time. It keeps their process handles and live progress; the work runs on processes it spawns.job.gleamruns one export: collect, scan, package, publish.trace_sourceis the SDK reader of a session's transcript and provider requests. It needs theHistorycapability.trace.gleamprojects rows to trace events and marks which strings are free text.secrets.gleamis the exact known-secret pass.worker.gleamspeaks the worker protocol and checks every reply.model.gleamanddownload.gleamown the pinned model and its install.ledger.gleamowns theexport_jobsandexport_findingstables.- The redaction engine is
priv/python/albedo_redact.pyandpriv/python/albedo_redaction/; the pinned manifest ispriv/export/tagger.json.
Tagger install #
Nothing downloads a model except POST /extensions/export/tagger/install. The
download follows the pinned manifest's files over HTTPS from Hugging Face and
its CDN only, under the export network route, resuming each file
from its .partial with a byte range. Every file's size and SHA-256 must match
the manifest before the files move into place and verified.json is written.
The tagger is ready only when that stamp names exactly the manifest's files and
every file has its size; the files alone never count. The worker hashes them
again on every load. ALBEDO_EXPORT_TAGGER_MANIFEST names another manifest for
private tests, and only then may a file come from a loopback http address.
Model files live under $ALBEDO_HOME/export/tagger/<model>/, on the daemon's
host. DELETE /extensions/export/tagger removes them, and is refused while an
export runs or a download is in progress.
Collecting #
A create captures the session's last transcript position and last provider request id in one read snapshot. The scope is the whole history or the rows from the newest user row on. The job then reads every row and request within those bounds inside one further read snapshot and writes them to a private staging file. Rows and requests added after the capture stay out, and a link from a row to a request past the bound, or a request's attachment to a row past it, reads as null. No transaction is held while the tagger runs.
Rows become typed events: user, note, assistant, thinking, tool_call,
tool_result, request, and omitted for a row that does not decode or a
provider item with nothing to project. Reasoning, answers and calls come through
message_content; a provider's replay object is never copied. Each row event
carries its turn_id, input_id, request_id (the request that produced it)
and first_sent_by, null when not recorded. Requests carry model, profile,
provider, effort, timing, outcome and reported usage, never the account or the
provider's error text. Tool arguments and results that are JSON objects or
arrays are kept as JSON, read strictly; anything else, or nesting past 64
levels, stays one string. Full arguments come from the call row, not the history
preview.
What a trace leaves out is listed on the event and counted on the job:
encrypted_reasoning (signatures, encrypted or redacted reasoning),
provider_opaque, image and attachment (metadata only, never bytes),
tool_output_truncated (the result the model saw was already cut short),
oversized_text (a string over 8 MiB, replaced by null) and undecodable_row.
Files attached before albedo recorded file metadata cannot be listed. Kernel
spill files are never read.
Redaction #
Every free-text string is scanned: text, tool argument and result values and object keys, numbers a model or person wrote (as their JSON text), file names, and metadata such as profile and model names. The trace's own structure, such as event types, positions, call ids and usage counts, is not.
First the exact known-secret pass replaces every credential the daemon holds,
and its JSON-escaped, base64, base64url and percent-encoded forms, with
[REDACTED:known_secret#n]. The values are read once per export from
creds.json, config.json and extensions.json through settings_store.load,
which holds the settings lock only while it reads. A file that exists but cannot
be read fails the export with credentials_unreadable; a missing file adds
nothing. A value, or an encoding of one, shorter than eight bytes is not matched
exactly; only the tagger may still catch it. These values never leave the
export's process. Then the worker redacts the rest. A redacted number becomes a
string. Two keys of one object that become the same fail the export with
key_collision. The known values are checked again in every reply, every
written row, the report and the manifest; a survivor fails the export with
known_secret_survived.
Markers are [REDACTED:<category>#<n>], with n stable per value within one
export. Findings name the row, a JSON Pointer, whether the span is in a key, the
category, the source (model, rule, or keep for the exact pass), and start
and end as Unicode scalar offsets into the redacted string, covering the marker.
Worker protocol #
One worker process serves one export, started through
host_resources.open_redactor: the kernel's interpreter, or
ALBEDO_REDACT_PYTHON, runs albedo_redact.py, or ALBEDO_EXPORT_WORKER in
tests, through sh, which discards its stderr. Its environment is the cleaned
one plus ALBEDO_REDACT_MODEL_DIR, ALBEDO_REDACT_THREADS,
ALBEDO_REDACT_PROTOCOL and the test overrides. Frames are a 4-byte big-endian
length and one JSON object, at most 32 MiB.
- The worker's first frame is
hellowithprotocol,model_id,rules_versionandcategories, orfatalwith a code. The model and rules must equal the manifest's, and the categories must come from the closed list. redactsends at most 64 items and 4 MiB of text, or one item of up to 8 MiB. Each item has a key, a text, andkeepspans of the known-secret markers.- The worker answers
progressframes, then oneresultwith the same keys in order. Each text is redacted and its spans are in Unicode scalars of the output. Keep spans come back unchanged. Alternatively the worker answerserrorwith a code. closeends the worker. A cancel kills it.
Any other reply, a silent worker for 120 seconds (hello included), an exit, or a mismatch fails the export closed. There is no retry and no fallback. Nothing the worker sends is logged.
Review and download #
A finished scan writes trace.jsonl, redaction-report.json and
manifest.json, zips them stored, in that order, into archive.zip, removes
the staging file, and publishes the job for review. The preview pages the exact
trace.jsonl bytes; findings page the report's entries. POST approve with
If-Match and {"reviewed": true} moves the job to ready, and only a ready
job's archive is served. Files are mode 0600 in directories of mode 0700 under
$ALBEDO_HOME/export/jobs/<id>/.
Cancel stops a running worker and frees the scan slot before it answers; it
removes a reviewed copy's files. Delete removes the job, its findings and its
files. Session deletion removes the session's job rows; startup fails any export
an earlier daemon left scanning, with interrupted, and removes every directory
that holds no reviewable export.