Add messaging config types and load/save functions (gt-i6jvc)

Add MessagingConfig with:
- Lists: static mailing lists with fan-out delivery
- Queues: shared work queues with claiming
- Announces: bulletin boards for broadcast messages

Includes:
- types.go: MessagingConfig, QueueConfig, AnnounceConfig types
- loader.go: Load/Save/Validate functions, MessagingConfigPath helper
- loader_test.go: Round-trip and validation tests

Created ~/gt/config/messaging.json with example configuration.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-28 14:07:30 -08:00
parent 176ad3ae69
commit 6fb4851301
3 changed files with 345 additions and 0 deletions

View File

@@ -254,3 +254,57 @@ func DefaultAccountsConfigDir() string {
home, _ := os.UserHomeDir()
return home + "/.claude-accounts"
}
// MessagingConfig represents the messaging configuration (config/messaging.json).
// This defines mailing lists, work queues, and announcement channels.
type MessagingConfig struct {
Version int `json:"version"` // schema version
// Lists are static mailing lists. Messages are fanned out to all recipients.
// Each recipient gets their own copy of the message.
// Example: {"oncall": ["mayor/", "gastown/witness"]}
Lists map[string][]string `json:"lists,omitempty"`
// Queues are shared work queues. Only one copy exists; workers claim messages.
// Messages sit in the queue until explicitly claimed by a worker.
// Example: {"work/gastown": ["gastown/polecats/*"]}
Queues map[string]QueueConfig `json:"queues,omitempty"`
// Announces are bulletin boards. One copy exists; anyone can read, no claiming.
// Used for broadcast announcements that don't need acknowledgment.
// Example: {"alerts": {"readers": ["@town"]}}
Announces map[string]AnnounceConfig `json:"announces,omitempty"`
}
// QueueConfig represents a work queue configuration.
type QueueConfig struct {
// Workers lists addresses eligible to claim from this queue.
// Supports wildcards: "gastown/polecats/*" matches all polecats in gastown.
Workers []string `json:"workers"`
// MaxClaims is the maximum number of concurrent claims (0 = unlimited).
MaxClaims int `json:"max_claims,omitempty"`
}
// AnnounceConfig represents a bulletin board configuration.
type AnnounceConfig struct {
// Readers lists addresses eligible to read from this announce channel.
// Supports @group syntax: "@town", "@rig/gastown", "@witnesses".
Readers []string `json:"readers"`
// RetainCount is the number of messages to retain (0 = unlimited).
RetainCount int `json:"retain_count,omitempty"`
}
// CurrentMessagingVersion is the current schema version for MessagingConfig.
const CurrentMessagingVersion = 1
// NewMessagingConfig creates a new MessagingConfig with defaults.
func NewMessagingConfig() *MessagingConfig {
return &MessagingConfig{
Version: CurrentMessagingVersion,
Lists: make(map[string][]string),
Queues: make(map[string]QueueConfig),
Announces: make(map[string]AnnounceConfig),
}
}