API routes#
The client uses the public /v1/brains/{brain_id}/application-conversations/{connection_id} prefix: POST /messages for a confirmation or correction, POST /state for current selected fields, POST /withdrawals for removal, and current GET /versions/{version_id} Originals. The canonical OpenAPI describes these operations. The older private thread-recall examples remain supported separately.
Set up a private example#
Install the repository-local Python client and configure the four server environment variables from the quickstart. Use a dedicated authorized test connection. The application must authorize the subject and threads before selecting them.
Run from the repository root. Keep this example directory for all later commands. Initialization is local and makes no network requests.
user_md_demo="$(mktemp -d)"
user_md_trial="$(.venv/bin/python -c 'from uuid import uuid4; print(uuid4())')"
user_md_set_op="$user_md_trial"
user_md_correct_op="$(.venv/bin/python -c 'from uuid import uuid4; print(uuid4())')"
user_md_withdraw_op="$(.venv/bin/python -c 'from uuid import uuid4; print(uuid4())')"
.venv/bin/python -m brain.client.user_markdown init "$user_md_demo/user.md" \
--subject "user-md-$user_md_trial" --field contact-window --field pickup \
--thread first-call --thread returning-callRun setup once per independent trial. Keep these IDs and the directory for every stage or reconciliation of that trial; a fresh local directory alone does not create a fresh server subject or idempotency key.
The output is a managed file. An existing human-authored file is refused. Its private .user.md.brain/ directory holds connection-bound configuration and pending-operation custody. Credentials stay in the server environment.
Confirm exact words#
The source note stays byte-exact. The selected value must bind to a literal source quote. Confirmation is an explicit application/user decision, not a conclusion drawn by this CLI.
printf 'Please call after 6 pm.\n' > "$user_md_demo/contact.md"
.venv/bin/python -m brain.client.user_markdown set "$user_md_demo/user.md" \
--field contact-window --source "$user_md_demo/contact.md" --value "after 6 pm" \
--occurred-at 2026-11-16T12:00:00Z \
--operation-id "$user_md_set_op"
.venv/bin/python -m brain.client.user_markdown context "$user_md_demo/user.md"The file shows the exact confirmed value, a current Original link and an explicit unknown for pickup. Open Originals through your authorized server client; credentials stay out of the Markdown and browser. Its metadata includes the connection binding, revision, check time, expiry and omissions. Routine command output contains outcomes rather than source text; context deliberately prints the refreshed Markdown.
Correct the preference#
printf 'Please call after 7 pm instead.\n' > "$user_md_demo/contact.md"
.venv/bin/python -m brain.client.user_markdown set "$user_md_demo/user.md" \
--field contact-window --source "$user_md_demo/contact.md" --value "after 7 pm" \
--thread returning-call --occurred-at 2026-11-16T12:01:00Z \
--operation-id "$user_md_correct_op"
.venv/bin/python -m brain.client.user_markdown context "$user_md_demo/user.md"The client reads the current field and submits an expected-version correction. A concurrent change can refuse that correction. The next canonical read must show 7 pm, with its new version; the superseded Original is no longer a current read. For an edit based on a previously observed version, pass --expected-version UUID.
Withdraw or clear#
.venv/bin/python -m brain.client.user_markdown withdraw "$user_md_demo/user.md" \
--field contact-window --operation-id "$user_md_withdraw_op"
.venv/bin/python -m brain.client.user_markdown context "$user_md_demo/user.md"The preference becomes Needs confirmation; an older preference must not return. Withdrawal retains custody history and is terminal for this stable field source within the connection. It is not physical erasure. Use clear, with a source note, clock and new operation ID, when you need a reversible “no confirmed value” state that can later be corrected.
Refresh, restart and uncertain writes#
.venv/bin/python -m brain.client.user_markdown watch "$user_md_demo/user.md" \
--interval-seconds 5 --duration-seconds 3600The bounded watch polls canonical state; it does not replay writes. It retires old prose after a failed refresh and stops on 401/403. A transient read failure can recover during a later poll. Each new CLI process reopens the same private control directory; source state remains in PostgreSQL across API restarts.
If a write returns unknown, it may have committed. New writes and context use stop. Keep the operation directory and explicitly reconcile that exact operation:
For example, if the correction returned unknown, its operation ID is the retained user_md_correct_op. If a different step returned unknown, use that step’s actual reported operation ID instead.
.venv/bin/python -m brain.client.user_markdown reconcile "$user_md_demo/user.md" \
--operation-id "$user_md_correct_op"Reconciliation uses the original payload and idempotency key. If that replay is refused, the earlier completion stays unknown: pending custody and the context block remain. A matching receipt resolves it. The private pending source payload is removed after a known terminal outcome; receipt/hash metadata remains. A correction definitively refused on its first attempt needs a fresh decision and new operation ID.
Budgets and freshness#
- 1–16 selected fields and 1–16 authorized threads.
- Source notes: up to 4,096 UTF-8 bytes. Confirmed values: up to 512 UTF-8 bytes.
- The complete output defaults to 8,192 bytes;
init --max-bytesaccepts 1,024–32,000. Fields and citations remain whole; omissions are explicit. A budget unable to fit the metadata is refused before file creation. - Snapshot age defaults to 60 seconds;
--max-age-secondsaccepts 1–300. This is a local consumption bound, not a promise that permission cannot change before expiry.
Use context to revalidate before consuming the file. Direct copies cannot learn of a later withdrawal, revoke themselves or erase content already imported into another tool. Choose that disclosure deliberately. Edit source notes rather than the generated file; observed external edits cause refusal and are preserved.
Byte budgets are not token guarantees. Provider execution, free-form personal understanding and superiority to a simple keyed-state store are outside this flow. See what works today for the measured scope.
What the independent check proved#
Six unseen fictional histories passed all 18 resume checkpoints and 54 field dispositions, including real API restarts and 21 separate CLI invocations. Current Originals opened; superseded and withdrawn values stayed absent. Separate controls covered clear/reconfirmation, uncertain acknowledgement and explicit reconciliation, expiry, refusal, ownership, budgets and scope.
A separate frozen 12-case recovery check passed on the journal update, covering refused replays, API/client restarts, scope and request integrity, and matching-receipt resolution. The earlier client failed 9 of those 12 cases. This check used fictional data and disposable PostgreSQL.
The fair raw-history and keyed-state baselines both tied 18/18 tasks and 54/54 dispositions. The Markdown totaled 541 whitespace words versus 229 minimal raw-value words. This establishes confirmed-state file interoperability and continuity, not reading reduction, semantic memory or a win over those baselines. The check used disposable PostgreSQL and no model calls; it does not establish a live customer workflow or a production latency SLO.