Skip to main content

Crate printobserver_core

Crate printobserver_core 

Source
Expand description

printobserver-core.

Owns: the supervision logic — the loop that turns printer state and vision observations into supervisory decisions, and the policy that decides which decisions are allowed to reach the printer — together with the event kinds and source names that logic writes (kinds), the one aggregate a caller and the agent both read, the print’s context (context), and the persistence interfaces it needs, one per aggregate (store).

May depend on: printobserver-types and the three port crates (printobserver-printer-api, printobserver-vision-api, printobserver-supervisor-api), and NO implementation crate. This is the rule the whole design rests on and just check-repo enforces it. The persistence interfaces this crate needs are its own (store), one trait per aggregate it persists, and the store implementation depends on this crate to implement them.

§The policy, which is the reason this layer exists

A failure detector can already see a failure and a printer can already drive the machine. What does not exist without this crate is the thing in between that decides what an agent is allowed to do about it, and its whole value is in being thin, bounded, and the single place that decision is made — so that an operator’s own commands are bounded by exactly the same rules an agent’s are.

  • Effective bounds are the configured safety envelope intersected with the active print’s manifest. A manifest may only narrow; a range wider than the envelope’s is narrowed to the envelope’s and the narrowing is recorded on the print. See bounds.
  • Every action from every actor passes one decision, taken by decision::decide and issued by the one function named in supervisor. There is no path by which an action reaches the printer without it, and that is structural: no other item of this crate names an action method of the printer port, and no item outside that one module can obtain the handle to call one on.
  • A request outside the bounds is rejected, not clamped, and the rejection is persisted with the value asked for and the range allowed, so the caller can ask again inside the range.
  • A bounded intervention expires on its own. Core reads the current time through an injected Clock rather than the system’s, so expiry is driven by time passing and by nothing else. See expiry.
  • Nothing in this crate, and nothing reachable from it, sends a command string to a printer. The printer port declares no method that admits one: no method admits a byte sequence at all, and the only string anywhere in the closure its parameters reach is the one FileName wraps.

Re-exports§

pub use accounting::ChargeRule;
pub use accounting::UNTRACKED_REASON;
pub use accounting::charge_rule;
pub use actions::ActionOutcome;
pub use actions::reported_value;
pub use block_on::block_on;
pub use bounds::Bounds;
pub use bounds::effective_bounds;
pub use check_image::CheckImageRequest;
pub use check_image::CheckImages;
pub use check_image::ImageUse;
pub use check_image::PlanPosition;
pub use check_image::ShownImage;
pub use clock::Clock;
pub use clock::SystemClock;
pub use clock::plus_seconds;
pub use clock::seconds_between;
pub use clock::unix_seconds;
pub use config::CoreConfig;
pub use config::DEFAULT_DETECTOR_RESUME_GRACE;
pub use config::DEFAULT_EXPIRY_POLL;
pub use config::DEFAULT_OBSERVATION_INTERVAL;
pub use config::DEFAULT_RECENT_EVENTS;
pub use config::DEFAULT_SHEETS;
pub use config::MAX_LOOK_WAIT_S;
pub use config::PRINT_ID_PLACEHOLDER;
pub use config::PreflightMode;
pub use config::SheetTable;
pub use config::SpoolPolicy;
pub use context::AgentContext;
pub use context::AgentEvent;
pub use context::AgentHeater;
pub use context::AgentPrint;
pub use context::AgentPrinter;
pub use context::PrintContext;
pub use context::Since;
pub use context::newer_than;
pub use decision::DecisionInput;
pub use decision::adjustment;
pub use decision::changes_the_machine;
pub use decision::decide;
pub use decision::valid_from;
pub use error::CoreError;
pub use events::PendingTurn;
pub use events::Received;
pub use events::TERMINAL_STATES;
pub use expiry::rejection_detail;
pub use expiry::restoring_action;
pub use filament::DEFAULT_DIAMETER_MM;
pub use filament::MATERIAL_DENSITIES;
pub use filament::MarkClearing;
pub use filament::buffer_g;
pub use filament::density_for;
pub use filament::grams_for_length;
pub use filament::marks_cleared_by;
pub use gcode_index::BedArea;
pub use gcode_index::GcodeIndex;
pub use gcode_index::IndexBuilder;
pub use gcode_index::PlanFact;
pub use gcode_index::PlanMismatch;
pub use gcode_index::Rise;
pub use gcode_index::SetValue;
pub use gcode_index::SlicerPlan;
pub use inbox::Arrival;
pub use inbox::Inboxes;
pub use kinds::ActionExecutedPayload;
pub use kinds::ActionRejectedPayload;
pub use kinds::ActionRequestedPayload;
pub use kinds::AgentAssessmentPayload;
pub use kinds::AgentStopUnactedPayload;
pub use kinds::BedClearActor;
pub use kinds::BedClearAssertedPayload;
pub use kinds::CameraDegradedPayload;
pub use kinds::CameraLookPayload;
pub use kinds::CameraRetryPayload;
pub use kinds::ChargePendedPayload;
pub use kinds::DetectorHealthChangedPayload;
pub use kinds::DetectorStatus;
pub use kinds::FilamentChangeSignalledPayload;
pub use kinds::FilamentConsumedPayload;
pub use kinds::FileTallyRebaselinedPayload;
pub use kinds::FrameCause;
pub use kinds::GcodeIndexedPayload;
pub use kinds::HeatedTool;
pub use kinds::InterventionExpiredPayload;
pub use kinds::OperatorAcknowledgementPayload;
pub use kinds::PeriodicObservationPayload;
pub use kinds::PortFailurePayload;
pub use kinds::PortFailureSite;
pub use kinds::PositionFreshness;
pub use kinds::PreflightCheckedPayload;
pub use kinds::PrintEndedPayload;
pub use kinds::PrintStartedPayload;
pub use kinds::PrintUntrackedPayload;
pub use kinds::PrinterConnectionChangedPayload;
pub use kinds::PrinterResetPayload;
pub use kinds::RebaselineDisposition;
pub use kinds::RecoveryExecutedPayload;
pub use kinds::RecoveryRejectedPayload;
pub use kinds::RecoveryRequestedPayload;
pub use kinds::SignalPosition;
pub use kinds::SpoolAdjustedPayload;
pub use kinds::SpoolCommandRejectedPayload;
pub use kinds::SpoolLoadedPayload;
pub use kinds::SpoolRegisteredPayload;
pub use kinds::SpoolRetiredPayload;
pub use kinds::SpoolUnloadedPayload;
pub use kinds::SpoolUnverifiedPayload;
pub use kinds::TIMELINE_KINDS;
pub use kinds::UnaccountedPrintPayload;
pub use kinds::UnattendedPrinterActivityPayload;
pub use kinds::agent_source;
pub use kinds::operator_source;
pub use kinds::system_source;
pub use look::CameraRetry;
pub use look::DEFAULT_CAMERA_RETRIES;
pub use look::DEFAULT_CAMERA_RETRY_BACKOFF;
pub use look::Look;
pub use observation::Observed;
pub use preflight::ANALYSIS_POLL;
pub use records::AcknowledgementDisposition;
pub use records::ActionId;
pub use records::ActionKind;
pub use records::ActionRecord;
pub use records::ActionRequest;
pub use records::Actor;
pub use records::ActorClass;
pub use records::ChargeKey;
pub use records::ChargeMethod;
pub use records::ChargedFilament;
pub use records::ClearedMark;
pub use records::DoubtedSpool;
pub use records::EffectiveBounds;
pub use records::ExecutionOutcome;
pub use records::FilePosition;
pub use records::ImageRecord;
pub use records::Intervention;
pub use records::InterventionId;
pub use records::InterventionOutcome;
pub use records::JobManifest;
pub use records::LoadedSpool;
pub use records::ManifestNarrowing;
pub use records::MaterialComparison;
pub use records::MaterialName;
pub use records::MaterialObjection;
pub use records::MaterialResult;
pub use records::PendingCharge;
pub use records::PendingTaken;
pub use records::PolicyDecision;
pub use records::Preflight;
pub use records::PreflightNeed;
pub use records::PreflightObjection;
pub use records::PreflightSpool;
pub use records::PreflightTool;
pub use records::PreflightToolResult;
pub use records::PreflightVerdict;
pub use records::PrintAction;
pub use records::PrintOutcome;
pub use records::PrintRecord;
pub use records::PrintSegmentKey;
pub use records::RejectionReason;
pub use records::SafetyEnvelope;
pub use records::SheetComparison;
pub use records::SheetId;
pub use records::SheetObjection;
pub use records::SheetResult;
pub use records::ShortSpool;
pub use records::SpoolCommand;
pub use records::SpoolField;
pub use records::SpoolId;
pub use records::SpoolLifecycle;
pub use records::SpoolRecord;
pub use records::SpoolRefusalCause;
pub use records::SpoolTrust;
pub use records::UnanalysedSpool;
pub use records::UncomparedMaterial;
pub use records::UnverifiedMark;
pub use records::UnverifiedMarks;
pub use records::UnverifiedReason;
pub use records::UnverifiedReasonKind;
pub use records::ActionAllowance;
pub use records::AwayFromBed;
pub use records::BedTemperature;
pub use records::DEFAULT_CLEARANCE_MARGIN_MM;
pub use records::DEFAULT_MAX_LIFT_MM;
pub use records::LastPrint;
pub use records::PausedPrint;
pub use records::RecoveryAction;
pub use records::RecoveryActionKind;
pub use records::RecoveryConfig;
pub use records::RecoveryDecision;
pub use records::RecoveryField;
pub use records::RecoveryGrants;
pub use records::RecoveryPosition;
pub use records::RecoveryRejection;
pub use records::RecoveryStatus;
pub use records::RecoveryTemperatures;
pub use records::ToolTemperature;
pub use records::ZHome;
pub use records::ZTrust;
pub use scoring::EVIDENCE_INTERVALS;
pub use scoring::ScoringProbe;
pub use scoring::ScoringRead;
pub use scoring::ScoringReading;
pub use spools::SpoolCommandOutcome;
pub use store::ActionStore;
pub use store::AuditPage;
pub use store::Charge;
pub use store::ChargeIdentity;
pub use store::ChargeRecord;
pub use store::DEFAULT_HISTORY_WINDOW;
pub use store::EventDraft;
pub use store::EventStore;
pub use store::FilamentStore;
pub use store::FileTally;
pub use store::HistoryQuery;
pub use store::ImageDraft;
pub use store::ImageLookup;
pub use store::ImageStore;
pub use store::MAX_HISTORY_LIMIT;
pub use store::NewSpool;
pub use store::Pend;
pub use store::PrintStore;
pub use store::SessionStore;
pub use store::SettleOutcome;
pub use store::Settlement;
pub use store::SpoolChange;
pub use store::SpoolMutation;
pub use store::SpoolWrite;
pub use store::StoreError;
pub use store::Stores;
pub use store::TimelineQuery;
pub use store::TimelineStore;
pub use store::resolve_history_limit;
pub use supervisor::Issued;
pub use supervisor::RecoveryIssued;
pub use supervisor::Supervisor;
pub use toolpath::ExtrusionKind;
pub use toolpath::LayerRef;
pub use toolpath::LayerToolpath;
pub use toolpath::ObjectOutline;
pub use toolpath::SpoolError;
pub use toolpath::ToolpathSegment;
pub use toolpath::spool_path;
pub use turn_access::OpenedTurn;
pub use turn_access::TurnAuthority;
pub use turn_lock::TurnGuard;
pub use turn_lock::TurnLocks;
pub use watch::ActiveJob;
pub use watch::DEFAULT_PRINTER_POLL;
pub use watch::DEFAULT_UNATTENDED_WINDOW;
pub use watch::DetectorHealth;
pub use watch::DetectorHealthStatus;
pub use watch::DetectorProbe;
pub use watch::HeadPosition;
pub use watch::PRINTER_WATCH_KINDS;
pub use watch::PUSH_CHANNEL_DOWN;
pub use watch::PositionProbe;
pub use watch::ScoringVerdict;
pub use watch::Watched;

Modules§

accounting
The printer timeline, and what every print takes from the spools that fed it.
actions
The one path an action takes, whoever asked for it.
block_on
A dependency-free executor, so that the expiry driver can run its own work.
bounds
The effective bounds: the configured envelope intersected with the manifest.
check_image
The image a check is shown, chosen in one place.
clock
The one time source this crate reads.
closing
Closing a print record printobserver left open, at an operator’s word.
config
What a running supervisor is configured with.
context
The one aggregate a caller and the agent both read.
decision
The one decision, as a total function over what it is given.
detector
A print the detector paused, and the resume an adjustment earns it.
error
The one error type core answers its callers with.
events
The loop: one normalized event becomes one supervised turn.
expiry
A bounded intervention expires on its own, and nothing has to ask it to.
filament
The arithmetic of filament, and the one rule for which command clears which mark on a spool.
gcode_index
What the slicer planned to print at each height, indexed once per print from the print’s own G-code.
inbox
What reaches a turn while it is running.
kinds
The event kinds and source names the supervision domain writes.
listing
Every print this system holds, and the one the printer is running now.
look
A fresh look at a print: what arrived, what the camera shows, and what the printer says, now — or at the printer, with no print named.
observation
A periodic observation of every active print, which no detector asked for.
preflight
Whether the spools loaded hold enough for a print, asked before it starts.
records
The supervision domain’s own records, and the identifiers it mints.
recovery
Moving the printer after a print fails, through the one granted path.
scoring
Whether the failure detector is scoring the active print.
spools
The spool ledger’s commands and reads, through the one granted path.
store
The persistence interfaces the supervision domain needs, one per aggregate.
supervisor
The supervisor, and the one call site every action passes through.
toolpath
The planned geometry of a print, read from its G-code by the one read the GcodeIndex makes: each object’s footprint outline, and one layer’s toolpath read back from the print’s spool.
turn_access
Where a supervision turn’s runs take their credentials from.
turn_lock
One supervision turn per print at a time.
unobserved
The prints the printer’s own tallies counted and this system never saw.
upgrade
Events written under an earlier payload shape, read into the one their kind carries now.
watch
The printer watch: what changed under a print while nobody asked.