Skip to content

bridge: include inbox.pull observability meta#149

Merged
benvinegar merged 1 commit intomainfrom
bridge/inbox-pull-meta-observability
Feb 23, 2026
Merged

bridge: include inbox.pull observability meta#149
benvinegar merged 1 commit intomainfrom
bridge/inbox-pull-meta-observability

Conversation

@benvinegar
Copy link
Copy Markdown
Member

@benvinegar benvinegar commented Feb 23, 2026

Summary

Add baudbot-side broker client support for modem-dev/baudbot-services#61 by including an optional meta object on POST /api/inbox/pull.

What changed

  • slack-bridge/broker-bridge.mjs
    • Adds meta payload on inbox pull requests with:
      • agent_version (from BAUDBOT_AGENT_VERSION override or ~/.pi/agent/baudbot-version.json, fallback unknown)
      • uptime metrics (bridge_uptime_hours, system_uptime_hours)
      • health counters (heartbeat_runs, heartbeat_consecutive_errors, heartbeat_last_ok_at)
      • session counts (active_sessions, active_dev_agents)
      • poll metadata (outbound_mode, poll_count, max_messages, wait_seconds)
  • test/broker-bridge.integration.test.mjs
    • Extends inbox pull protocol test to assert meta is present and includes expected fields/types.
  • Docs/config
    • CONFIGURATION.md: documents optional BAUDBOT_AGENT_VERSION
    • .env.schema: adds BAUDBOT_AGENT_VERSION

Validation

  • npm test -- test/broker-bridge.integration.test.mjs

Notes

  • Signature/canonicalization behavior is unchanged for inbox pull (still signs protocol payload fields).
  • This PR only emits metadata from baudbot; broker-side storage/query mapping is handled in modem-dev/baudbot-services#61.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Feb 23, 2026

Greptile Summary

Adds observability metadata to broker inbox pull requests to enable broker-side monitoring and diagnostics. The implementation correctly excludes the meta object from signature canonicalization (verified in tests), ensuring backward compatibility with the existing protocol security model.

Key additions:

  • buildPullMeta() collects agent version, uptime metrics, health counters, and session counts
  • readAgentVersion() reads from env override or ~/.pi/agent/baudbot-version.json
  • countActivePiSessions() scans socket directory for active sessions and dev agents
  • Tests verify meta structure and signature validation still works correctly

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • Clean implementation with comprehensive test coverage. The critical security invariant (signature excludes meta from canonicalization) is properly tested and documented. All new code has safe error handling with fallback values.
  • No files require special attention

Important Files Changed

Filename Overview
slack-bridge/broker-bridge.mjs Added observability metadata collection (buildPullMeta) including agent version, uptime metrics, health counters, and session counts; properly excludes meta from signature canonicalization
test/broker-bridge.integration.test.mjs Extended protocol test to verify meta object presence and structure; confirms signature still validates correctly (meta not included in canonical payload)

Sequence Diagram

sequenceDiagram
    participant Bridge as broker-bridge.mjs
    participant FS as File System
    participant Broker as Broker API
    
    Bridge->>Bridge: startPollLoop()
    Bridge->>Bridge: pullInbox()
    Bridge->>Bridge: buildPullMeta()
    Bridge->>FS: readAgentVersion() from env/file
    FS-->>Bridge: agent_version
    Bridge->>FS: countActivePiSessions() from socket dir
    FS-->>Bridge: active_sessions, active_dev_agents
    Bridge->>Bridge: Calculate uptime metrics
    Bridge->>Bridge: Collect health counters
    Note over Bridge: meta object assembled<br/>(NOT included in signature)
    Bridge->>Bridge: signPullRequest(timestamp, max, wait)
    Note over Bridge: Signature only covers<br/>protocol payload fields
    Bridge->>Broker: POST /api/inbox/pull<br/>{workspace_id, protocol_version,<br/>max_messages, wait_seconds,<br/>timestamp, signature, meta}
    Broker-->>Bridge: {messages: [...]}
    Bridge->>Bridge: Process messages
Loading

Last reviewed commit: 8028b1d

@benvinegar benvinegar merged commit 57ccddb into main Feb 23, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant