Skip to main content

Crate shigoto

Crate shigoto 

Source
Expand description

shigoto (仕事) — the typed job-system primitive.

Umbrella crate. Re-exports the public surface of every sibling so consumers depend on shigoto = "0.1" and reach the full algebra via use shigoto::{Job, JobId, Scheduler, ...}; without naming every sub-crate.

Canonical spec: theory/SHIGOTO.md. Theory frame: theory/THEORY.md §IV (Motion).

Re-exports§

pub use shigoto_gate;

Structs§

AllUpstreamsTerminal
AllUpstreamsTerminal — every direct DAG predecessor has reached a terminal phase ({Succeeded, Skipped, Deadlettered}). The scheduler implicitly applies this gate to enforce DAG edge semantics; consumers don’t normally register it explicitly.
BudgetSpec
BudgetTree
Three-dimension budget envelope. Allocation checks every applicable limit (min-intersection): a job runs iff all three have slack.
Dag
Typed DAG of JobIds. Edges declare “to may not start until from reaches a terminal phase” (Succeeded | Skipped | Deadlettered). Acyclic by construction at edge-add time would require an O(V+E) check on every insert; instead, cycles are detected at toposort() / waves(), where consumers must run before scheduling anyway.
FailureRecord
GateContext
Everything a Gate needs to make its decision: the job in question, the FSM snapshot (every other job’s phase), the DAG (so gates like AllUpstreamsTerminal can ask about predecessors).
IllegalTransition
Rejected transition — (from, signal) is not a legal FSM cell. Returning Result instead of panicking lets consumers report drift (an operator action attempting an illegal transition) without crashing the scheduler.
InMemorySink
In-memory JobId → Output map. The consumer reads via drain (clears + returns) or snapshot (clones + keeps) after ticks complete. Arc<Mutex<...>> interior so the same sink can be shared between the Job (recording) and the consumer (reading).
InProcessScheduler
Default scheduler — single-process, in-memory FSM state, sequential execution within a wave.
JobId
Typed identity for a Job. Stable across cycles + scheduler restarts.
JobKindId
Typed work-class identifier. Stored as String (not &'static str) so it serializes through serde without lifetime constraints. Cheap Clone is fine for the volume we expect (≤ ~100 kinds across the whole scheduler).
NullSink
No-op sink — discards every output. Default for Jobs that don’t need their typed Output surfaced.
OperatorApproved
OperatorApproved — pass iff an external operator has flipped a pre-arranged flag. The flag itself lives in the consumer’s state store; this gate is a thin wrapper that holds an Arc<AtomicBool> or similar. v0.1 ships with a Closure variant that takes a Fn() -> bool for tests + ad-hoc cases.
Snapshot
Read-only snapshot of the scheduler’s current FSM map.
TickReceipt
Derived per-tick rollup the scheduler emits on every tick.
TransitionEvent
UnhealedDrift

Enums§

BudgetError
DagError
GateAggregate
Aggregate gate outcome — what the cohort of gates collectively said. Per §III.9 individual gates return Pass / Wait / Skip; the aggregate is the worst outcome (Skip > Wait > Pass) per a typed reducer in shigoto-gate. We carry the rolled-up result here so the FSM stays language-agnostic about how the rollup is computed.
GateOutcome
JobPhase
FSM phase a Job inhabits. See theory/SHIGOTO.md §III.3 for the transition table.
JobScope
JobSubject
RetryDecision
RetryOutcome
Retry decision from a RetryPolicy::decide() call. Same shape that shigoto-retry’s RetryDecision exposes — duplicated as a typed signal payload so the FSM stays in shigoto-types without a dependency on shigoto-retry.
RetryPolicy
SchedulerError
Signal
FSM driver — every legal way a Job’s phase can change. Exhaustive over the (JobPhase, Signal) cross-product per theory/SHIGOTO.md §IV.1; the advance table below enumerates every cell.
SkipReason
TransitionReason

Traits§

ErasedJob
Trait-object dispatch surface. The scheduler holds Box<dyn ErasedJob> (Job itself isn’t object-safe because of the associated types); ErasedJob collapses the typed Output + Error to () + boxed error so the scheduler can store heterogeneous jobs in one DAG.
Gate
One typed precondition. Pure — no IO. Gate impls that “need” IO are antipatterns; the right shape is a Job that emits a typed fact and a downstream gate that checks the fact.
Job
The typed Job trait — what every consumer’s domain-specific job implements. Per theory/SHIGOTO.md §III.1.
JobError
JobInput
Inputs / Outputs / Errors implement these marker traits so the scheduler can serialize across boundaries when persistence lands.
JobOutput
OutputSink
Typed receiver for Job::Output values. Jobs call record on a successful execute so consumers (reconcile receipts, audit trails, dashboards) can read the typed outcomes the scheduler’s phase-tracking discards.
RecordingJob
Convenience trait that captures the most common Job authoring shape across pleme-io consumers: a Job whose typed Output flows through an OutputSink for consumer-side capture, and whose identity decomposes into (scope, kind, subject).
RetryDecider
Scheduler
TransitionEmitter
Receivers of TransitionEvent. Thin trait over the canonical shigoto_types::sink::Sink<TransitionEvent> so every consumer writing Arc<dyn TransitionEmitter> keeps working unchanged after the theory/CONVERGENCE-ADOPTION.md Phase 0.1 extraction. The blanket impl below means any Sink<TransitionEvent> impl auto-satisfies TransitionEmitter — no per-impl wiring at the consumer side.

Functions§

advance
The canonical FSM driver. Pure: same (from, signal) always produces the same result. Exhaustive over JobPhase × Signal — adding a new phase or signal fails to compile until every cell of the cross-product is decided.

Type Aliases§

AuditFileEmitter
Append-only JSONL audit file. One event per line. Same shape as tend’s existing audit.rs so operators can grep both with the same tooling. Alias of the canonical shigoto_types::sink::AuditFileSink<TransitionEvent> — JSONL serialization is byte-identical (one serde_json::to_string per line + writeln! append).
MultiEmitter
Fan-out emitter — every inner sink receives every event. Alias of the canonical shigoto_types::sink::MultiSink<TransitionEvent>; inner sinks are Arc<dyn Sink<TransitionEvent>>.
NullEmitter
No-op emitter — the default for tests + consumers without observability wired up. Sinks should compose via MultiEmitter instead of stubbing this in production. Alias of the canonical shigoto_types::sink::NullSink<TransitionEvent>.