Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
Cursor native journal and load
The hosted Cursor adapter requires PostgreSQL journal storage. The harness supplies the authorized Macro session ID and its own replica ID. Before the actor starts, attachment activation binds the journal to the exact acquired session claim, including its management fence. Unactivated access and rebinding to another generation fail. Every read and append verifies that supplied fence while locking the session row. No new raw-history endpoint or provider-identity mapping is introduced. The standalone stdio binary uses an explicit process-local journal and cannot restore a previous process's sessions.
cursor_journal_input orders inputs by (agent_session_id, sequence) and associates runs by the existing provider's run IDs. A prompt is recorded before execution; PromptAccepted links that original content sequence to the returned run. Raw SSE event names, original joined data text, provider IDs, polling response bodies, transport errors, local terminal decisions, and reconciliation markers are retained. Unknown SSE data is retained even when it cannot be decoded. There is no second ACP transcript here.
Prompt intent sequence preserves pre-execution audit order. Accepted prompts are projected immediately before the run's first native observation, after older-run recovery, rather than at their intent or acceptance position. An accepted run with no observations stays deferred while an older captured tail remains unfinished; recovery publishes its prompt when it reaches that run. Cancellation state is established before pre-prompt recovery and remains effective after that recovery completes.
All emitting paths use the same replay machine after append. Poll results reconcile against the captured final step's text, appending only its missing suffix. Cursor's step-started records distinguish final-answer text from earlier commentary. Divergent text fails rather than guessing an overlap. Completed runs are not ingested again. Reopening a partial stream verifies its captured content prefix before appending new content; status/heartbeat/error records are connection observations and do not participate in prefix matching. No Last-Event-ID request header is sent: provider IDs are retained, but remote resume support is not assumed.
Foreign recovery captures its batch without publishing replacement frames. After validating that the captured history can be reconstructed, a typed host-local requirement asks the session domain to initiate initialize and standard session/load after any dispatched prompt responds. A pending-reload bit pauses only background capture until load completes, not prompts already dispatched by the host. Pending commands wait behind that handshake. Recovery discovered while a load response is queued triggers another load before commands are flushed. The requirement is not a durable status, an agent-initiated client request, or a second replacement protocol. Only a valid successful load commits full history; failed or incomplete loads preserve the selected window. Original user chunks and terminal facts are reconstructed from the journal, including cancelled prompts, without restoring a pending request over replacement history. Standalone clients without the host channel can retrieve captured recovery on their next standard load.
Completed native turns emit the optional, agent-neutral _session/turn_complete notification after their reconstructed updates, with a finished, cancelled, or failed outcome. The generic fold maps that fact to its existing stop vocabulary. A partial replay tail has no terminal fact and remains open; subsequent recovery emits its completion when the provider finishes. Correlated live prompt responses remain authoritative. This extension does not certify loads: ordinary valid ACP load success still replaces history, including an empty replacement, and failed loads still discard their candidate.
Load holds the session turn gate, validates and replays a stable journal snapshot with fresh translation state, and retains that state for continuation. The ACP adapter queues the load response before releasing the gate and enabling synchronization. Journal failures stop readiness and cannot be masked by cancellation. The delivered-run watermark remains separate: its existing ACP marker still goes through the host's fenced append/checkpoint transaction, only after notifications have been queued.
Recovery and rollout limits
A session without complete journal history is hydrated by listing every provider run and fetching each native stream in chronological order. Every run must include its original user message and a terminal result. Hydration is capture-only until all history validates. Final-answer-only records, expired/truncated streams, prefix mismatches, missing user prompts, and unavailable history cause an explicit load error, preserving the committed projection. They never publish a successful incomplete replacement. Hydration performs reads only, never prompt or tool execution.
There is no compatibility interpretation for historical lookup-only load successes: every valid correlated ACP load success replaces history, even with no replay frames. The consolidated migration does not create or backfill the unused agent_session_log.legacy_load column.
A process loss between remote prompt acceptance and persisting the accepted run association can leave an unresolved prompt intent. Without a proven association, load fails explicitly instead of executing that prompt again or dropping its history. Likewise, a foreign run observed only by polling cannot later claim to contain its unavailable original prompt. Operators should retain old Macro history; this migration does not manufacture or backfill missing provider details from ACP frames.
Apply the SQLx-generated 20260906060601_cursor_session_replay migration and prepare SQLx metadata from the repository root before deploying. It adds the delivered-run watermark, session history boundary, and native journal in dependency order. No changes to provider resume negotiation are required. Cursor advertises ACP load only. The generic session/fold layers own successful-load history selection and failed-load staging. A realtime replace event means replay has committed while the client is connected, not that a new live turn has started.
Previously applied PR migrations
PR #6233 consolidated these unreleased migrations into one UP/DOWN pair:
20260905234752_cursor_run_watermark20260906040138_agent_session_history_boundary20260906040140_cursor_native_journal20260906042344_agent_session_legacy_load_context
Fresh environments use the consolidated migration normally. For local environments that already applied the old files, do not reset the database or run their DOWN migrations: that would discard journal inputs and checkpoint values. Back up the database and inspect each database's _sqlx_migrations history, including test databases, before changing anything.
For a database with all four old migrations successfully applied, verify their checksums against the old PR revision and compare its columns, defaults, constraints, and indexes with a fresh consolidated schema (excluding only legacy_load). In one transaction, lock the migration metadata and affected tables, capture row counts and content hashes, drop only the unused legacy_load column without CASCADE, verify the schema and retained data again, then replace exactly those four metadata rows with the consolidated UP version, description, and SHA-384 checksum. Preserve all unrelated migration records. Abort on any mismatch. Check sqlx migrate run afterward; it should be a no-op. Do not stamp a partially applied or divergent schema as migrated; finish and verify its missing schema changes first under a separately reviewed procedure.
The combined DOWN is for deliberate rollback only: it drops the new journal and checkpoint columns. Test DOWN/UP on an isolated disposable database, never on an existing session database whose history must survive. This local reconciliation procedure is not an instruction to rewrite production migration history.