v0.3.9-pre.002-fix.001
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-worker-api/src/identity.rs
|
||||
// version: 1
|
||||
// version: 2
|
||||
|
||||
/// Maximum UTF-8 byte length admitted for one Worker identifier.
|
||||
pub const MAX_WORKER_ID_BYTES: usize = 128;
|
||||
@@ -10,7 +10,7 @@ pub const MAX_WORKER_KIND_CODE_BYTES: usize = 128;
|
||||
#[derive(Clone, Eq, Hash, Ord, PartialEq, PartialOrd)]
|
||||
pub struct WorkerId(std::string::String);
|
||||
|
||||
impl WorkerId {
|
||||
impl crate::WorkerId {
|
||||
/// Creates one non-empty Worker identifier using the KSP safe-code alphabet.
|
||||
pub fn new(value: impl std::convert::Into<std::string::String>) -> crate::Result<Self> {
|
||||
let value = value.into();
|
||||
@@ -27,7 +27,7 @@ impl WorkerId {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for WorkerId {
|
||||
impl std::fmt::Debug for crate::WorkerId {
|
||||
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
return formatter.write_str("WorkerId(..)");
|
||||
}
|
||||
@@ -37,7 +37,7 @@ impl std::fmt::Debug for WorkerId {
|
||||
#[derive(Clone, Eq, Hash, Ord, PartialEq, PartialOrd)]
|
||||
pub struct WorkerKindCode(std::string::String);
|
||||
|
||||
impl WorkerKindCode {
|
||||
impl crate::WorkerKindCode {
|
||||
/// Creates one non-empty Worker kind using the KSP safe-code alphabet.
|
||||
pub fn new(value: impl std::convert::Into<std::string::String>) -> crate::Result<Self> {
|
||||
let value = value.into();
|
||||
@@ -54,7 +54,7 @@ impl WorkerKindCode {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for WorkerKindCode {
|
||||
impl std::fmt::Debug for crate::WorkerKindCode {
|
||||
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
return formatter.debug_tuple("WorkerKindCode").field(&self.0).finish();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-worker-api/src/lifecycle.rs
|
||||
// version: 1
|
||||
// version: 2
|
||||
|
||||
/// Current lifecycle state of one continuous Worker.
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
|
||||
@@ -19,7 +19,7 @@ pub enum WorkerState {
|
||||
Faulted(crate::ErrorCode),
|
||||
}
|
||||
|
||||
impl WorkerState {
|
||||
impl crate::WorkerState {
|
||||
/// Returns the stable safe lifecycle code without rendering Worker data.
|
||||
#[must_use]
|
||||
pub const fn code(&self) -> &'static str {
|
||||
@@ -63,7 +63,7 @@ pub enum WorkerHealth {
|
||||
Unhealthy,
|
||||
}
|
||||
|
||||
impl WorkerHealth {
|
||||
impl crate::WorkerHealth {
|
||||
/// Returns the stable safe code for this health classification.
|
||||
#[must_use]
|
||||
pub const fn code(&self) -> &'static str {
|
||||
@@ -88,7 +88,7 @@ pub enum WorkerActivity {
|
||||
Active,
|
||||
}
|
||||
|
||||
impl WorkerActivity {
|
||||
impl crate::WorkerActivity {
|
||||
/// Returns the stable safe code for this activity classification.
|
||||
#[must_use]
|
||||
pub const fn code(&self) -> &'static str {
|
||||
@@ -108,7 +108,7 @@ pub struct WorkerLifecycle {
|
||||
state: crate::WorkerState,
|
||||
}
|
||||
|
||||
impl WorkerLifecycle {
|
||||
impl crate::WorkerLifecycle {
|
||||
/// Creates one lifecycle in [`WorkerState::Created`] state.
|
||||
#[must_use]
|
||||
pub const fn new(id: crate::WorkerId, kind: crate::WorkerKindCode) -> Self {
|
||||
@@ -167,7 +167,7 @@ impl WorkerLifecycle {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for WorkerLifecycle {
|
||||
impl std::fmt::Debug for crate::WorkerLifecycle {
|
||||
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
return formatter.debug_struct("WorkerLifecycle").field("id", &self.id).field("kind", &self.kind).field("state", &self.state).finish();
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
// file: crates/ksp-worker-api/src/snapshot.rs
|
||||
// version: 1
|
||||
// version: 2
|
||||
|
||||
/// Monotone sequence attached to one latest-value Worker snapshot stream.
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
|
||||
pub struct WorkerSnapshotSequence(u64);
|
||||
|
||||
impl WorkerSnapshotSequence {
|
||||
impl crate::WorkerSnapshotSequence {
|
||||
/// Creates the initial sequence position for one Worker snapshot stream.
|
||||
#[must_use]
|
||||
pub const fn initial() -> Self {
|
||||
@@ -50,7 +50,7 @@ pub struct WorkerSnapshot {
|
||||
activity: crate::WorkerActivity,
|
||||
}
|
||||
|
||||
impl WorkerSnapshot {
|
||||
impl crate::WorkerSnapshot {
|
||||
/// Creates one immutable common Worker snapshot from already validated values.
|
||||
#[must_use]
|
||||
pub const fn new(
|
||||
@@ -101,7 +101,7 @@ impl WorkerSnapshot {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for WorkerSnapshot {
|
||||
impl std::fmt::Debug for crate::WorkerSnapshot {
|
||||
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
return formatter
|
||||
.debug_struct("WorkerSnapshot")
|
||||
@@ -130,7 +130,7 @@ pub trait WorkerSnapshotSource: std::marker::Send + std::marker::Sync {
|
||||
|
||||
#[cfg(test)]
|
||||
fn exhausted_snapshot_sequence() -> crate::WorkerSnapshotSequence {
|
||||
return WorkerSnapshotSequence(u64::MAX);
|
||||
return crate::WorkerSnapshotSequence(u64::MAX);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-worker-api/src/stop.rs
|
||||
// version: 1
|
||||
// version: 2
|
||||
|
||||
/// Runtime-neutral cloneable token carrying cooperative Worker stop intent.
|
||||
#[derive(Clone)]
|
||||
@@ -7,7 +7,7 @@ pub struct WorkerStopToken {
|
||||
requested: std::sync::Arc<std::sync::atomic::AtomicBool>,
|
||||
}
|
||||
|
||||
impl WorkerStopToken {
|
||||
impl crate::WorkerStopToken {
|
||||
/// Creates a token with no stop request.
|
||||
#[must_use]
|
||||
pub fn new() -> Self {
|
||||
@@ -27,13 +27,13 @@ impl WorkerStopToken {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::default::Default for WorkerStopToken {
|
||||
impl std::default::Default for crate::WorkerStopToken {
|
||||
fn default() -> Self {
|
||||
return Self::new();
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for WorkerStopToken {
|
||||
impl std::fmt::Debug for crate::WorkerStopToken {
|
||||
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
return formatter.debug_struct("WorkerStopToken").field("stop_requested", &self.is_stop_requested()).finish();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-worker-api/tests/dependency_boundary.rs
|
||||
// version: 1
|
||||
// version: 2
|
||||
|
||||
//! Dependency and runtime-neutrality canaries for the Worker API foundation.
|
||||
|
||||
@@ -59,6 +59,47 @@ fn pre_002_production_sources_forbid_job_runtime_domain_and_wire_dependencies()
|
||||
return;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pre_002_fix_001_shared_visible_items_use_crate_root_facade_inside_owner_modules() {
|
||||
let identity = include_str!("../src/identity.rs");
|
||||
let lifecycle = include_str!("../src/lifecycle.rs");
|
||||
let snapshot = include_str!("../src/snapshot.rs");
|
||||
let stop = include_str!("../src/stop.rs");
|
||||
for expected in [
|
||||
"impl crate::WorkerId {",
|
||||
"impl std::fmt::Debug for crate::WorkerId {",
|
||||
"impl crate::WorkerKindCode {",
|
||||
"impl std::fmt::Debug for crate::WorkerKindCode {",
|
||||
] {
|
||||
assert!(identity.contains(expected), "missing crate-root Worker identity impl target: {expected}");
|
||||
}
|
||||
for expected in [
|
||||
"impl crate::WorkerActivity {",
|
||||
"impl crate::WorkerHealth {",
|
||||
"impl crate::WorkerLifecycle {",
|
||||
"impl crate::WorkerState {",
|
||||
"impl std::fmt::Debug for crate::WorkerLifecycle {",
|
||||
] {
|
||||
assert!(lifecycle.contains(expected), "missing crate-root Worker lifecycle impl target: {expected}");
|
||||
}
|
||||
for expected in [
|
||||
"impl crate::WorkerSnapshotSequence {",
|
||||
"impl crate::WorkerSnapshot {",
|
||||
"impl std::fmt::Debug for crate::WorkerSnapshot {",
|
||||
"return crate::WorkerSnapshotSequence(u64::MAX);",
|
||||
] {
|
||||
assert!(snapshot.contains(expected), "missing crate-root Worker snapshot reference: {expected}");
|
||||
}
|
||||
for expected in [
|
||||
"impl crate::WorkerStopToken {",
|
||||
"impl std::default::Default for crate::WorkerStopToken {",
|
||||
"impl std::fmt::Debug for crate::WorkerStopToken {",
|
||||
] {
|
||||
assert!(stop.contains(expected), "missing crate-root Worker stop impl target: {expected}");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
fn manifest_dependency_names(section: &str) -> std::vec::Vec<&str> {
|
||||
let mut names = std::vec::Vec::new();
|
||||
for line in section.lines() {
|
||||
|
||||
Reference in New Issue
Block a user