mirror of
https://github.com/hanzoai/team-go.git
synced 2026-10-30 20:22:42 +00:00
The Go transactor and account service for Hanzo Team. History starts here. The previous 107 commits carried the fork's origin in their messages and their tree, and none of it described this code: the Go under pkg/transactor is Hanzo's own work implementing a wire protocol, not a port of anyone's implementation. pkg/transactor/model.json remains, and remains attributed. It is a compiled platform model this transactor loads through go:embed, governed by EPL-2.0 and named in NOTICE. Removing it is a replacement project -- a new compiler and a move off the protocol -- not a deletion.
37 lines
1.2 KiB
Go
37 lines
1.2 KiB
Go
package bots
|
|
|
|
// reconcilePlan is the diff between the desired bot set (from IAM + cloud
|
|
// agents) and the workspace's current bot members.
|
|
type reconcilePlan struct {
|
|
toAdd []ServiceAccount // enabled SAs not yet present
|
|
toRemove []string // service_account_ids of members to deactivate
|
|
}
|
|
|
|
// reconcile is a pure function: given the desired service-accounts and the set
|
|
// of service_account_ids currently active as bot members, return which to add
|
|
// and which to deactivate. Disabled SAs are removed; enabled SAs not yet present
|
|
// are added. A no-op re-run yields empty add/remove.
|
|
//
|
|
// This is the Go port of reconcileBotMembers (mapping.ts) — identical semantics,
|
|
// so the behavior is locked across the TS→Go move.
|
|
func reconcile(desired []ServiceAccount, currentSaIDs map[string]bool) reconcilePlan {
|
|
desiredIDs := make(map[string]bool, len(desired))
|
|
var toAdd []ServiceAccount
|
|
for _, sa := range desired {
|
|
if sa.Disabled {
|
|
continue
|
|
}
|
|
desiredIDs[sa.ID] = true
|
|
if !currentSaIDs[sa.ID] {
|
|
toAdd = append(toAdd, sa)
|
|
}
|
|
}
|
|
var toRemove []string
|
|
for saID := range currentSaIDs {
|
|
if !desiredIDs[saID] {
|
|
toRemove = append(toRemove, saID)
|
|
}
|
|
}
|
|
return reconcilePlan{toAdd: toAdd, toRemove: toRemove}
|
|
}
|