Files
viettranx c8ebe9a789 refactor(comments): remove plan/phase refs from agent identity hardening code
Rewrite inline comments added during the agent identity hardening so
they explain the code as it stands today, rather than tying to internal
plan terminology (phase numbers, FR/NFR/H/M/C codes, PR references,
trap zone labels). Commit history already carries the plan archaeology.
Comments now keep the non-obvious invariants (cache boundaries, bypass
gaps, silent-nil traps, dual-tenant semantics) and drop the scaffolding.
Comment-only — no runtime behavior change.
2026-04-11 21:22:23 +07:00

32 lines
1013 B
Go

package eventbus
import (
"log/slog"
"github.com/google/uuid"
)
// validateAgentID is a publish-time observer that logs a warning when a
// DomainEvent carries a non-UUID AgentID. It does NOT block the publish —
// observability only. Acts as a safety net catching future drift before the
// event reaches a consumer that parses the field as a UUID and queries the DB
// with it.
//
// Log field name is `non_uuid_agent_id` — intentionally distinct from the
// standard `agent_id` field used elsewhere — to avoid collision with
// observability tooling that parses `agent_id` as a UUID.
//
// See docs/agent-identity-conventions.md for the full convention.
func validateAgentID(event DomainEvent) {
if event.AgentID == "" {
return // legitimate team-owned, tenant-scoped, or anonymous event
}
if _, err := uuid.Parse(event.AgentID); err != nil {
slog.Warn("eventbus.non_uuid_agent_id",
"event_type", event.Type,
"non_uuid_agent_id", event.AgentID,
"source_id", event.SourceID,
)
}
}