Provider-agnostic override -> full-scan -> incremental -> bootstrap sync-strategy decision logic
| Tier | foundation |
| Role | unclassified (baselined) |
| Path | crates/foundation/refresh-policy |
| Edition | 2021 |
| Targets | foundation_refresh_policy |
| Public items | 6 across 2 modules |
| Tests | 7 |
What it is for
# foundation-refresh-policy
Provider-agnostic sync-strategy decision logic: given the current state (an explicit override, a full-scan flag, and any stored cursor), decides whether the next sync should use a caller-pinned override, a full scan, resume incrementally from a cursor, or bootstrap with a default window.
Lifted (decision logic only) from rust-gmail-manager/src/services/sync_service.rs's build_sync_query — see CHANGELOG.md for the Gate 4.5 provenance note and README.md for the full design rationale.
Scope boundary: this crate does no I/O, no provider-specific fetching, and no worker/scheduling loop. It answers one question — which SyncStrategy applies next — and nothing else. The worker loop that acts on the decision lives in operations-mail-sync (sprint 3.45 crate 10).
Capabilities
policy (other)
RefreshPolicy — the override -> full scan -> incremental -> bootstrap
| Item |
|---|
pub const DEFAULT_BOOTSTRAP_WINDOW_DAYS: i64 |
RefreshPolicy
RefreshPolicy — the override -> full scan -> incremental -> bootstrap
| Item |
|---|
pub struct RefreshPolicy |
RefreshPolicy :: fn default() -> Self |
RefreshPolicy :: fn with_bootstrap_window(bootstrap_window : chrono::Duration) -> Self |
RefreshPolicy :: fn decide(& self, override_filter : Option <& str>, full : bool, cursor : Option <& Cursor>,) -> SyncStrategy |
SyncStrategy
The decision output: which strategy the next sync should use.
| Item |
|---|
pub enum SyncStrategy |
How to use it
No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.
Module structure
foundation_refresh_policy
policystrategy
flowchart TD n_foundation_refresh_policy["foundation_refresh_policy"] n_foundation_refresh_policy --> n_policy["policy"] n_foundation_refresh_policy --> n_strategy["strategy"]
Public surface
`policy`
| Item | What it is |
|---|---|
pub const DEFAULT_BOOTSTRAP_WINDOW_DAYS: i64 | The default bootstrap window when no policy-specific override is given: 30 days, matching the source's newer_than:30d Gmail-query fallback (rust-gmail-manager/src/services/sync_service.rs). |
pub struct RefreshPolicy | A sync-strategy decision policy: given the current state (an explicit override, a full-scan flag, and any stored cursor), decides which SyncStrategy the next sync run should use |
RefreshPolicy :: fn default() -> Self | — |
RefreshPolicy :: fn with_bootstrap_window(bootstrap_window : chrono::Duration) -> Self | A policy with a caller-chosen bootstrap window instead of the 30-day default. |
RefreshPolicy :: fn decide(& self, override_filter : Option <& str>, full : bool, cursor : Option <& Cursor>,) -> SyncStrategy | Decide the next sync strategy |
`strategy`
| Item | What it is |
|---|---|
pub enum SyncStrategy | What the next sync run should do, per the override -> full scan -> incremental -> bootstrap precedence chain in crate::RefreshPolicy::decide |
Re-exports. Exported here, defined elsewhere.
| Export | Defined in |
|---|---|
SyncStrategy | strategy::SyncStrategy |
{RefreshPolicy,DEFAULT_BOOTSTRAP_WINDOW_DAYS} | policy::{RefreshPolicy,DEFAULT_BOOTSTRAP_WINDOW_DAYS} |
Boundary
Depends on no other workspace tier.
Shares tier foundation with 27 other crates: foundation-audit-log, foundation-basemodels, foundation-bounded-io, foundation-conversation-closure, foundation-crypto-sign, foundation-decisioning, foundation-encounter-vocabulary, foundation-fs-metadata, … (27 total).
_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._
Where it sits
| Tier (ontology) | foundation |
| Architectural role (taxonomy) | unclassified (baselined) |
| Location | crates/foundation/refresh-policy |
| Vocabulary in force (lexicon) | current |
Dependencies
Runtime, in this workspace.
| Crate | Tier | Optional | Only on |
|---|---|---|---|
| `foundation-mail-message` | foundation | no | always |
Runtime, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
chrono | ^0.4 | serde | no | always |
serde | ^1 | derive | no | always |
Development, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
serde_json | ^1 | — | no | always |
Build. None.
Depended on by. 2 workspace crates.
Signal flow — what reaches this crate, and what it reaches.
flowchart LR n_operations_mail_sync["operations-mail-sync"] -->|uses| SELF n_tools_mail_manager["tools-mail-manager"] -->|uses| SELF SELF["foundation-refresh-policy"] SELF -->|runtime| n_foundation_mail_message["foundation-mail-message"] classDef self fill:#1f883d,stroke:#1f883d,color:#fff; class SELF self;
Feature flags
No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.
Targets
| Kind | Name | Source |
|---|---|---|
| lib | foundation_refresh_policy | `src/lib.rs` |
Error model
No public error type was detected: no public item declares a type named *Error, and no public signature returns one.
Operational characteristics
| Property | Evidence |
|---|---|
| async public surface | none detected |
| async runtime | none detected |
| database access | none detected |
| network I/O | none detected |
| unsafe code | none detected |
| environment variables | none detected |
No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.
Configuration
No environment variable is read with a literal name anywhere in this crate. A variable whose key is computed at run time cannot be listed here, and is not claimed to be absent.
Related capabilities
2 workspace crates depend on this one: operations-mail-sync, tools-mail-manager.
Verification
| Kind | Count |
|---|---|
| Unit tests | 7 |
| Integration tests | 0 |
| Examples | 0 |
| Doctests | 0 |
Evidence by module. How often each public module is named by something executable.
| Module | Tests | Examples | Consumers |
|---|---|---|---|
policy | 2 | 0 | 3 |
strategy | 1 | 0 | 1 |
What the tests establish, by name:
bootstrap_window_is_configurable—src/policy.rsdefault_bootstrap_window_is_thirty_days—src/policy.rsfull_scan_has_no_filter_and_ignores_a_stored_cursor—src/policy.rsno_cursor_falls_back_to_bootstrap_with_default_window—src/policy.rsoverride_wins_over_everything—src/policy.rsstored_cursor_becomes_incremental—src/policy.rssync_strategy_round_trips_through_serde—src/strategy.rs
Documentation coverage
| Measure | Documented | Total |
|---|---|---|
| Public items with rustdoc | 5 | 6 |
Public modules with a //! block | 2 | 2 |
pie showData
title Public items with rustdoc
"Documented" : 5
"No rustdoc detected" : 1
Metrics
| Metric | Value |
|---|---|
| Rust source files | 3 |
| Source lines | 212 |
| Code lines | 124 |
| Public API items | 6 |
| Public modules | 2 |
| Tests | 7 |
| Examples | 0 |
| Cargo features | 0 |
| Direct runtime dependencies | 3 |
| Workspace reverse dependencies | 2 |
pie showData
title Public API by kind
"constant" : 1
"enum" : 1
"method" : 3
"struct" : 1
pie showData
title Rust source composition
"Code" : 124
"Blank or comment" : 88
Generation
Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.