Skip to main content

Module bring_local

Module bring_local 

Source
Expand description

Bringing a project’s local work into the vault it was just linked to (lean-ctx cloud link --bring-local): its local tasks (crate::tasks::local) become proposed tasks of the vault, and its local doc pages (crate::local_docs) pages of the vault, once each.

A local task is brought when it was never shared and is open: Cloud opens every task an Instance proposes (owner decision 25.10.), so a task that is only proposed locally stays local until it is accepted, and a claimed or submitted one stays local so no claim, result or evidence is lost. Its goal ends with "Local task #<n>" as the reference, and it is marked shared locally with the vault’s number, so a second run skips it. Before a task is sent, a local ledger records it; a run interrupted after Cloud answered (or after the request left) resumes from that ledger instead of sending it twice (bring_tasks).

A page is brought when it was never shared and the vault has no page with its slug; /slug links between brought pages point at their new vault ids, links to pages the vault already holds point at those. After the events are queued, each brought page is marked shared locally (journaled, by the person, “cloud link”), so a second run skips it. The events reach Cloud with the next push; the background sync retries what fails.

Structs§

Brought
What --bring-local brings (or would bring).
DocItem
One local page and what the link does with it.
InFlight
A task on its way into a vault, recorded before it is sent.
Ledger
The tasks of one project on their way into a vault, by local number.
TaskItem
One local task and what the link does with it.
TaskSink
What bring_tasks calls on the outside world.
Unsettled
A local task the link would strand: only proposed, claimed or submitted (and not brought yet). Once a project is linked its tasks are Cloud’s, so these are settled locally first.

Constants§

LEAVE_UNSETTLED_FLAG
The flag that links a project although local tasks are unsettled; they then stay local and are reached with lean-ctx tasks … --local.
RESEND_WINDOW_SECS
Cloud replays a proposal’s first answer for this long after it (its instance idempotency keys live 7 days); a ledger entry older than this is never sent again.

Functions§

author
Who a link import is recorded as: the person runs cloud link.
bring_tasks
Bring every propose item of items (planned from tasks, proposals from proposal_of) into the vault vault_id. Each task is entered in ledger before it is sent, gets its number there as soon as Cloud answers, and leaves it once it is marked shared. A task found in the ledger resumes from there: a known number is only marked, never sent again; an unanswered send is repeated with the same key inside RESEND_WINDOW_SECS (Cloud replays its first answer) and after that is reported, never resent, so an interrupted run never makes a second vault task.
doc_events
The vault events that create every import item of items from its raw page (storage form, cloud:<local id> links), choosing its vault id with new_id and filling it into the item.
import
Bring the local tasks, then the local pages, of root into its linked vault (vault = ns/name, id vault_id). Pages need the vault’s replica here; when they cannot go, the tasks that went stay reported as gone and docs_error says why the pages wait (docs is the plan then).
import_docs
Bring the local pages of root into its linked vault vault (ns/name). Needs the vault’s replica on this machine (the first sync makes it).
import_tasks
Bring every open local task of root into the vault vault_id (vault = ns/name): bring_tasks against Cloud, the local task store and the ledger in this Instance’s config.
link_gate
Every path that links a project asks this first: the unsettled local tasks of root, or why the link is refused (leave is the person’s explicit LEAVE_UNSETTLED_FLAG).
local_action_in_linked
Whether action (on local task number, when it names one) may act on the local store of the linked project root: reads always; a write only on a task that was not brought into a vault; new tasks go to Cloud.
local_not_shared
The local tasks of root that are neither brought into a vault nor closed: in a linked project they are “local, not shared” and stay reachable with --local (also when the link came in through git).
not_shared_note
One line naming list for a linked project’s task list; None when there are none.
plan_docs
What to do with each of pages, given the vault’s slugs (slug → id; empty when the vault is not read, as on a dry run).
plan_local
The plan for root from local state only (--dry-run, or before the vault is shared): pages the vault already holds show as import here.
plan_tasks
What to do with each local task.
refused_for_good
A refusal after which no vault task exists and none will: the screen or the request check refused it, or Cloud answered with a 4xx. A lost connection, a 5xx or an unreadable answer may hide a created task.
task_proposal
The vault proposal for local task local of the project stable.
unsettled
The unsettled tasks among tasks.
unsettled_local
The unsettled local tasks of root.
unsettled_message
Why a link that brings local work is refused while list is unsettled.