moderator

package
v0.8.104 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: AGPL-3.0, AGPL-3.0-or-later, Apache-2.0, + 1 more Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrModeratorInitFailed warpnet.WarpError = "moderator: failed to init engine"
	ErrFetchFailed         warpnet.WarpError = "moderator: fetch failed"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine added in v0.5.21

type Engine interface {
	Moderate(content string) (bool, string, error)
	Close()
}

type Moderator

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

Moderator runs entirely report-driven: there is no peer-scanning loop. Every report opens a vote round shared by all moderators listening on ReportsTopic. The Moderator owns the side effects — running the engine, gossip, reporter notification, isolation — and hands the protocol itself (who votes, when, who finalizes) to the rounds it opens; it implements roundHost so a round can reach back for exactly those effects and nothing else.

func NewModerator added in v0.5.21

func NewModerator(
	ctx context.Context,
	node ModeratorNode,
	pub Publisher,
	sub ReportSubscriber,
	votes VoteExchange,
	privKey ed25519.PrivateKey,
) (*Moderator, error)

func (*Moderator) AuditStanding added in v0.8.77

func (m *Moderator) AuditStanding(peerID string) audit.Standing

AuditStanding reports what this node's own spot-checks make of a peer. Nothing consults it yet — see the audit package docs on why a single auditor must not be allowed to disqualify anyone on its own.

func (*Moderator) Broadcast added in v0.8.77

func (m *Moderator) Broadcast(v vote.Event) error

Broadcast implements round.Participant.

func (*Moderator) ChallengeHandler added in v0.8.77

func (m *Moderator) ChallengeHandler() warpnet.WarpHandlerFunc

ChallengeHandler answers audit spot-checks from other moderators: it runs the local engine over the challenged text and signs the answer with this node's key. Register it under audit.ChallengeRoute.

func (*Moderator) Close

func (m *Moderator) Close()

func (*Moderator) Decided added in v0.8.77

func (m *Moderator) Decided(rep event.ReportEvent, outcome vote.Event, votes []event.VerdictVote)

Decided implements round.Participant: it delivers the agreed verdict to the reporter and, on FAIL, runs the isolation broadcast. Shadow-ban: only bad verdicts go on the followers broadcast. Called by the round that picked this node to carry the decision — as chair, or as the backup that took over.

func (*Moderator) Event added in v0.8.77

func (m *Moderator) Event() <-chan warpnet.PeerEvent

Event is what this moderator concluded about its peers: the verdicts it carried, and what the audit made of the other moderators.

func (*Moderator) Start added in v0.5.21

func (m *Moderator) Start() error

func (*Moderator) Vote added in v0.8.103

func (m *Moderator) Vote(reportID string, rep event.ReportEvent) (vote.Event, bool, error)

Vote implements round.Participant: it runs the engine over the reported object and returns this moderator's finished vote. The bool is false when the report is unusable and no vote should be cast at all.

type ModeratorNode

type ModeratorNode interface {
	Node() warpnet.P2PNode
	ID() warpnet.WarpPeerID
	NodeInfo() warpnet.NodeInfo
	GenericStream(nodeIdStr string, path stream.WarpRoute, data any) (_ []byte, err error)
}

type Publisher added in v0.5.21

type Publisher interface {
	PublishUpdateToFollowers(ownerId, dest string, body any) (err error)
}

type ReportSubscriber added in v0.7.59

type ReportSubscriber interface {
	SubscribeReports(h func(ev event.ReportEvent) error) error
}

ReportSubscriber is the slice of the moderator pubsub the Moderator needs. It hands out one ReportEvent per gossip message.

type VoteExchange added in v0.8.77

type VoteExchange interface {
	PublishVote(ev vote.Event) error
	SubscribeVotes(h func(ev vote.Event) error) error
}

VoteExchange carries the per-round moderator votes over gossip.

Jump to

Keyboard shortcuts

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