CAP Cordum Agent Protocol Code
The Open Standard for Secure AI Agent Orchestration.
Brought to you by:
cordum111
context_ptr and result_ptr so the bus stays lean and secure.| Component | Version | Notes |
|---|---|---|
| Protocol wire schema | 1.0.0 | Append-only evolution; never renumber fields. |
| Repo / SDKs | 2.0.16 | Go/Python/Node/C++ SDKs and docs; pinned by tag. |
protocol_version field |
1 | Used in BusPacket for negotiation. |
flowchart LR
Client --> Gateway -->|"BusPacket{JobRequest}"| Submit["sys.job.submit"]
Submit --> Scheduler
Scheduler -->|"policy check"| Safety
Scheduler -->|"dispatch"| Pool["job.<pool>"]
Pool --> Worker
Worker -->|"write"| Memory[(result_ptr)]
Worker -->|"BusPacket{JobResult}"| Result["sys.job.result"]
Result --> Scheduler --> Client
sequenceDiagram
participant Client
participant API as API Gateway
participant Bus as Bus (pub/sub)
participant Safety as Safety Kernel
participant Sched as Scheduler
participant Worker as Worker Pool
participant Redis as Memory (ctx/res)
Client->>Redis: write ctx:<job_id>
Client->>API: request submission
API->>Bus: BusPacket{JobRequest} -> sys.job.submit
Bus->>Sched: JobRequest
Sched->>Safety: PolicyCheck(job_id, topic, tenant)
Safety-->>Sched: decision
Sched->>Bus: dispatch -> job.<pool>
Bus->>Worker: JobRequest (queue group)
Worker->>Redis: read context_ptr
Worker->>Redis: write result_ptr
Worker->>Bus: BusPacket{JobResult} -> sys.job.result
Bus->>Sched: JobResult (state update)
Sched-->>Client: status/result via API
JobRequest (submit) + JobResult (complete), with workflow metadata (workflow_id, parent_job_id, step_index).context_ptr, result_ptr, redacted_context_ptr keep the bus free of blobs.progress_pct, last_memo) for long tasks.JobRequest to support durable rollback.PENDING -> SCHEDULED -> DISPATCHED -> RUNNING -> {SUCCEEDED|FAILED|FAILED_RETRYABLE|FAILED_FATAL|TIMEOUT|DENIED|CANCELLED}.Canonical protobuf definitions live under proto/cordum/agent/v1/:
- buspacket.proto — envelope and payload selection.
- job.proto — job request/result messages and enums.
- heartbeat.proto — liveness and capacity signals.
- safety.proto — Safety Kernel gRPC surface.
- alert.proto — lightweight system alerts.
- BusPacket.signature — optional digital signature for authenticity; SDK helpers sign/verify envelopes when provided keys.
examples/simple-echo/ — smallest possible job submission + result with bus messages and sequence (Go/Python/Node).examples/workflow-repo-review/ — parent/child workflow with aggregation.examples/heartbeat.json — standalone heartbeat sample.examples/README.md — quick pointers to all flows.package main
import (
"log"
agentv1 "github.com/cordum-io/cap/v2/cordum/agent/v1"
"github.com/nats-io/nats.go"
"google.golang.org/protobuf/proto"
)
func main() {
// Connect to a NATS server.
nc, _ := nats.Connect("nats://127.0.0.1:4222")
defer nc.Drain()
// Subscribe to the "job.echo" subject and join the "job.echo" queue group.
_, _ = nc.QueueSubscribe("job.echo", "job.echo", func(msg *nats.Msg) {
// Unmarshal the received message into a BusPacket.
var pkt agentv1.BusPacket
_ = proto.Unmarshal(msg.Data, &pkt)
// Get the JobRequest from the packet.
req := pkt.GetJobRequest()
// Create a JobResult.
res := &agentv1.JobResult{
JobId: req.GetJobId(),
Status: agentv1.JobStatus_JOB_STATUS_SUCCEEDED,
ResultPtr: "redis://res/" + req.GetJobId(),
WorkerId: "echo-1",
}
// Create the response BusPacket.
out, _ := proto.Marshal(&agentv1.BusPacket{
TraceId: pkt.GetTraceId(),
SenderId: "echo-1",
ProtocolVersion: 1,
Payload: &agentv1.BusPacket_JobResult{JobResult: res},
})
// Publish the response.
_ = nc.Publish("sys.job.result", out)
})
// Block forever.
select {}
}
spec/ - normative spec: envelopes, jobs, pointers, heartbeats, safety, state, workflows, transport, security.proto/ - protobuf contracts (copy/paste ready).examples/ - JSON and sequence flows for common scenarios.tools/ - helper scripts for proto generation (optional).sdk/ - starter SDKs for Go, Python, Node/TS, and C++ with NATS helpers.cordum/ - Go protobuf stubs (import path github.com/cordum-io/cap/v2/cordum/agent/v1).python/ - Python protobuf stubs (enable with CAP_RUN_PY=1).cpp/ - C++ protobuf stubs (vendored headers/sources).node/ - Node JS protobuf stubs (CommonJS, binary wire format).github.com/cordum-io/cap/v2 (see go.mod).protocol_version (currently 1) is used for negotiation; tag releases when message shapes change.CONTRIBUTING.md for workflow and style guidance.BusPacket envelopes with stable trace_id across workflows and children.context_ptr, result_ptr, and redacted_context_ptr.JobRequest with workflow links (workflow_id, parent_job_id, step_index) when fanning out.sys.heartbeat with pool/region and capacity.job_id + pointers.Apache-2.0 (LICENSE).