Skip to main content

memstead_base/ingest/
mod.rs

1//! The deterministic ingest-orchestration surface.
2//!
3//! Ingest today has two implementations that have drifted apart: a full
4//! orchestration (selection, backoff, change-detection, brief assembly,
5//! process-state lifecycle) living in the Claude-Code plugin's Node.js, and
6//! a hard-coded natural-language charge in the macOS app that uses none of
7//! it. This module is the engine-side home the deterministic half is being
8//! ported into, so that the plugin skill and the macOS app both reduce to
9//! thin clients pulling the *same* rendered run-brief from the engine —
10//! honouring "every engine-reachable operation is reachable over UniFFI
11//! *and* CLI" and "the engine owns mem-repo state".
12//!
13//! The boundary is load-bearing: **deterministic → engine** (selection,
14//! backoff, change-detection, brief assembly, cursor/process-state);
15//! **LLM-inherent → agent** (reading sources, mutating the graph). The
16//! engine renders the brief and advances deterministic state — it never
17//! hosts the agent.
18//!
19//! The deterministic half is ported and wired: the structural [`resolve`]
20//! layer (joins an ingest config to its projection, facets, and mediums), the
21//! [`change_detection`] primitives, the [`cursor`] driver that assembles a
22//! per-source changed slice across the git / graph / mtime strategies, and
23//! [`brief`] assembly — all reachable through `memstead ingest brief` (CLI)
24//! and the UniFFI surface, which the plugin skill and macOS app consume as
25//! thin clients.
26
27pub mod advance;
28pub mod brief;
29pub mod change_detection;
30pub mod cursor;
31pub mod findings;
32pub mod guidance;
33pub mod prune;
34pub mod refinement;
35pub mod render;
36pub mod report;
37pub mod resolve;
38pub mod selection;
39pub mod slice;
40pub mod status;
41
42pub use crate::pipeline::Source;
43pub use advance::{
44    AdvanceError, AdvanceOutcome, AdvanceState, DispositionInput, EXCLUDED_VERDICT, ExcludeError,
45    ExcludeOutcome, advance_baseline, advance_store_path, delete_advance_store, read_advance_store,
46    record_exclusions, write_advance_store,
47};
48pub use brief::{
49    NoSignalNote, PROCESS_MEM_SCHEMA, ProcessMemInfo, SourceCursor, SyncCommand,
50    assemble_discovery_brief, assemble_one_shot_brief, render_changed_slice, render_goal_and_avoid,
51    render_intent, render_one_shot_lens, render_operative_data, render_situation,
52    render_sync_brief, render_verify_brief,
53};
54pub use change_detection::{
55    Digest, StatDiff, StatEntry, StatMap, compute_stat_map, diff_stat_maps, digest_stat_map,
56    digests_equal, parse_digest_token, serialize_digest_token,
57};
58pub use cursor::{
59    compute_source_cursor, enumerate_facet_files, source_moved, source_moved_since,
60    write_active_deny_file,
61};
62pub use findings::{
63    FacetEnumerability, Finding, FindingClass, FindingKey, FindingTarget, FindingsBatch,
64    FindingsError, FindingsStore, FullResyncDecision, FullResyncRefusal, VerifyOutcome,
65    adjudicate_anchor, current_findings, delete_findings_store, findings_store_path,
66    read_findings_store, record_anchor_hash_backfill, record_verified_baseline,
67    schedule_full_resync, verify_binding, write_findings_store,
68};
69pub use guidance::{
70    GuidanceDefaults, MemGuidance, ResolvedGuidance, merge_guidance_block, resolve_writing_guidance,
71};
72pub use prune::{
73    PruneDisposition, PruneMerge, PruneMode, PruneProposal, classify_prune_candidate,
74    prune_proposals,
75};
76pub use refinement::{
77    Batch, ROTATION_ANCHOR_ADJUDICATION, ROTATION_UNCOVERED_FILES, bump_verify_runs, next_batch,
78    next_rotation_batch,
79};
80pub use render::{
81    RenderBriefError, mode_name, render_ingest_brief, render_sync_brief_for,
82    render_verify_brief_for,
83};
84pub use report::{
85    ALLOWED_REPORT_INCLUDE_KEYS, AnchorComposition, DEFAULT_REPORT_BUDGET, DenominatorBasis,
86    FacetCapability, FacetFreshness, FidelityReport, GrainCoverage, RenderedFidelityReport,
87    TreeFanout, compute_fidelity_report, render_fidelity_report,
88};
89pub use resolve::{
90    ChangeStrategy, ResolveError, ResolvedIngest, ResolvedSource, find_git_root,
91    resolve_binding_run, resolve_change_strategy,
92};
93pub use selection::{
94    BackoffEntry, MAX_SKIP_LEVEL, OperationFilter, OperationKind, apply_backoff, select_next_due,
95    select_next_due_operation, should_skip,
96};
97pub use slice::{
98    Slice, SliceOutcome, graph_changes_to_slice, graph_slice_outcome, is_git_token,
99    mtime_slice_outcome,
100};