Skip to main content

Module capture

Module capture 

Source
Expand description

Capture quality gate (Cloud v4 V1, SPEC-ENGINE §3.1).

Every item that leaves the machine for a vault is one typed claim: a single complete sentence of 24–300 characters, a node type, at least one valid reference, an evidence level, deduplicated against what the place holds, admitted and screened. The gate is rule-based: it rejects with a stable ReasonCode, it never rewrites or splits (E1). A fact that fails stays in the local knowledge store unchanged.

Modules§

conflicts
Concurrent edits of one shared fact across Instances (#286).
dedupe
Dedupe of the capture gate (SPEC-ENGINE §3.1.5): an exact key over the normalised statement and a MinHash near-duplicate check, both keyed with the place id key pk_id, so two engines of a place reach the same verdict and nobody without the key can confirm a guessed statement.
derived
Provenance of captured claims (Cloud v5 CHECKLIST 2.2.2, 2.6.1): a claim that names a vault node itself (node:<id> reference) builds on it, and its node.add is followed by a derived_from edge to that node. The edge is ordinary vault content: signed, queued with the claim (offline too) and pushed by the next sync.
emit
Capture step 6 (SPEC-ENGINE §3.1.2): what the gate let through becomes signed node.add events in the place’s replica — queued as pending (the offline queue the sync driver pushes), with the keyed dedupe key, the encrypted MinHash signature and an own_sources row, so a later run never sends the same claim twice and a purge can find the local text.
episode
Episodes (SPEC-ENGINE §3.2.3): one node per ended session, built from its record — the goal (last task), the outcome (final progress or an explicit keyword), dead ends (ctx_session finding tag=dead_end and revert commits of the session window), the files it changed and the commits it made. An episode that fails the episode rules (§3.1.4) is not captured (episode_shape, or no_reference without files and commits); nothing of it leaves the machine then.
lifecycle
The lifecycle of captured knowledge after its node.add: what an agent does to a fact later reaches the vault, so other engines never keep receiving knowledge its author has withdrawn.
refs
Reference grammar of the capture gate (SPEC-ENGINE §3.1.3, rule G10): file:, sym:, test:, commit:, node: and https://, each checked against the checkout bound to the vault. An invalid reference counts as absent; a commit that is on no remote-tracking branch yet is pending.
rules
Text rules of the capture gate (SPEC-ENGINE §3.1.4, G2–G9): one complete, single-line claim of 24–300 characters that is not log output, not truncated and not a list. Rules reject; they never rewrite.
sharing
Whether a fact just remembered goes to the team, decided when it is remembered (3.12.3): ctx_knowledge remember and lean-ctx knowledge remember say "local only: <reason>" with how to fix it, instead of a plain OK that the capture gate later turns into a silent rejection.

Structs§

CaptureCandidate
A local fact shaped for the gate.
CaptureCounts
Counts of capture runs (SPEC-ENGINE §3.1.2 step 7): never any text.
CaptureRun
One capture run for one place: the gate’s inputs and what it counted.
CapturedFact
A fact the gate let through, with its valid references and where it came from in the local store (for own_sources, never shared).
Pending
A candidate waiting for its commit to reach a remote-tracking branch.

Enums§

ReasonCode
Why the gate refused a candidate. Stable snake_case strings: counted, shown in cloud status, reported to the place as counts only.

Constants§

GATE_VERSION
Version of the gate rules, carried with every count and event.
MAX_REFERENCES
References a claim may carry (G10).
PENDING_DAYS
A candidate whose only reference is an unpublished commit waits this long before it is rejected finally (G10).

Functions§

evidence_of
Evidence level of a fact: explicit; imported for imports and provider or derived origins; observed for a local fact with an anchor; else stated.
fact_key_hash
hex(blake3_keyed(pk_id, category || 0x00 || key)): names a local fact in the pending file without its slug.
finish_run
Keep what a run found: its counts and the candidates still pending.
gate
The rules G2–G11 on a shaped candidate. Returns the valid references.
load_counts
load_pending
local_pk_id
The place id key of a vault until the replica delivers the server’s id_salt (SPEC-ENGINE §3.1.5).
node_type_of
Node type of a fact (SPEC-ENGINE §3.1.3), Err(NoType) for a category in the deny map.
open_run
Open a capture run for the project stable at root: the vault it is bound to (or the project itself before it is), its pending candidates. Returns the run and the place name its counts are kept under.
record_counts
Add one run’s counts to the vault’s unsent counts.
save_pending
shape
Shape a fact into a candidate (G1). import_ref is the reference its import source names (file:<path> or commit:<sha>).

Type Aliases§

CountsFile
Unsent counts per vault, <data>/cloud/capture/counts.json.