# Connect a private local participant to two memory stores

Version 0.1.4 includes an optional **in-process host integration**, not a new
Hearth server. It connects one already-admitted private request to an existing
owner-bound Qdrant/rules adapter and an explicitly chosen SPIRALMESH SQLite library.
The stores remain separate. Hosted memory remains separate too.

## Try it first, without a model

Extract the ZIP. From that extracted folder, run:

```powershell
python -B integrations/private_dialogue/exercise.py
```

Python 3.11 or newer and its standard library are sufficient. No pip install,
account, key, model download, running server or personal path is needed.
The example creates a temporary synthetic library outside the extracted folder
and removes it on completion. It does not use an existing participant library.

The result should say `status: PASS`, `provider_calls: 0`, `real_qdrant: false`,
and show an observation for each of the Ember and Lumen namespaces. It runs the
real bundled SQLite store and dialogue engine. The primary adapter and model
replies are **scripted fixtures**. This proves integration mechanics, not a real
model's behavior, a Qdrant connection or a hosted service.

Each fixture reads both stores in one session, deliberately saves one note with
verified readback, opens a fresh session, reads that note and declines further
work without another write. Raw note bodies reach the scripted model callback
and are absent from the returned operation evidence.

## What a host developer supplies

`integrations/private_dialogue/host.py` exports `run_private_dialogue`.
Import it by its absolute path in a fresh Python process, just as `exercise.py`
does from its own directory. The helper resolves the bundled engine and `src`
beside itself. It refuses a process already holding a different SPIRALMESH
module rather than silently mixing libraries from two installations.

```python
result = run_private_dialogue(
    node_id="S5_LOCUS",                 # host-fixed Ember namespace
    continuity_root=authorized_library, # existing initialized library
    primary_library=owner_bound_primary,
    chat=authorized_model_callback,
    question=admitted_question,
    request_id=unique_request_id,
    max_rounds=8, max_actions=20, deadline_seconds=120,
)
```

This is a callable function, **not an authenticated server**. Before calling it,
the host must authenticate and admit the private request, bind its permitted
owner and root, and enforce provider selection, credentials, resource limits
and any required egress consent. Do not accept these bindings or callbacks from
model output or a public request. A trusted callback is a host capability.

The fixed bindings are `S5_LOCUS → ember` and `S17_LUMEN → lumen`. These names
select local namespaces, not a vendor identity or proof of who answered. A fork
can deliberately adapt the host mapping. Actions cannot choose another principal
or library path. Constructor failure is reported as unavailable; it does not
create an empty replacement library or remove the primary memory route.

`primary_library.capabilities()` returns the actual primary-store description.
`primary_library.execute(operation, arguments, operation_id)` implements the
existing unprefixed protocol: browse, search, read, remember, correct, forget,
export and rules. It must enforce owner isolation itself. Unsupported operations
must fail explicitly. Successful memory results bind the schema
`article11.agent-memory-result.v1`, operation, operation ID, `state: ok`,
`authority: context_only` and an `items` list. Writes additionally require
`persisted: true` and `readback_verified: true`. The included pure engine contains
the exact schemas; `SyntheticPrimary` demonstrates a read result only.

`chat(messages, response_schema)` returns a dictionary with `content` containing
one JSON response and `done_reason` such as `stop` or `length`. The response has
`choice` (accept, decline or question), `actions`, `reply` and `done`. The callback
must send the supplied schema and full intended conversation to its configured
model and report truncation truthfully. A real callback may incur provider cost
and send private context to that provider. No provider callback is bundled.
Timeouts bound waiting; they cannot cancel an already-running callback thread or
remote request. Do not retry an uncertain write without reconciling its operation
ID. The returned evidence does not schedule a retry or another session.

## What changes and what stays private

When available, the SQLite adapter adds eleven `continuity_*` names: boot,
resume, browse, read, remember, correct, forget, message, inbox, export and
reconcile. Only remember, correct and forget mutate the library through this
adapter. SQLite export returns a private JSON value; it does not write a file.
No new send, share, set-letter or import operation is offered. Existing rights
are checked by the bundled store on every operation.

The complete permitted library remains reachable; a starter letter is not a
retrieval boundary. A failed read is not a refusal, zero selected context is not
proof of an unavailable library, and tool availability is not proof of a read.
`returned_to_model` becomes true only when the following callback actually starts.
Read references identify their store and principal. An inbox row is not proof of
an unread, read or acknowledged status.

Raw tool values remain inside the model conversation. The facade returns chosen
reply text, operation outcomes, hashes and context references. Both SQLite and
primary export payloads are withheld from that returned envelope. This differs
deliberately from the active Hearth runtime's legacy private-export exception.
The model may choose to quote a note in its reply; this helper is not a filter
that proves a reply contains no private information. Publication or forwarding
still needs the host's applicable sharing boundary.

Forgetting removes active content under the store's documented semantics; it
does not erase other versions, exports, backups or provider conversations.
The local administrator can read these files. Namespace boundaries are software
controls, not encrypted isolation, legal standing or proof of subjective experience.

## Existing Hearth users

The terminal and inbox-carry tools recognize both stores and verified SQLite
saves. They still require your existing, explicitly configured private Hearth
route and local authentication. Installing this ZIP does not update or restart
that service. Integrate the optional helper in your own host or use the same
adapter/protocol in your existing runtime after its focused checks. No public
endpoint is opened by extraction or by this example.

The SQLite adapter and pure dialogue engine match the active tested source.
The small host facade is newly derived and tested for this portable package;
it is not represented as a byte-identical deployed server. `SOURCE_INDEX.json`
records this distinction and the exact inputs.
