Skip to content

API Reference parrot.knowledge.wiki.sync

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.knowledge.wiki.sync

View source

Sync engine — moves authored knowledge between two wiki planes (FEAT-461).

sync_push/sync_pull replicate memory pages (origin="memory"), their attributed notes, and the asserted edges touching them, between the LOCAL plane (env "local") and a shared REMOTE plane (typically ArangoDB, resolved from target_env's effective config). Conflict rule is last-write-wins per record by :attr:WikiPageRecord.updated_at (TASK-2465), compared as parsed UTC datetimes and clamped to the destination's clock (FEAT-692); a memory record never overwrites a non-memory page with the same concept_id; notes merge append-if-absent so a note is never dropped by a merge; deletes are never propagated (v1 limitation, documented).

The engine talks only :class:BaseWikiStore APIs — never a raw driver — so tests can fake the remote with a second local (sqlite/memory) plane.

Alias BaseWikiStore

Re-exported from parrot.knowledge.wiki.store.BaseWikiStore.

Attribute LWWOutcome

Attribute SYNC_CLOCK_SKEW

Class SyncError

Raised when the remote plane cannot be reached or opened.

Always names the target host/env, and is only ever raised BEFORE any write is attempted — a sync run never partially applies changes without logging them.

Class SyncReport

Outcome of one :func:sync_push / :func:sync_pull run.

Fields:

Field Type Default Description
direction Literal['push', 'pull'] Which way knowledge moved.
env str The target (remote) environment name.
created int 0 Records written that did not exist at the destination.
updated int 0 Records overwritten because the source was strictly newer.
skipped_older int 0 Records left alone because the destination was already as new or newer (LWW).
skipped_own int 0 Pull-only — source records whose asserted_by matched the local identity, excluded by default.
skipped_foreign int 0 Records left alone because the destination page with that concept_id is not a memory page (FEAT-692).
dry_run bool False Whether this report describes a dry run (nothing applied).
details list[str] Optional human-readable per-record lines, for CLI verbose output.

Alias WikiBookkeeper

Re-exported from parrot.knowledge.wiki.bookkeeper.WikiBookkeeper.

Alias WikiPageRecord

Re-exported from parrot.knowledge.wiki.store.WikiPageRecord.

Alias WikiProjectConfig

Re-exported from parrot.knowledge.wiki.project.WikiProjectConfig.

Alias create_wiki_store

Re-exported from parrot.knowledge.wiki.store.create_wiki_store.

Function default_local_identity

The local identity used to filter own-authored records on pull.

default_local_identity() -> str

Returns: str

Alias is_server_backend

Re-exported from parrot.knowledge.wiki.store.is_server_backend.

Alias load_effective_config

Re-exported from parrot.knowledge.wiki.project.load_effective_config.

Attribute logger

Function normalize_sync_stamp

Normalise a sync stamp to UTC and clamp it to now + SYNC_CLOCK_SKEW.

normalize_sync_stamp(value: Any, *, now: datetime | None = None) -> str | None

Parameter Type Default Description
value Any The raw stamp.
now datetime | None None The destination's current time (defaults to the system clock).

Returns: str | None — YYYY-MM-DDTHH:MM:SS[.ffffff]+00:00, or None when unparseable.

Function parse_sync_stamp

Parse a sync updated_at into an aware UTC datetime.

Accepts ISO-8601 strings with Z or any offset, fractional seconds, and datetime objects (postgres rows). A naive value is taken as UTC.

parse_sync_stamp(value: Any) -> datetime | None

Parameter Type Default Description
value Any The raw stamp.

Returns: datetime | None — The UTC datetime, or None when value is missing or unparseable.

Alias resolve_arango_params

Re-exported from parrot.knowledge.wiki.project.resolve_arango_params.

Alias sqlite_policy_from_config

Re-exported from parrot.knowledge.wiki.project.sqlite_policy_from_config.

Function sync_pull

Pull authored knowledge from the shared plane of target_env.

sync_pull(root: Path, *, target_env: str = 'dev', include_own: bool = False, dry_run: bool = False, local_identity: str | None = None) -> SyncReport

Parameter Type Default Description
root Path Repository root.
target_env str 'dev' Environment whose effective config names the remote plane (default "dev").
include_own bool False When False (default), records whose asserted_by matches local_identity are excluded (skipped_own) — your own memories stay authoritative locally. True switches to pure LWW.
dry_run bool False Compute and return the report; apply nothing, log nothing.
local_identity str | None None Identity string to filter on; defaults to :func:default_local_identity.

Returns: SyncReport — The sync report.

Raises:

  • SyncError — The remote plane could not be reached.

Function sync_push

Push local authored knowledge to the shared plane of target_env.

sync_push(root: Path, *, target_env: str = 'dev', dry_run: bool = False, local_identity: str | None = None) -> SyncReport

Parameter Type Default Description
root Path Repository root.
target_env str 'dev' Environment whose effective config names the remote plane (default "dev").
dry_run bool False Compute and return the report; apply nothing, log nothing.
local_identity str | None None Unused for push (accepted for a symmetric signature with :func:sync_pull; push never filters by authorship — every local memory page moves).

Returns: SyncReport — The sync report.

Raises:

  • SyncError — The remote plane could not be reached.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally