# Paired REM project Markdown preview

`co rem fleet` exchanges reviewed project Markdown between two devices. The
owner chooses one shared project ID and one publisher. Both devices can add
contributions. The publisher can save a synthesis that cites the exact input
revisions it reviewed. `fleet show` prints the stored Markdown verbatim.

## Run with synthetic notebooks

From this worktree, run the setup below in Bash or Zsh. It creates two throwaway
signing identities, two notebooks, and four sample Markdown files in a temporary
directory. Use a Python interpreter with ConnectOnion dependencies installed.
Set `PYTHON` to an absolute interpreter path if needed. The fixture uses no
accounts or network transport.

```sh
export PYTHONPATH="$PWD"
py=${PYTHON:-python3}
demo=$(mktemp -d)
"$py" - "$demo" <<'PY'
from pathlib import Path
import sys

from nacl.signing import SigningKey

base = Path(sys.argv[1])
addresses = {}
for name in ("laptop", "desktop"):
    key = SigningKey.generate()
    path = base / name / ".co/keys/agent.key"
    path.parent.mkdir(parents=True)
    path.write_bytes(bytes(key))
    path.chmod(0o600)
    addresses[name] = "0x" + key.verify_key.encode().hex()
    (base / name / "address").write_text(addresses[name])

for name in addresses:
    directory = base / name / "notes/devices"
    directory.mkdir(parents=True)
    for device, address in addresses.items():
        (directory / f"{device}.md").write_text(f"# {device}\n\n## Facts\n- Status: active\n- Address: {address}\n")
        (directory / (device + ".policy.md")).write_text(
            f'---\nkind: device\nstore_level: personal\nidentities:\n'
            f'  - {{id: "{address}", type: key, verified: owner}}\n'
            'edges:\n  - {rel: belongs_to, to: me, verified: owner}\n---\n'
        )

(base / "mail.md").write_text("# Aurora progress\n\nDelivery starts Monday.\n")
(base / "coding.md").write_text("# Aurora decision\n\nUse the local queue.\n")
(base / "legacy.md").write_text("# Aurora progress\n\nMonday is the start of delivery.\n")
(base / "synthesis.md").write_text("# Aurora\n\nStart delivery Monday with the local queue.\n")
PY

laptop=$(cat "$demo/laptop/address")
desktop=$(cat "$demo/desktop/address")
left()  { (cd "$demo/laptop"  && "$py" -m connectonion.cli.main rem --root notes "$@"); }
right() { (cd "$demo/desktop" && "$py" -m connectonion.cli.main rem --root notes "$@"); }

left fleet pair "$desktop" --page projects/aurora --publisher "$laptop"
right fleet pair "$laptop" --page projects/aurora --publisher "$laptop"
left fleet add "$demo/mail.md" --source mail --ref mail:synthetic:42 --source-revision v1 --version manual-v1 --level personal
right fleet add "$demo/coding.md" --source coding --ref codex:synthetic:7 --source-revision v1 --version manual-v1 --level personal
right fleet add "$demo/legacy.md" --source legacy --ref mail:synthetic:42 --source-revision v1 --version manual-v1 --level personal

left fleet export "$demo/laptop.bundle"
right fleet apply "$demo/laptop.bundle" --ack "$demo/laptop-ack.bundle" --local-file
left fleet ack "$demo/laptop-ack.bundle" --local-file
right fleet export "$demo/desktop.bundle"
left fleet apply "$demo/desktop.bundle" --ack "$demo/desktop-ack.bundle" --local-file
right fleet ack "$demo/desktop-ack.bundle" --local-file

left fleet status
reviewed=$(left --json fleet status | "$py" -c 'import json, sys; print(json.load(sys.stdin)["data"]["reviewed"])')
left fleet publish "$demo/synthesis.md" --reviewed "$reviewed" --version manual-v1 --level personal
left fleet export "$demo/synthesis.bundle"
right fleet apply "$demo/synthesis.bundle" --ack "$demo/synthesis-ack.bundle" --local-file
left fleet ack "$demo/synthesis-ack.bundle" --local-file

right fleet show
left fleet publish "$demo/synthesis.md" --reviewed "$reviewed" --version manual-v1 --level personal
left fleet export "$demo/after-ack.bundle"
```

The second publish reports unchanged. The final export reports zero revisions
and creates no bundle. `fleet status` lists each original and its citations. To
read any original, pass its full revision ID to `fleet show`.

To capture a successful no-change review with fresh evidence, continue in the
same shell:

```sh
printf '# Aurora update\n\nMonday is confirmed.\n' > "$demo/mail-v2.md"
left fleet add "$demo/mail-v2.md" --source mail --ref mail:synthetic:42 --source-revision v2 --version manual-v1 --level personal
reviewed=$(left --json fleet status | "$py" -c 'import json, sys; print(json.load(sys.stdin)["data"]["reviewed"])')
left fleet publish "$demo/synthesis.md" --reviewed "$reviewed" --version manual-v1 --no-change "The new evidence confirms the current plan"
left fleet status
```

The status shows the assessment and its reason. Only the new evidence
revision is eligible for export.

## Transfer and disclosure

With an existing paired agent project on each device, use `fleet send` to
make a fresh export and send it to the configured peer. On the receiver, run
`co receive` and supply the exact landed path, such as
`.co/inbox/files/YYYY-MM-DD/rem-fleet.bundle`, to `fleet apply FILE --ack NEW_FILE`.
Return the ACK with `co send PEER ACK_FILE` and use its landed path in
`fleet ack FILE`. The existing transport requires permission to send files
to the other agent. Fleet checks the full sender address, receipt path and
checksum, then decrypts and verifies the bundle. Bundles and ACKs are
encrypted to the paired recipient, including when using `--local-file` for
deliberately copied files outside the inbox.

Each address must be owner-verified in the device policy beside its active
device page. The sender checks both devices at export, and the receiver
checks them again on apply. A revoked or lost bound device blocks exchange.

The `--level` applies to the entire Markdown revision, its provenance and all
citations. Use the default `sensitive` when unsure. This preview exports only
recoverable flows to an owner-held device whose current policy permits the
whole revision. Policy also checks a synthesis's input revisions. Use only
reviewed summaries and opaque evidence IDs as inputs. If you transfer files
manually, create a fresh export immediately before each send and discard stale
exports after a policy change. A prior export is still decryptable by its
intended recipient. The receiver can enforce its own current policy, and a
sender-side policy change alone cannot retract an earlier export or delivery.

If a bundle was applied but the ACK was lost, replay the bundle using a fresh
ACK path. If a synthesis was deferred because its inputs hadn't arrived, apply
the inputs and replay the synthesis. New exports omit acknowledged revision IDs.

## Scope

The preview keeps its revision history in the local REM store and exposes it
through `fleet status` and `fleet show`. It leaves existing project pages and
original files in place. The owner stages each legacy original under a shared
project ID only after checking identity or citations. Title-only matches remain
outside the shared project.

The CLI records a successful synthesis's evidence fingerprint and exact
reviewed inputs. Unchanged evidence skips explicit publish, and a correction,
new source revision, or `--rebuild` permits a new synthesis. If fresh evidence
leaves the published Markdown byte-identical, use `fleet publish FILE --reviewed TOKEN
--version VERSION --no-change "REASON"` to record the reviewed inputs and reason
locally without creating a revision. A failed or deferred review stays due. The preview does
not run the nightly Abstract model, assign collection across devices, manage
failover, or promote fleet Markdown into the normal REM reader. #3627 is
needed to coordinate a shared mailbox before collection and extraction.
