Skip to main content

TaskContext

Struct TaskContext 

Source
pub struct TaskContext {
    pub tick: u64,
    pub workers: HashMap<WorkerId, WorkerSummary>,
    pub success_rate: f64,
    pub progress: f64,
    pub escalations: Vec<(WorkerId, Escalation)>,
    pub available_actions: Option<ActionsConfig>,
    pub v2_guidances: Option<Vec<Guidance>>,
    pub excluded_actions: Vec<String>,
    pub previous_guidances: HashMap<WorkerId, Arc<Guidance>>,
    pub done_workers: HashSet<WorkerId>,
    pub metadata: HashMap<String, Value>,
}
Expand description

タスク状況(Analyzer が生成、Manager が消費)

§構成

  • ベース情報: tick, workers, success_rate, progress, escalations, available_actions
  • 探索情報: v2_guidances, excluded_actions
  • 拡張 KV: metadata で任意の追加情報を格納

§使用例

let context = TaskContext::new(tick)
    .with_worker(WorkerSummary::new(WorkerId(0)).with_phase(WorkerPhase::Working))
    .with_progress(0.5)
    .insert("llm_summary", "探索フェーズ中");

Fields§

§tick: u64

現在の tick

§workers: HashMap<WorkerId, WorkerSummary>

各 Worker の状態サマリ

§success_rate: f64

成功率 (0.0 - 1.0)

§progress: f64

進捗 (0.0 - 1.0)

§escalations: Vec<(WorkerId, Escalation)>

Escalation 一覧(WorkerId, Escalation)

§available_actions: Option<ActionsConfig>

利用可能なアクション

§v2_guidances: Option<Vec<Guidance>>

ExplorationSpaceV2 から生成された Guidance

select_nodes() → Guidance 変換で直接生成。 Manager はこれをそのまま Worker に配布できる。

§excluded_actions: Vec<String>

除外すべきアクション(成功済み/クローズ済み)- プロンプトから除外

§previous_guidances: HashMap<WorkerId, Arc<Guidance>>

前回の Guidance(Worker ID -> Arc

Orchestrator が Manager.prepare() 呼び出し前に設定。 Manager は prepare() でこれを使って ResolvedContext に ManagerInstruction を埋め込む。 Arc で共有することでクローン時のディープコピーを回避。

§done_workers: HashSet<WorkerId>

Goal Action(Terminal Action)を達成した Worker これらのWorkerは Manager.prepare() でリクエスト対象から除外される

§metadata: HashMap<String, Value>

追加メタデータ(軽量LLM分析結果等)

Implementations§

Source§

impl TaskContext

Source

pub fn new(tick: u64) -> Self

新しい TaskContext を作成

Source

pub fn with_worker(self, summary: WorkerSummary) -> Self

Worker サマリを追加

Source

pub fn with_success_rate(self, rate: f64) -> Self

成功率を設定

Source

pub fn with_progress(self, progress: f64) -> Self

進捗を設定

Source

pub fn with_escalation( self, worker_id: WorkerId, escalation: Escalation, ) -> Self

Escalation を追加

Source

pub fn with_actions(self, actions: ActionsConfig) -> Self

利用可能なアクションを設定

Source

pub fn with_previous_guidances( self, guidances: HashMap<WorkerId, Arc<Guidance>>, ) -> Self

前回の Guidance を設定(Arc で共有)

Source

pub fn with_previous_guidance( self, worker_id: WorkerId, guidance: Arc<Guidance>, ) -> Self

単一 Worker の前回 Guidance を追加

Source

pub fn insert<V: Into<Value>>(self, key: impl Into<String>, value: V) -> Self

メタデータを追加

Source

pub fn set<V: Into<Value>>(&mut self, key: impl Into<String>, value: V)

メタデータを追加(mutable)

Source

pub fn get(&self, key: &str) -> Option<&Value>

メタデータを取得

Source

pub fn get_str(&self, key: &str) -> Option<&str>

メタデータを文字列として取得

Source

pub fn get_f64(&self, key: &str) -> Option<f64>

メタデータを数値として取得

Source

pub fn get_i64(&self, key: &str) -> Option<i64>

メタデータを整数として取得

Source

pub fn get_bool(&self, key: &str) -> Option<bool>

メタデータを真偽値として取得

Source

pub fn has_escalations(&self) -> bool

Escalation があるか

Source

pub fn has_escalation_for(&self, worker_id: WorkerId) -> bool

特定の Worker が Escalation 中かどうか

Source

pub fn worker(&self, id: WorkerId) -> Option<&WorkerSummary>

特定 Worker の情報を取得

Source

pub fn escalated_worker_count(&self) -> usize

Escalation 中の Worker 数を取得

Source

pub fn worker_ids(&self) -> Vec<WorkerId>

Worker ID 一覧を取得

Source§

impl TaskContext

Source

pub fn has_exploration(&self) -> bool

探索が有効か(v2_guidances がある場合)

Source

pub fn filter_for_workers(&self, worker_ids: &[WorkerId]) -> TaskContext

指定した Worker のみを含むフィルタ済み TaskContext を作成

Manager のパーティショニングで使用。 各 Manager は担当する Worker のみの TaskContext を受け取る。

Trait Implementations§

Source§

impl Clone for TaskContext

Source§

fn clone(&self) -> TaskContext

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TaskContext

Source§

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

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

impl Default for TaskContext

Source§

fn default() -> Self

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

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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