Commit graph

16 commits

Author SHA1 Message Date
Nick Misasi
5c7aecda49 feat(08-02): extend protobuf contract for response streaming + flush
Add flush field to ServeHTTPResponse for best-effort HTTP flush support.
Update ServeHTTPResponse and ServeHTTPResponseInit with comprehensive
documentation of streaming invariants, message ordering, and status
code validation rules.

Changes:
- Add flush boolean field (field 4) to ServeHTTPResponse
- Document response streaming invariants (init-once, header locking)
- Document status code validation (100-999 range, 0 defaults to 200)
- Regenerate Go and Python protobuf code

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 14:34:36 -05:00
Nick Misasi
19c392084b feat(08-01): add protobuf contract for ServeHTTP request streaming
Add bidirectional streaming RPC for ServeHTTP hook to support
efficient HTTP request/response transfer between Go and Python.

Key changes:
- New hooks_http.proto with ServeHTTPRequest/Response messages
- HTTPHeader message for multi-value header support
- ServeHTTPRequestInit with full request metadata
- ServeHTTPResponseInit for status and headers
- Body chunks with completion flag for streaming
- Updated hooks.proto with ServeHTTP streaming RPC
- Regenerated Go and Python code

Design decisions:
- 64KB default chunk size per gRPC best practices
- First message carries metadata, subsequent messages carry body
- body_complete flag signals end of stream
- Headers as repeated HTTPHeader for multi-value support

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 14:23:38 -05:00
Nick Misasi
20f7cdebcd feat(03-04): update Makefile and generate Go code
- Add hooks_command.proto to Makefile proto mappings
- Update hooks_command.proto to import api_remaining.proto for shared types
  (CommandArgs, CommandResponse, PluginClusterEvent)
- Define new types: WebSocketRequest, SyncMsgJson, SyncResponse, RemoteCluster
- Generated Go code compiles successfully
- Total hooks in PluginHooks service: 41 (excluding deferred ServeHTTP/ServeMetrics)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 13:42:31 -05:00
Nick Misasi
0c75338a99 feat(03-04): add remaining hook RPCs to PluginHooks service
Update hooks.proto with 11 new RPCs for command/websocket/cluster/shared channels/support hooks:

COMMAND HOOKS:
- ExecuteCommand

WEBSOCKET HOOKS:
- OnWebSocketConnect
- OnWebSocketDisconnect
- WebSocketMessageHasBeenPosted

CLUSTER HOOKS:
- OnPluginClusterEvent

SHARED CHANNELS HOOKS:
- OnSharedChannelsSyncMsg
- OnSharedChannelsPing
- OnSharedChannelsAttachmentSyncMsg
- OnSharedChannelsProfileImageSyncMsg

SUPPORT HOOKS:
- GenerateSupportData

Also added note about ServeHTTP and ServeMetrics being deferred to Phase 8.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 13:40:25 -05:00
Nick Misasi
8261d03e05 feat(03-04): create hooks_command.proto with command/cluster/websocket hook definitions
Add protobuf message definitions for command, WebSocket, cluster, shared channels,
and support data generation hooks including:
- CommandArgs, CommandResponse, SlackAttachment model types
- PluginClusterEvent, WebSocketRequest model types
- SyncMsgJson, SyncResponse, RemoteCluster for shared channels
- Request/response messages for 11 hooks:
  - ExecuteCommand
  - OnPluginClusterEvent
  - OnWebSocketConnect/Disconnect
  - WebSocketMessageHasBeenPosted
  - OnSharedChannelsSyncMsg/Ping/AttachmentSyncMsg/ProfileImageSyncMsg
  - GenerateSupportData

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 13:39:45 -05:00
Nick Misasi
6f4a0fe8c9 feat(03-03): add user/channel hook RPCs to PluginHooks service
Add 10 RPC definitions to PluginHooks service:
- USER HOOKS: UserHasBeenCreated, UserWillLogIn, UserHasLoggedIn,
  UserHasBeenDeactivated, OnSAMLLogin
- CHANNEL AND TEAM HOOKS: ChannelHasBeenCreated, UserHasJoinedChannel,
  UserHasLeftChannel, UserHasJoinedTeam, UserHasLeftTeam

Import hooks_user_channel.proto for request/response message types.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 13:36:16 -05:00
Nick Misasi
e6c343c72b feat(03-03): create hooks_user_channel.proto with user/channel hook definitions
Add protobuf definitions for 10 user and channel lifecycle hooks:
- UserHasBeenCreated, UserWillLogIn, UserHasLoggedIn, UserHasBeenDeactivated
- OnSAMLLogin (with JSON blob for SAML assertion)
- ChannelHasBeenCreated
- UserHasJoinedChannel, UserHasLeftChannel (with optional actor)
- UserHasJoinedTeam, UserHasLeftTeam (with optional actor)

Includes SamlAssertionInfoJson type for handling external SAML library types.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 13:35:44 -05:00
Nick Misasi
5b3ef59f9a feat(03-02): update Makefile and generate Go code for message hooks
- Add hooks_message.proto mapping to Makefile for proto generation
- Update hooks_message.proto to import api_remaining.proto for
  PushNotification and Preference types (avoiding redefinition)
- Generate Go code for all message hook messages and RPCs

Verified:
- make proto-gen succeeds
- go build ./public/pluginapi/grpc/generated/go/pluginapiv1/... succeeds

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 13:33:52 -05:00
Nick Misasi
079fd4cd61 feat(03-02): add message hook RPCs to PluginHooks service
Add 12 message-related RPC definitions to the PluginHooks service:
- MessageWillBePosted - intercept/modify posts before save
- MessageWillBeUpdated - intercept/modify post updates before save
- MessageHasBeenPosted - notification after post created
- MessageHasBeenUpdated - notification after post updated
- MessagesWillBeConsumed - filter posts before client delivery
- MessageHasBeenDeleted - notification after post deleted
- FileWillBeUploaded - intercept/modify file uploads
- ReactionHasBeenAdded - notification after reaction added
- ReactionHasBeenRemoved - notification after reaction removed
- NotificationWillBePushed - intercept/modify push notifications
- EmailNotificationWillBeSent - intercept/modify email notifications
- PreferencesHaveChanged - notification after preferences changed

Each RPC includes documentation explaining:
- When the hook is called
- How to use return values (modify, reject, allow)
- The original Go signature

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 13:32:27 -05:00
Nick Misasi
ab912b3a2d feat(03-02): create hooks_message.proto with message hook definitions
Add protobuf message definitions for 12 message-related hooks:
- MessageWillBePosted, MessageWillBeUpdated
- MessageHasBeenPosted, MessageHasBeenUpdated
- MessagesWillBeConsumed, MessageHasBeenDeleted
- FileWillBeUploaded
- ReactionHasBeenAdded, ReactionHasBeenRemoved
- NotificationWillBePushed, EmailNotificationWillBeSent
- PreferencesHaveChanged

Also defines model types:
- PushNotification (typed proto, moderate size)
- EmailNotificationJson (JSON blob wrapper for complex type)
- EmailNotificationContent (typed return for email hook)
- Preference (simple 4-field struct)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 13:31:51 -05:00
Nick Misasi
54d0d6cc8b feat(02-01): add PluginAPI proto skeleton and parity verifier
- Create api.proto with PluginAPI service definition covering all 236
  methods from server/public/plugin/api.go
- Create api_user_team.proto with User, Session, and Team request/response
  messages with placeholder fields
- Create api_channel_post.proto with Channel, Post, and Emoji messages
- Create api_kv_config.proto with KV store, config, plugin, and logging
  messages
- Create api_file_bot.proto with File, Upload, and Bot messages
- Create api_remaining.proto with Server, Command, Preference, OAuth,
  Group, SharedChannel, Property, and Audit messages
- Add ViewUsersRestrictions to common.proto
- Add apiverify tool that parses Go API interface and proto service
  to ensure parity
- Update Makefile with new proto file mappings

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 11:24:09 -05:00
Nick Misasi
8a38e38f0d feat(03-01): add lifecycle/system hook RPCs in hooks_lifecycle.proto and hooks.proto
Define protobuf messages and PluginHooks gRPC service for lifecycle and
system hooks:
- Implemented: returns list of hooks the plugin implements
- OnActivate/OnDeactivate: plugin lifecycle events
- OnConfigurationChange: configuration change notifications
- OnInstall: plugin installation event
- OnSendDailyTelemetry: daily telemetry hook
- RunDataRetention: data retention batch processing
- OnCloudLimitsUpdated: cloud product limit changes
- ConfigurationWillBeSaved: configuration validation/modification

Also adds model types:
- OnInstallEvent: mirrors model.OnInstallEvent
- ProductLimits/FilesLimits/MessagesLimits/TeamsLimits: typed cloud limits
- ConfigJson: JSON blob wrapper for model.Config (too large for typed proto)

Updates Makefile to include new proto file mappings.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 11:18:19 -05:00
Nick Misasi
99f4b588a8 feat(03-01): add shared hook context types (PluginContext) in hooks_common.proto
Add hooks_common.proto with PluginContext message that mirrors the
server/public/plugin/context.go Context struct. This provides session_id,
request_id, ip_address, accept_language, and user_agent fields for passing
hook invocation context from server to plugins.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 11:16:06 -05:00
Nick Misasi
1a8f3c0c4e feat(01-03): add error handling and RPC envelope conventions
- Add RequestContext message for request metadata (plugin_id, request_id,
  session_id, user_id) to enable logging correlation across Go/Python
- Add params field (google.protobuf.Struct) to AppError for error message
  interpolation, matching model.AppError's params field
- Document RPC envelope conventions in proto comments:
  - Request messages: {Method}Request with RequestContext as field 1
  - Response messages: {Method}Response with AppError as field 1
  - Error strategy: Response-embedded AppError (Option B) for full
    semantic preservation, gRPC status reserved for transport errors
- Regenerate Go code with new types

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 11:10:27 -05:00
Nick Misasi
ca57bca5a2 feat(01-02): add core protobuf types (User, Channel, Post, Team, FileInfo)
- Add common.proto with Empty, StringMap, and AppError messages
- Add user.proto with User message (34 fields mirroring model.User)
- Add channel.proto with Channel, ChannelType enum, ChannelBannerInfo
- Add post.proto with Post, PostMetadata, PostEmbed, PostPriority, Reaction
- Add team.proto with Team, TeamMember, TeamUnread, TeamType enum
- Add file.proto with FileInfo, FileUploadResponse, FileData
- Update Makefile to support all proto files with proper import mappings
- Remove bootstrap.proto (replaced by common.proto)
- Use google.protobuf.Struct for dynamic JSON fields (Post.props, Channel.props)
- All timestamps are int64 (milliseconds since epoch)
- All IDs are strings (26-char base32)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 11:06:42 -05:00
Nick Misasi
2e61b0e626 feat(01-01): add protobuf directory structure and bootstrap.proto
- Create server/public/pluginapi/grpc/proto/ for proto sources
- Create server/public/pluginapi/grpc/generated/go/ for generated Go code
- Add bootstrap.proto with Empty message for validating codegen pipeline
- Generate bootstrap.pb.go using protoc v6.33.4 / protoc-gen-go v1.36.6

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 10:59:17 -05:00