adapters/nats: optional NATS bridge for ai/verify barrier decisions - #385
Conversation
VerifyBridge wraps a *verify.Workflow and publishes a BarrierDecision event to a NATS subject after each CheckSafety/CheckAndCommit/ CheckAndCommitIdempotent call, for a team that already runs NATS and wants to observe barrier decisions from another service without polling. It calls straight through to the wrapped workflow and returns its exact result; a publish failure never changes or blocks the barrier's own decision. ai/verify itself is untouched, and nothing here reads or writes the B-Tree. Own Go module under go.work, same pattern as adapters/redis and adapters/cassandra. Tests start an in-process NATS server (nats-server/v2) so they need no external service listening.
Added it to the same for-loop that already builds, vets, and tests search, jsondb, incfs, adapters/cassandra, and adapters/redis, each a separate module under go.work that go list ./... from the root never reaches on its own.
Runs the same blocked-then-allowed drop_prod_db sequence as examples/verify_barrier, through an adapters/nats.VerifyBridge instead of calling *verify.Workflow directly, with a second goroutine subscribed to the published events standing in for an external observer. Needs a NATS server at nats://127.0.0.1:4222 to run; prints a plain message and exits if one isn't reachable.
Short addendum to docs/MCP_A2A_AND_VERIFICATION_ENGINE.md explaining why ai/verify has no event mechanism of its own, what the bridge adds instead, and why it's opt-in and doesn't touch storage.
Gemini PR ReviewThe diff introduces a new Code quality and readability
Potential bugs and correctness issues
Missed edge cases
Performance considerations
The diff introduces a well-designed, robust, and thoroughly tested NATS observability bridge without compromising the core |
…lves, and skip the image-scan sarif upload when the scan never ran
Gemini PR ReviewThis pull request introduces a new Code quality and readability
Potential bugs and correctness issues
Missed edge cases
Performance considerations
|
… doesn't reverse joltrin's embedded thesis, it never touches the hot path
Gemini PR ReviewThis pull request introduces an optional NATS bridge for observing Overall, the diff looks fine and is a well-executed feature addition. Code quality and readability
Potential bugs and correctness issues
Missed edge cases
Performance considerations
|
This is entirely opt-in and doesn't touch joltrin's embedded core, the B-Tree/storage hot path, or ai/verify itself. Happy to adjust or close this if it isn't a direction you want.
I went looking for a genuine, honest way to let an external system observe joltrin's internal events over NATS, without contradicting the project's whole embedded-only pitch. ai/verify (the runbook safety barrier described in docs/MCP_A2A_AND_VERIFICATION_ENGINE.md) turned out to be a clean fit: it's a synchronous, dependency-free library, CheckSafety/CheckAndCommit/CheckAndCommitIdempotent just return their decision directly to the caller, with no event or hook mechanism of its own. Agent memory checkpointing, the other place I looked, is a direct B-Tree write with no comparable seam, so I left that alone rather than force something into the storage path.
What this adds: adapters/nats, its own Go module under go.work (same pattern as adapters/redis and adapters/cassandra). VerifyBridge wraps a *verify.Workflow and publishes a small JSON BarrierDecision event to a NATS subject after each barrier check, for a team that already runs NATS elsewhere and wants to observe these decisions from another service. It calls straight through to the wrapped workflow and returns its exact result unchanged; a publish failure can never change or block the barrier's own decision. Nothing in ai/verify, tools/mcpserver, or tools/a2aagent was modified, and nothing here reads or writes the B-Tree.
Also included: tests against a real in-process NATS server (nats-server/v2), so they need nothing listening externally, either locally or in CI; a runnable example (examples/verify_barrier_nats) that replays examples/verify_barrier's blocked-then-allowed sequence through the bridge with a subscriber attached; a short addendum to docs/MCP_A2A_AND_VERIFICATION_ENGINE.md; and adapters/nats added to the CI workflow's per-module build/vet/test loop alongside the other workspace modules.
Ran locally before pushing: gofmt -l (clean), go build/go vet across the root module with the same exclusions CI uses, and the same for-loop CI runs over search, jsondb, incfs, adapters/cassandra, adapters/redis, and adapters/nats, all passing, including go test -race for the new module.