Expand description
Persistence records for app/domain operational rules.
This module documents the storage/public projection gate for the
pet-resort AI program: portfolio seed facts, service-line offerings, core
service rules, manager daily-brief labor outcomes, data-quality hygiene
outcomes, and source-system ecosystem records. Storage code is allowed to
speak in stable record codes, flattened optional fields, and JSON payloads,
but promotion back into domain values is explicit and source-grounded.
The gate is deliberately narrow:
domainowns business meaning and invariants such as daycare eligibility, grooming cadence, training duration, source evidence, and review gates.storageowns durable representations, discriminator checks, codec errors, and idempotent evidence records suitable for Postgres or fixtures.appand runtime crates decide when a workflow may read or write records; storage records never authorize live provider writes or customer messaging.integrationadapters attachStoredSourceRecordRefvalues so a derived record can be audited back to Gingr, a warehouse export, or another source instead of becoming an invented operational fact.
Crosswalk navigation: this module backs the storage/persistence rows for
outcome records, source refs, service offerings, portfolio records, and
reporting groups. Use
docs/entity-atlas/contract-crosswalk/storage-persistence.md from entity
pages, workflow-packets.md from workflow pages, and the storage/API tests
named there as the executable proof.
use storage::operations::{
ServiceOfferingKindCode, ServiceOfferingRecord, StoredSourceRecordRef,
};
let source_ref = StoredSourceRecordRef {
system: "gingr".to_owned(),
record_type: "reservation_type".to_owned(),
record_id: "reservation-type-42".to_owned(),
observed_at: "2026-06-18T14:00:00Z".to_owned(),
adapter_version: "gingr-fixture-v1".to_owned(),
};
let promoted_service = domain::operations::ServiceOffering::Daycare {
format: domain::operations::DaycareFormat::AllDayPlay,
eligibility_rules: vec![
domain::operations::DaycareEligibilityRule::TemperamentReviewRequired,
domain::operations::DaycareEligibilityRule::StaffToPetRatioRequired,
],
};
let stored = ServiceOfferingRecord::try_from(promoted_service.clone())?;
assert_eq!(stored.service_kind, ServiceOfferingKindCode::Daycare);
assert_eq!(source_ref.record_id, "reservation-type-42");
let encoded = stored.encode_json()?;
let decoded = ServiceOfferingRecord::decode_json(&encoded)?;
let demoted: domain::operations::ServiceOffering = decoded.try_into()?;
assert_eq!(demoted, promoted_service);Re-exports§
pub use crate::service_line::grooming::StoredCadenceWeeksError;pub use crate::service_line::training::StoredProgramDurationWeeks as StoredTrainingProgramDurationWeeks;pub use crate::service_line::training::StoredProgramDurationWeeksError as StoredTrainingProgramDurationWeeksError;
Structs§
- Core
Service Contracts Record - Storage snapshot of the service-line rules enabled for a location.
- Data
Quality Hygiene Outcome Record - Stored evidence for a data-quality hygiene action, including labor deltas, issue references, and resolution state.
- Data
Quality Hygiene Outcome Record Builder - Use builder syntax to set the inputs and finish with
build(). - Data
Quality Hygiene Reporting Group - Dimensions used to group data-quality hygiene outcomes by location, day, issue type, and owner role.
- Manager
Daily Brief Outcome Record - Stored evidence for a manager daily-brief action, including before/after labor minutes and source references.
- Manager
Daily Brief Outcome Record Builder - Use builder syntax to set the inputs and finish with
build(). - Manager
Daily Brief Reporting Group - Dimensions used to aggregate manager daily-brief labor outcomes by location, day, action, and owner role.
- PetResort
Portfolio Record - Storage shape for the pet-resort portfolio facts used to seed operating assumptions.
- PetResort
Portfolio Record Builder - Use builder syntax to set the inputs and finish with
build(). - Service
Offering Record - Flattened storage shape for one service-line offering; only fields valid for its
service_kindmay be populated. - Service
Offering Record Builder - Use builder syntax to set the inputs and finish with
build(). - Stored
Brand Name - Non-empty pet-resort brand display name persisted beside the stable brand code.
- Stored
Data Quality Hygiene Labor Minutes - Non-zero minute quantity persisted for data-quality hygiene labor evidence.
- Stored
Manager Daily Brief Labor Minutes - Non-zero minute quantity persisted for manager daily-brief labor evidence.
- Stored
Resort Count - Positive resort count persisted for portfolio seed facts.
- Stored
Source Record Ref - Provider provenance attached to stored evidence so facts can be audited back to Gingr or another source system.
- Stored
Source Record RefBuilder - Use builder syntax to set the inputs and finish with
build(). - Technology
Ecosystem Record - Stored view of the systems that produce operational data and adjacent labor signals.
- Technology
Ecosystem Record Builder - Use builder syntax to set the inputs and finish with
build().
Enums§
- Adjacent
System Code - Stable codes for adjacent systems that provide labor, recruiting, marketing, or analytics evidence.
- Business
Line Code - Stable business-line codes for NVA portfolio membership.
- Codec
Error - JSON codec failures at the storage gate.
- Core
Operating System Code - Stable codes for operational source systems that may feed NVA workflows.
- Data
Access Pattern Code - Stable codes for how operational facts are accessed from source systems.
- Data
Quality Hygiene Action Kind Code - Persisted data-quality actions used to quarantine, repair, or reconcile source evidence.
- Data
Quality Hygiene Outcome Code - Persisted outcome states for data-quality hygiene actions.
- Data
Quality Hygiene Persona Code - Persisted personas accountable for data-quality hygiene work.
- Data
Quality Resolution Status Code - Persisted lifecycle status for a data-quality issue after review.
- Error
- Errors raised while validating storage records, codecs, or domain-to-storage projection.
- Manager
Daily Brief Action Kind Code - Persisted manager daily-brief actions that can produce labor-minute evidence.
- Manager
Daily Brief Outcome Code - Persisted outcome states for manager daily-brief actions.
- Manager
Daily Brief Persona Code - Persisted staff personas accountable for manager daily-brief work.
- Operator
Code - Stable operator code used in portfolio seed records.
- PetResort
Brand Code - Stable brand codes for NVA pet-resort banners.
- PetResort
Brand Record - Stored pet-resort brand descriptor with code plus display name.
- Portfolio
Structure Code - Stable portfolio-structure codes for pet-resort operating assumptions.
- Record
Kind - Storage record families used in shape-validation diagnostics.
- Service
Offering Kind Code - Discriminator for the service-line variant represented by a flattened offering record.
- Shape
Mismatch Reason - Reasons a flattened record cannot represent the requested domain variant.
- Storage
Field - Persisted fields that can reject invalid domain values during storage conversion.
- Stored
Resort Count Error - Validation failures for persisted resort-count quantities.
Type Aliases§
- Result
- Result type returned by fallible storage projection and codec operations.