Claude adapter + registry + Hub.Ingest / Handler - #1
Merged
Merged
Conversation
Wire the first real adapter end-to-end. POSTing a Claude hook body to
/hook/claude now produces an Event on Hub.Events().
Core
- Signal.Raw + Event.Raw plumbing (decision.go, hub.go, design.md).
- Adapter struct, RegisterAdapter, Adapters, lookupAdapter, InstallConfig,
InstallResult, AllAgents, ErrUnknownAgent (adapter.go).
- Hub.Ingest, Hub.Handler (POST /hook/{agent}, 202/400/404/405/413/500),
Hub.ServeHTTP, 1 MiB body cap (hub.go).
Claude adapter
- Self-registers from init(); MapHookEvent covers every row in
design.md's Claude table. Install/uninstall stubbed pending next ticket.
- Subagent identity follows the official schema: SessionID = agent_id,
ParentSessionID = session_id (Claude fires Subagent* under the parent).
Tests
- adapters/claude/map_test.go: per-row mapping + timestamp + tolerance.
- adapter_test.go: registry duplicate / empty / sorted snapshot / concurrent.
- hub_ingest_test.go: E2E HTTP — happy path, 404/400/413/405, unknown
event drop, PreCompact drop, subagent flow, 1000-concurrent ingest.
- testdata/claude/*.json fixtures mirror real Claude payload shape.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
POST /hook/claude→EventonHub.Events().Adapter+ registry,Hub.Ingest/Handler/ServeHTTP, andSignal.Raw→Event.Rawplumbing.specs/design.md's mapping table; install/uninstall stubbed for the next ticket (Skipped: true).SessionID = agent_id,ParentSessionID = session_id.Test plan
go vet ./...go test -race ./...(registry, claude map per row, full HTTP integration including 1000-concurrent ingest)golangci-lint runcurl -X POST -d @testdata/claude/stop.json http://localhost:9090/hook/claudeproducesEvent{Status: idle}on the stream.Follow-up flagged
Per the official Claude hooks reference,
agent_idis added to every hook fired inside a subagent (not justSubagentStart/SubagentStop). Today we only remap session ids on those two events. To match design.md's "subagents are independent sessions" model, the remap (SessionID = agent_id,ParentSessionID = session_id) should be promoted to a default rule wheneveragent_idis non-empty. Deliberately deferred to its own ticket so this PR stays scoped to the design table.