Skip to content

Commit 38ce0ce

Browse files
committed
examples: 14 ARCP-primitive samples translated from python-sdk
1 parent ce34354 commit 38ce0ce

49 files changed

Lines changed: 2612 additions & 284 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

samples/.rubocop.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Sample files demonstrate end-to-end protocol flows and intentionally
2+
# keep all of the protocol code in one place. Relax the per-sample
3+
# metric ceilings so reviewers see the wire shape, not seven helper
4+
# methods.
5+
inherit_from: ../.rubocop.yml
6+
7+
AllCops:
8+
Exclude: []
9+
10+
Metrics/MethodLength:
11+
Max: 60
12+
Metrics/BlockLength:
13+
Max: 60
14+
Metrics/AbcSize:
15+
Max: 60
16+
Metrics/CyclomaticComplexity:
17+
Max: 16
18+
Metrics/PerceivedComplexity:
19+
Max: 16
20+
Metrics/ParameterLists:
21+
Max: 8
22+
23+
Style/Documentation:
24+
Enabled: false
25+
Style/ClassAndModuleChildren:
26+
Enabled: false
27+
Lint/ScriptPermission:
28+
Enabled: false

samples/01_minimal_session.rb

Lines changed: 0 additions & 36 deletions
This file was deleted.

samples/02_tool_invoke_with_progress.rb

Lines changed: 0 additions & 43 deletions
This file was deleted.

samples/03_human_input_request.rb

Lines changed: 0 additions & 42 deletions
This file was deleted.

samples/04_permission_challenge.rb

Lines changed: 0 additions & 45 deletions
This file was deleted.

samples/05_observer_subscription.rb

Lines changed: 0 additions & 62 deletions
This file was deleted.

samples/06_relay_human_in_the_loop.rb

Lines changed: 0 additions & 56 deletions
This file was deleted.

samples/README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# ARCP Ruby SDK Samples
2+
3+
Numbered short samples (`01_*``06_*`) live alongside fourteen
4+
single-purpose sample directories, each named for the protocol
5+
primitive it demonstrates.
6+
7+
> **Illustrative, not runnable.** Each example imports `arcp` as if
8+
> it were a published gem. Setup boilerplate (transport URL,
9+
> identity, auth) is elided as `client = nil # ARCPClient(...)`. LLM
10+
> and framework calls live in tiny stub modules so the protocol code
11+
> in `main.rb` is what you read.
12+
13+
## The fourteen primitives
14+
15+
| Directory | Demonstrates | Spec |
16+
|---|---|---|
17+
| [`subscriptions/`](./subscriptions) | Three Observer clients on one session, three filters, three sinks. | §5, §13 |
18+
| [`leases/`](./leases) | Lease-gated shell agent. Reads coarse, writes scoped. | §15.4–§15.5 |
19+
| [`lease_revocation/`](./lease_revocation) | Per-table leases with `lease.revoked` / `lease.extended` mid-flight. | §15.5 |
20+
| [`permission_challenge/`](./permission_challenge) | Two-party permission challenge — generator asks, reviewer holds veto. | §15.4, §6.4 |
21+
| [`delegation/`](./delegation) | `agent.delegate` fan-out + `JobMux` to demux events by `job_id`. | §14, §6.4 |
22+
| [`handoff/`](./handoff) | `agent.handoff` with transcript packed as artifact, runtime fingerprint pinned. | §14, §16, §8.3 |
23+
| [`heartbeats/`](./heartbeats) | Worker federation; heartbeat-loss reroute via `idempotency_key`. | §10.3, §6.4 |
24+
| [`capability_negotiation/`](./capability_negotiation) | Capability-driven peer routing; standard `cost.usd` rollups. | §7, §17.3.1, §18.3 |
25+
| [`resumability/`](./resumability) | Real crash and resume via `Process.exit!` + `resume` envelope. | §10, §19, §6.4 |
26+
| [`reasoning_streams/`](./reasoning_streams) | `kind: thought` stream + a peer runtime that subscribes and delegates critiques back. | §11.4, §13, §14 |
27+
| [`extensions/`](./extensions) | Custom `arcpx.sdr.*.v1` namespace with correct unknown-message handling. | §21 |
28+
| [`human_input/`](./human_input) | `human.input.request` fanned across phone/email/Slack; first-wins resolution. | §12 |
29+
| [`cancellation/`](./cancellation) | Cooperative `cancel` (terminate) vs `interrupt` (pause and ask). | §10.4–§10.5 |
30+
| [`mcp/`](./mcp) | ARCP runtime fronting an MCP server: `tool.invoke` → MCP `call_tool`. | §20 |
31+
32+
## Conventions
33+
34+
- Ruby 3.4+, `# frozen_string_literal: true` on every file, single
35+
quotes per repo `.rubocop.yml`.
36+
- Each example is one `main.rb` (the protocol code) + 0–2 stub
37+
modules named for what they elide (`agents.rb`, `steps.rb`,
38+
`cheap.rb`, `synth.rb`, `work.rb`, `channels.rb`, `sql.rb`,
39+
`upstream.rb`, `sinks/*.rb`).
40+
- `client = nil # ARCPClient(...)` literally — transport, identity,
41+
and auth are setup noise, not the point.
42+
- Envelopes match RFC-0001 v2 exactly. Custom message types follow
43+
§21.1 `arcpx.<domain>.<name>.v<n>` naming.
44+
- `Async {}` blocks for concurrency, `case/in` pattern matching for
45+
envelope dispatch, `Data.define` for value objects.
46+
47+
## What's where in the SDK
48+
49+
- `Arcp::Client::Client` — handshake driver.
50+
- `Arcp::Envelope.build(type:, payload:, ...)` — envelope minting.
51+
- `Arcp::Envelope`, `Arcp::ErrorCode`, `Arcp::Error` — wire primitives.
52+
- `Arcp::Transport::WebSocket` / `Arcp::Transport::Memory` — transports.
53+
- `Arcp::Store::EventLog` — SQLite schema reused by `subscriptions`.
54+
55+
## Reading order
56+
57+
For a brisk tour: `subscriptions`, `leases`, `delegation`,
58+
`resumability` (this one actually crashes and recovers),
59+
`cancellation`, `extensions`, `mcp`. These seven exercise the bulk
60+
of the protocol.

0 commit comments

Comments
 (0)