Help us shape the future of Go! Take the 2026 Go Developer Survey

blackboard

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 4 Imported by: 1

Documentation

Overview

Package blackboard 黑板(Blackboard)架构原语:共享状态板 + 多专家轮转读写。

与 Supervisor(eino adk prebuilt:中心调度员指派任务)不同,Blackboard 没有 调度员——每位专家自行观察黑板增量、判断与己相关则贡献条目;循环至无人再写 或达轮次上限。适用:多视角分析(多角色并行审阅同一材料、结论互相引用), 贡献顺序不可预知、无中心指派逻辑的场景。

并发语义:Board 线程安全;Convene 每轮串行调用各专家(专家内可自行并发)。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Board

type Board struct {
	// contains filtered or unexported fields
}

Board 共享黑板(线程安全;内存态——持久化由调用方按 Entries 快照自行落库)。

func NewBoard

func NewBoard() *Board

NewBoard 创建黑板。

func (*Board) Entries

func (b *Board) Entries() []Entry

Entries 全量快照。

func (*Board) EntriesAfter

func (b *Board) EntriesAfter(after int64) []Entry

EntriesAfter 增量观察:返回 seq > after 的条目(专家"自上次读过之后"的新内容)。

func (*Board) Latest

func (b *Board) Latest(kind string) (Entry, bool)

Latest 读某 Kind 的最新条目。

func (*Board) Seed

func (b *Board) Seed(kind, content string) Entry

Seed 写入初始材料(author="user")。

func (*Board) Write

func (b *Board) Write(author, kind, content string) Entry

Write 追加条目,返回带序号的完整条目。

type ConveneOptions

type ConveneOptions struct {
	// MaxRounds 轮次上限(默认 3;每轮所有专家依次观察一次)。
	MaxRounds int
}

ConveneOptions 召集配置。

type ConveneResult

type ConveneResult struct {
	Rounds     int   // 实际轮数
	Total      int   // 黑板条目总数
	CurrentMax int64 // 当前最大 Seq(供调用方留痕)
}

ConveneResult 召集结果。

func Convene

func Convene(ctx context.Context, b *Board, specialists []Specialist, opts *ConveneOptions) (*ConveneResult, error)

Convene 召集专家轮转协作:每轮按序让每位专家观察增量并可写入; 一整轮无人贡献(共识达成)或达 MaxRounds 停止。 Specialist.Name 须非空且全局唯一(构建期 fail-fast):观察游标按 Name 键控, 重名会共享游标(后执行者读到被同名者推进的 since,跳过的增量永不重看)。

type Entry

type Entry struct {
	Seq     int64     `json:"seq"`     // 单调递增(增量观察游标)
	Author  string    `json:"author"`  // 贡献者(专家名或 "user")
	Kind    string    `json:"kind"`    // 条目类型(如 "material"/"finding"/"verdict";词表由调用方约定)
	Content string    `json:"content"` // 内容
	At      time.Time `json:"at"`
}

Entry 黑板条目。

type Specialist

type Specialist struct {
	// Name 专家名(贡献条目的 Author)。
	Name string
	// Act 观察与贡献。since = 该专家上一轮读到的最大 Seq(首轮 0);
	// 返回 contributed=false 表示本轮无事可做。
	Act func(ctx context.Context, b *Board, since int64) (contributed bool, err error)
}

Specialist 专家:观察黑板增量,判断与己相关则贡献条目。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL