Skip to main content

SetupState

Struct SetupState 

Source
pub struct SetupState {
Show 15 fields pub schema_version: u32, pub steps: BTreeMap<SetupStep, StepEntry>, pub constitution_choice: ConstitutionChoice, pub constitution_checkpoint_completed_for: Option<String>, pub constitution_language: Option<String>, pub constitution_source: ConstitutionSource, pub constitution_validity: ConstitutionValidity, pub constitution_authoring: Option<ConstitutionAuthoring>, pub constitution_preview_hash: Option<String>, pub constitution_preview_version: u32, pub runtime_posture_source: RuntimePostureSource, pub operate_receipts_verified: bool, pub inherited: bool, pub telemetry_notice_decided_for: Option<String>, pub telemetry_opt_in: bool,
}
Expand description

The persisted, per-version setup-state record.

Fields§

§schema_version: u32§steps: BTreeMap<SetupStep, StepEntry>

Per-step status entries.

§constitution_choice: ConstitutionChoice

The user’s constitution decision.

§constitution_checkpoint_completed_for: Option<String>

Lane version (e.g. "0.8.67") whose constitution checkpoint the user has completed. Drives the once-per-version update checkpoint (#3794).

§constitution_language: Option<String>

Language the constitution prose was authored/reviewed in.

§constitution_source: ConstitutionSource

Which surface is the active user-global law.

§constitution_validity: ConstitutionValidity

Validity of the active user-global constitution file.

§constitution_authoring: Option<ConstitutionAuthoring>

How the active custom constitution was authored (guided deterministic vs model-drafted-then-ratified). None for bundled/deferred/inherited.

§constitution_preview_hash: Option<String>

Stable content hash of the most recently previewed/accepted rendered constitution (see crate::user_constitution::UserConstitution::preview_hash).

§constitution_preview_version: u32

Monotonic counter bumped each time a custom constitution is saved, so the report and /constitution can show which revision is live.

§runtime_posture_source: RuntimePostureSource

Where the current runtime posture came from.

§operate_receipts_verified: bool

Host-enforced Workflow dispatch and terminal receipts have been proven for this installation. Older records did not carry this proof and must deserialize false even if their Operate/Fleet card was marked Verified.

§inherited: bool

True when this record was derived from existing config rather than persisted by an explicit setup run. Lets /setup and doctor explain why an updating user is not treated as a broken fresh install.

§telemetry_notice_decided_for: Option<String>

TELEMETRY_NOTICE_VERSION whose telemetry notice the user has answered. None means the notice is still owed.

Never auto-completed and never deferred-completed: unlike the constitution checkpoint, which records a Deferred completion on the skip-onboarding path, a telemetry notice that was not rendered and answered leaves this None. Silence is not consent, so the failure mode of a missing notice is that nothing is ever collected.

These are fields rather than a new SetupStep variant on purpose: an unknown enum variant fails the whole record parse and silently drops the user back to derived-inherited state — including their constitution checkpoint — while unknown fields are ignored.

§telemetry_opt_in: bool

The user’s answer to the notice. Only meaningful when Self::telemetry_notice_decided_for matches the current TELEMETRY_NOTICE_VERSION.

Implementations§

Source§

impl SetupState

Source

pub fn status(&self, step: SetupStep) -> StepStatus

Status for a step, defaulting to StepStatus::NotStarted.

Source

pub fn set_step(&mut self, step: SetupStep, entry: StepEntry) -> &mut Self

Record (insert or replace) an entry for step.

Source

pub fn first_run_ready(&self) -> bool

First-run “ready”: language verified, provider/model ready-or-needs-action, runtime posture inherited/confirmed, and an explicit constitution choice.

Source

pub fn operate_ready(&self) -> bool

Operate/Fleet “ready”: provider credentials are verified, runtime posture has been reviewed, and the user has explicitly reviewed the Fleet/Operate on-ramp. This is intentionally separate from first_run_ready: a local-first user can be ready for ordinary first use before enabling durable multi-worker work.

Source

pub fn update_ready(&self, version: &str) -> bool

Update “ready” for version: the constitution checkpoint for that lane is complete. Everything else is inherited from existing config.

Source

pub fn needs_constitution_checkpoint(&self, version: &str) -> bool

Whether the once-per-version update checkpoint should still be shown.

Source

pub fn complete_constitution_checkpoint( &mut self, version: impl Into<String>, choice: ConstitutionChoice, ) -> &mut Self

Mark the constitution checkpoint complete for version (the bundled / default path is a valid completion).

Source

pub fn needs_telemetry_notice(&self, version: &str) -> bool

True when the telemetry notice for version has not been answered.

A decision recorded against a different notice version does not count: the content changed, so the answer is stale and is owed again.

Source

pub fn record_telemetry_notice( &mut self, version: impl Into<String>, opt_in: bool, ) -> &mut Self

Record the user’s answer to the telemetry notice for version.

Call this only from a path where the notice was actually rendered and the user actually answered. Deferral, skip-onboarding, and any non-interactive surface must leave the record untouched.

Source

pub fn telemetry_accepted(&self, version: &str) -> bool

True when the user was asked the current notice and said yes.

This is one half of the emit condition; the other is telemetry = true in config. Neither alone suffices, which is what makes a stale pre-existing telemetry = true — settable and inert for a long time — not consent.

Source

pub fn telemetry_declined(&self, version: &str) -> bool

True when the user was asked the current notice and said no.

Distinct from “never asked”: only a recorded decline is an answer, and only an answer may be acted on destructively.

Source

pub fn derive_inherited(facts: &InheritedConfigFacts) -> Self

Derive a safe inherited state for an existing user with no persisted setup_state.json. Surfaces they already configured become StepStatus::Verified; an update never looks like a fresh, broken setup. The constitution checkpoint is intentionally left incomplete so updating users still see it once.

Source

pub fn path() -> Result<PathBuf>

Path to the setup-state sidecar under $CODEWHALE_HOME.

Source

pub fn load() -> Result<Option<Self>>

Load the persisted setup-state from the home sidecar.

Returns Ok(None) when the file is missing or unreadable/corrupt, so callers fall back to derive_inherited rather than forcing a fresh wizard. A corrupt record is logged, never fatal.

Source

pub fn load_from(path: &Path) -> Option<Self>

Load from an explicit path (testable). See load for the missing/corrupt fallback contract.

Source

pub fn save(&self) -> Result<()>

Atomically persist this record to the home sidecar.

Source

pub fn save_to(&self, path: &Path) -> Result<()>

Atomically persist to an explicit path (testable).

Trait Implementations§

Source§

impl Clone for SetupState

Source§

fn clone(&self) -> SetupState

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 SetupState

Source§

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

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

impl Default for SetupState

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for SetupState

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 SetupState

Source§

impl PartialEq for SetupState

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for SetupState

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for SetupState

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
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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

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

Checks if this value is equivalent to the given key. Read more
Source§

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

Source§

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.

Source§

impl<T> Instrument for T

Source§

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

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

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.

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.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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