Skip to main content

SessionPolicy

Struct SessionPolicy 

Source
pub struct SessionPolicy {
    pub freshness: FreshnessPolicy,
    pub ensure_server_on_start: bool,
    pub knowledge_on_end: bool,
    pub knowledge_on_compact: bool,
    pub brief_interval_minutes: Option<u64>,
    pub edits_require_claim: bool,
    pub stranded_after: Option<String>,
}
Expand description

session: — what the episode boundary does beyond drawing itself.

Only the half two entry paths both read is typed here. The rest of the block is carried through unread, as every other key is: the policy schema owns the full shape.

use majordomus_cli::policy::SessionPolicy;
// A policy that says nothing about it still converges. The default is what this
// repository's policy and the skeleton a new one is written from both declare, and a
// policy that could not be read must not silently change behaviour.
assert!(SessionPolicy::default().ensure_server_on_start);
assert!(SessionPolicy::default().knowledge_on_end);
assert!(SessionPolicy::default().knowledge_on_compact);
// and a repository that has turned one off is read as having turned it off
let off: SessionPolicy =
    serde_json::from_str(r#"{"ensure_server_on_start": false, "knowledge_on_end": false}"#)
        .expect("a session block");
assert!(!off.ensure_server_on_start);
assert!(!off.knowledge_on_end);
assert!(off.knowledge_on_compact, "the two switches are independent");

Fields§

§freshness: FreshnessPolicy

session.freshness: — how old a continuation record may be before it stops being current. A separate question from divergence, which is about git topology and says nothing about age.

§ensure_server_on_start: bool

Whether entering the repository converges on a ready shared server.

One switch, both entry paths: the provider’s start event (ADR 0035) and the file a shell evaluates on entry (ADR 0043). It defaults to true because that is what this repository’s policy and the skeleton a new one is written from both declare, and because a policy that could not be read must not silently change behaviour — an unreadable policy is doctor’s finding, not a reason to stop converging.

§knowledge_on_end: bool

Whether closing an episode derives the knowledge it produced into candidate records under the tracked knowledge section (ADR 0091). Read here so that knowledge_base.status judges a silent writer only where the writer is switched on, and defaults to true for the reason ensure_server_on_start does: the policy and the skeleton both declare it, and an unreadable policy must not change behaviour.

§knowledge_on_compact: bool

Whether a provider’s compaction event derives the same records. Independent of checkpoint_on_compact: the two record different things.

§brief_interval_minutes: Option<u64>

session.brief_interval_minutes: — how often a session reports on itself without being asked (ADR 0136). Absent is the default brief.session carries; the provider mod reads the interval from that answer rather than from this file.

§edits_require_claim: bool

session.edits_require_claim: — whether a provider’s tool may write a file of the checkout only while a claim covers it: the active task’s scope, or a live mesh claim of the writing session (I2735, crate::guard). Off unless a repository turns it on, because it refuses edits, and a repository that never asked for that must not find its workers stopped by an upgrade.

§stranded_after: Option<String>

session.stranded_after: — how long an open episode may be silent before its client is taken to be gone (90s, 30m, 12h). majordomus recover reads it to judge an episode stranded, and worktree.uncommitted reads the same value twice over: an episode silent this long holds no work, and uncommitted work untouched this long that nothing holds is abandoned. Absent is absent: no reader carries a default of its own, because a second copy of the number is the drift the policy exists to stop.

use majordomus_cli::policy::SessionPolicy;
let declared: SessionPolicy =
    serde_json::from_str(r#"{"stranded_after": "12h"}"#).expect("a session block");
assert_eq!(declared.stranded_after.as_deref(), Some("12h"));
assert_eq!(SessionPolicy::default().stranded_after, None, "absent is not a default");
// a bare number is seconds, as the shell reader takes it, and never a parse failure
// that would take the rest of the policy down with it
let bare: SessionPolicy =
    serde_json::from_str(r#"{"stranded_after": 3600}"#).expect("a session block");
assert_eq!(bare.stranded_after.as_deref(), Some("3600"));

Trait Implementations§

Source§

impl Clone for SessionPolicy

Source§

fn clone(&self) -> SessionPolicy

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SessionPolicy

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SessionPolicy

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for SessionPolicy

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for SessionPolicy

Source§

impl PartialEq for SessionPolicy

Source§

fn eq(&self, other: &SessionPolicy) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for SessionPolicy

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more