kosa8 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/kosa8/rl.rb CHANGED
@@ -274,6 +274,10 @@ module Kosa8
274
274
  @recorded = 0
275
275
  @status = nil
276
276
  @buf = []
277
+ # The chunk being sent and its Idempotency-Key, kept together until
278
+ # kosa8 Cloud answers: a later flush resends the same rows with the
279
+ # same key, so a send whose answer was lost is stored once.
280
+ @inflight = nil
277
281
  @buf_lock = Mutex.new
278
282
  @flush_lock = Mutex.new
279
283
  @lease = nil
@@ -352,15 +356,18 @@ module Kosa8
352
356
  sent = 0
353
357
  @flush_lock.synchronize do
354
358
  loop do
355
- chunk = @buf_lock.synchronize { @buf.shift(MAX_ROWS_PER_CALL) }
356
- return sent if chunk.empty?
357
-
358
- begin
359
- r = @cloud.request("POST", path("/rollouts"), { "rollouts" => chunk })
360
- rescue Exception # rubocop:disable Lint/RescueException
361
- @buf_lock.synchronize { @buf.unshift(*chunk) }
362
- raise
359
+ @buf_lock.synchronize do
360
+ if @inflight.nil?
361
+ rows = @buf.shift(MAX_ROWS_PER_CALL)
362
+ @inflight = [rows, SecureRandom.uuid] unless rows.empty?
363
+ end
363
364
  end
365
+ return sent if @inflight.nil?
366
+
367
+ chunk, key = @inflight
368
+ # On an error the chunk stays in flight with its key, for the next flush.
369
+ r = @cloud.request("POST", path("/rollouts"), { "rollouts" => chunk }, { idempotency_key: key })
370
+ @buf_lock.synchronize { @inflight = nil }
364
371
  n = r.is_a?(Hash) && r["recorded"].is_a?(Integer) ? r["recorded"] : chunk.size
365
372
  sent += n
366
373
  @recorded += n
@@ -370,7 +377,7 @@ module Kosa8
370
377
 
371
378
  # Rollouts buffered, not yet sent.
372
379
  def pending
373
- @buf_lock.synchronize { @buf.size }
380
+ @buf_lock.synchronize { @buf.size + (@inflight ? @inflight[0].size : 0) }
374
381
  end
375
382
 
376
383
  # The run with its summary (rewards, failure classes, live sandboxes,
data/lib/kosa8/toolbox.rb CHANGED
@@ -290,7 +290,8 @@ module Kosa8
290
290
  di = File.join(path, ".dockerignore")
291
291
  if File.exist?(di)
292
292
  ignore = File.readlines(di).reject { |l| l.strip.empty? || l.start_with?("#") }
293
- .map { |l| Pathname.new(l.strip).cleanpath.to_s }
293
+ .map { |l| Pathname.new(l.strip).cleanpath.to_s.sub(%r{\A/+}, "") } # "/build" is "build"
294
+ .reject { |l| l.empty? || l == "." }
294
295
  end
295
296
  skip = ->(rel) { ignore.any? { |p| rel == p || rel.start_with?(p + "/") } }
296
297
  io = StringIO.new(+"".b)
data/lib/kosa8/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kosa8
4
- VERSION = "0.6.0"
4
+ VERSION = "0.7.0"
5
5
  end
data/lib/kosa8.rb CHANGED
@@ -12,5 +12,6 @@ require_relative "kosa8/cloud"
12
12
  require_relative "kosa8/cloud_features"
13
13
  require_relative "kosa8/cloud_rl"
14
14
  require_relative "kosa8/cloud_more"
15
+ require_relative "kosa8/cloud_stream"
15
16
  require_relative "kosa8/fork_map"
16
17
  require_relative "kosa8/rl"
metadata CHANGED
@@ -1,23 +1,25 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kosa8
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - kosa8
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-11-22 00:00:00.000000000 Z
11
+ date: 2026-11-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: 'Typed client for the kosa8 daemon: sandboxes, run/exec streams, snapshots,
14
- fork, best-of-N explore and checkpoints shared with the kosa8 CLI, plus the kosa8
15
- Cloud API. No dependencies.'
13
+ description: 'Zero Trust cybersecurity infrastructure for AI agents: each agent in
14
+ its own microVM. Typed client for the kosa8 daemon: sandboxes, run/exec streams,
15
+ snapshots, fork, best-of-N explore and checkpoints shared with the kosa8 CLI, plus
16
+ the kosa8 Cloud API. No dependencies.'
16
17
  email:
17
18
  executables: []
18
19
  extensions: []
19
20
  extra_rdoc_files: []
20
21
  files:
22
+ - CHANGELOG.md
21
23
  - LICENSE
22
24
  - README.md
23
25
  - lib/kosa8.rb
@@ -27,6 +29,7 @@ files:
27
29
  - lib/kosa8/cloud_features.rb
28
30
  - lib/kosa8/cloud_more.rb
29
31
  - lib/kosa8/cloud_rl.rb
32
+ - lib/kosa8/cloud_stream.rb
30
33
  - lib/kosa8/errors.rb
31
34
  - lib/kosa8/fork_map.rb
32
35
  - lib/kosa8/rl.rb
@@ -37,7 +40,11 @@ homepage: https://kosa8.com
37
40
  licenses:
38
41
  - MIT
39
42
  metadata:
43
+ homepage_uri: https://kosa8.com
40
44
  source_code_uri: https://github.com/kosa8ai/kosa8-rb
45
+ changelog_uri: https://github.com/kosa8ai/kosa8-rb/blob/main/CHANGELOG.md
46
+ bug_tracker_uri: https://github.com/kosa8ai/kosa8-rb/issues
47
+ documentation_uri: https://docs.kosa8.com
41
48
  post_install_message:
42
49
  rdoc_options: []
43
50
  require_paths:
@@ -56,5 +63,5 @@ requirements: []
56
63
  rubygems_version: 3.0.3.1
57
64
  signing_key:
58
65
  specification_version: 4
59
- summary: 'Ruby SDK for kosa8: microVM sandboxes for AI agents'
66
+ summary: 'Zero Trust cybersecurity infrastructure for AI agents: the kosa8 Ruby SDK'
60
67
  test_files: []