Skip to content

Commit f4fe47e

Browse files
nficanoclaude
andcommitted
docs: add YARD comments to public API surfaces
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 95276e6 commit f4fe47e

6 files changed

Lines changed: 29 additions & 0 deletions

File tree

lib/arcp/auth/auth_scheme.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
module Arcp
44
module Auth
5+
# Authenticated principal returned by an `AuthScheme`.
56
Principal = Data.define(:id, :name, :scopes)
67

78
# AuthScheme is an interface: implementations expose

lib/arcp/auth/bearer.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@
33
module Arcp
44
module Auth
55
# Static-token bearer verifier. Maps token strings to Principals.
6+
#
67
# For production, plug a custom verifier implementing
78
# `#verify(token) -> Principal | nil`.
89
class Bearer
910
include AuthScheme
1011

12+
# Build a bearer verifier from a token-to-principal map.
1113
def initialize(tokens: {})
1214
@tokens = tokens.dup.freeze
1315
end
1416

17+
# Verify a bearer token and return the associated principal.
1518
def verify(token)
1619
return nil if token.nil?
1720

@@ -30,6 +33,7 @@ def verify(token)
3033
end
3134
end
3235

36+
# Convenience constructor for a single accepted token.
3337
def self.from_token(token, principal_id: 'anonymous', scopes: [])
3438
new(tokens: { token => Principal.new(id: principal_id, name: principal_id, scopes: scopes.freeze) })
3539
end

lib/arcp/clock.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,40 @@
33
require 'time'
44

55
module Arcp
6+
# Clock abstraction used by the runtime and tests.
67
module Clock
78
module_function
89

10+
# Current monotonic time in seconds.
911
def monotonic = Process.clock_gettime(Process::CLOCK_MONOTONIC)
12+
# Current wall-clock time in UTC.
1013
def now = Time.now.utc
1114
end
1215

16+
# Real clock wrapper for components that need an object.
1317
class SystemClock
18+
# Current wall-clock time in UTC.
1419
def now = Time.now.utc
20+
# Current monotonic time in seconds.
1521
def monotonic = Process.clock_gettime(Process::CLOCK_MONOTONIC)
1622
end
1723

24+
# Deterministic clock used in tests.
1825
class FakeClock
1926
attr_accessor :now_value, :monotonic_value
2027

28+
# Start at a specific UTC instant and advance manually in tests.
2129
def initialize(now: Time.utc(2026, 1, 1))
2230
@now_value = now.utc
2331
@monotonic_value = 0.0
2432
end
2533

34+
# Current wall-clock time in UTC.
2635
def now = @now_value
36+
# Current monotonic time in seconds.
2737
def monotonic = @monotonic_value
2838

39+
# Advance both wall-clock and monotonic time by `seconds`.
2940
def advance(seconds)
3041
@now_value += seconds
3142
@monotonic_value += seconds

lib/arcp/envelope.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ def self.from_json(bytes)
7676
from_h(Arcp::Serializer.load(bytes))
7777
end
7878

79+
# @api private
7980
def self.deep_freeze(value)
8081
case value
8182
when Hash
@@ -97,6 +98,7 @@ def to_h
9798

9899
def to_json(*_args) = Arcp::Serializer.dump(to_h)
99100

101+
# @api private
100102
def stringify(value)
101103
case value
102104
when Hash then value.transform_keys(&:to_s).transform_values { |v| stringify(v) }
@@ -108,6 +110,7 @@ def stringify(value)
108110
def known? = Arcp::MessageTypes.known?(type)
109111
end
110112

113+
# @api private
111114
UnknownEnvelope = Data.define(:envelope) do
112115
def type = envelope.type
113116
def payload = envelope.payload

lib/arcp/errors.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def to_payload(trace_id: nil)
2121
payload
2222
end
2323

24+
# @api private
2425
def self.default_message = name.split('::').last.gsub(/([a-z])([A-Z])/, '\1 \2').downcase
2526
end
2627

lib/arcp/ids.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,25 @@
33
require 'securerandom'
44

55
module Arcp
6+
# Identifier helpers for protocol objects.
67
module Ids
78
module_function
89

10+
# @api private
911
def envelope_id = SecureRandom.uuid_v7
12+
# @api private
1013
def session_id = "ses_#{SecureRandom.uuid_v7}"
14+
# @api private
1115
def job_id = "job_#{SecureRandom.uuid_v7}"
16+
# @api private
1217
def result_id = "res_#{SecureRandom.uuid_v7}"
18+
# @api private
1319
def call_id = "call_#{SecureRandom.uuid_v7}"
20+
# @api private
1421
def resume_token = SecureRandom.urlsafe_base64(24)
22+
# @api private
1523
def trace_id = SecureRandom.hex(16)
24+
# @api private
1625
def span_id = SecureRandom.hex(8)
1726
end
1827
end

0 commit comments

Comments
 (0)