kairos-chain 3.100.1 → 3.102.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 24804af6b77d713c59b70054018eb85af6a664629e5295654c06862304b18b63
4
- data.tar.gz: 1b1e0bad26fc0464a31ee2d58d8599f059aaad8259fc1e34dce5aa771c7ff196
3
+ metadata.gz: f92cefb68006ad142c4c25bf42b56118408706706c594dd277fbcc011166b355
4
+ data.tar.gz: 874c9a039bcefa99c681edef56738e078977df4db5db6def05b1594cebe32106
5
5
  SHA512:
6
- metadata.gz: 639b82daa0ae8ec3f95c82d3d2a899829c8ab83f2eda6b515df7b7d22141190780f4acd553f5b5eb1fa228018eb2298be124e25c4bfa75c14abe77013f3d2447
7
- data.tar.gz: 3cf1ebca7a67c0aaa532b4355ffcee0d10b78c9899c78e2f677ea1aba3f7af6b0c134c3cf163ea08003dc653a17539219161da982876633c2299edbc2c515677
6
+ metadata.gz: ffa02e574a2d88a867a32bf09924e4d19dccd68eda6a2e7bccd053385f2770b53a1c5e72301fb0f36acb899540aa04df21e0ba964b4c2f3d7b627eac188f2422
7
+ data.tar.gz: 4e99bc88884fa32696047393de4186e29f9d8f6c5a5972307e46a7dad90904458bd63947bbb5f6d335363cac41fb651e3e625fb076926aa8550b4819e5602535
data/CHANGELOG.md CHANGED
@@ -6,6 +6,88 @@ This project follows [Semantic Versioning](https://semver.org/).
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [3.102.0] - 2026-11-20
10
+
11
+ ### Added — llm_client 0.5.0: provider `antigravity` (the Antigravity CLI, `agy`)
12
+
13
+ - New llm_client provider `antigravity` (`AntigravityAdapter`) drives `agy`. The prompt goes to stdin
14
+ as one stream-json line, because `agy -p` takes the prompt only as its own argument. The call runs
15
+ under a per-call agent definition whose tool allowlist is empty (the only guard that removes web
16
+ search), with session settings that deny all seven permission actions under strict permission mode,
17
+ and with `--sandbox` and slash commands off. Plan mode is not used: it injects the /plan procedure
18
+ and wrote plan files under `~/.gemini/antigravity-cli/brain/`. Success requires exit 0 and a
19
+ `result` event with status SUCCESS and a non-empty response, since a turn whose tool was auto-denied
20
+ exits 0 with nothing said. On every run, before success is judged, a reply is refused unless the
21
+ session reports this call's agent (a random name per call) and strict permission mode, and every
22
+ tool step's last state is the CLI's own permission refusal (a tool that completed, failed after
23
+ running or never reported an outcome, and any unrecognised step or event, refuse the reply).
24
+ Measured: outside read, shell fetch, web search and a 100 KB prompt. **Not yet measured: the write
25
+ probe.** No `model_observed` is returned: the CLI's init event names a model before any model has
26
+ answered.
27
+ - agy keeps every turn on disk under `~/.gemini/antigravity-cli/` and no setting turns that off, so
28
+ whatever is sent through this provider persists there.
29
+ - **The default multi_llm_review roster is unchanged.** No seat uses this provider unless an
30
+ instance's own config names it.
31
+ - Review state: three multi-LLM review rounds (2026-11-15 to 2026-11-18). The fixes for the round-3
32
+ blocking finding (a tool step left active passed the after-run check) have not been re-reviewed.
33
+ - Not changed: core `Capability::EXTERNAL_BINARIES` does not name `agy`, so the capability manifest
34
+ under-reports this dependency.
35
+ - Upgrade note: `kairos-chain upgrade` overwrites an installed SkillSet whose files differ from the
36
+ gem's, whatever the two versions are (only `config/` is left alone). An instance that carried
37
+ llm_client 0.5.0 ahead of the gem was put back to 0.4.0 by the 3.100.1 and 3.101.0 upgrades; from
38
+ this release the two are equal. The upgrade itself is not changed.
39
+
40
+ ## [3.101.0] - 2026-11-20
41
+
42
+ ### Added — succession edges on the L2 save path; dream 0.4.0 digests read them, label membership and record checks
43
+
44
+ Implements dream_digest design v0.13. First use of dream_digest (0.3.0) showed three ways a digest could
45
+ misstate its sources: a change of mind read as a disagreement, a digest calling itself fresh while its
46
+ topic had grown, and no reader but its writer.
47
+
48
+ - **Core: succession edges.** An L2 node declares that it replaces or corrects an earlier L2 node in its
49
+ own frontmatter: `relations: [{type: replaces | corrects, target: "v1:<session_id>/<name>", part:
50
+ <optional>, grounds: {quote, by} | {contradicted_by}}]`. An edge is valid when it carries grounds and
51
+ its formal target exists (a soft-archived node exists). `ContextGraph.succession_edge_failures` states
52
+ the two conditions once, for the save path and for any reader. **`context_save` now refuses a save
53
+ whose `replaces` / `corrects` edge fails either one**, stores nothing and returns the reason; the
54
+ writer may save the node without the edge. Saves that declare no such edge are untouched, and
55
+ `informed_by` may still point forward. Other relation types, `supersedes` included, stay accepted and
56
+ declare no succession. A writer holds names and an edge stores only the formal form:
57
+ `ContextManager#formal_targets_for(name)` lists the nodes that bear a name, and a refusal for a missing
58
+ target names them.
59
+ - **dream 0.4.0 — what a digest reads.** The READ set is the selected nodes closed under succession: a
60
+ node that declares succession over a member is a member whether or not it carries the topic's tag, and
61
+ so is the target of a member's valid edge. The generation directive lists the declared edges as data,
62
+ states a replacement only where a valid edge declares one, does not compose edges, and labels every
63
+ other difference between sources as date-only. Selection by tag no longer aborts on a node whose
64
+ frontmatter does not parse. A soft-archive stub keeps the relations its node declared.
65
+ - **dream 0.4.0 — labels.** `read` evaluates two independent conditions now, for the caller, and stores
66
+ neither: drift (a source changed) and membership (the recorded selection rule, applied again and
67
+ closed, against the snapshot). A digest made from an explicit list, a node whose relations cannot be
68
+ read, and a store not read in full are membership-unknown, never fresh. Pass the `selection_rule`
69
+ that `package` and `refresh` return on to `write`.
70
+ - **dream 0.4.0 — events and checks.** A generation and a check are events in an append-only,
71
+ hash-chained log per topic (`dream/digest_events/<slug>.jsonl`), apart from the artifact. The latest
72
+ generation event of a topic is its current one; labels are given only to stored text whose hash is its
73
+ output hash, and other stored text is not shown. New modes `check_package` and `check` let a context
74
+ other than the author compare a digest with its sources. A check counts only when both identities were
75
+ supplied by the invoking layer (an authenticated HTTP user), they differ, and the text compared is the
76
+ generation's output; a check of other text is recorded and listed on no label. Over stdio no identity
77
+ is supplied, so checks are recorded and listed and none counts. New mode `targets` turns a node name
78
+ into formal targets.
79
+ - **dream 0.4.0 — access.** Nodes resolve under the roots core gives the caller's user context. A caller
80
+ that cannot read the whole READ set of a topic's current generation gets the reply a topic with no
81
+ digest gets, from every mode. A write whose snapshot names a source that no longer resolves is refused.
82
+ - **Upgrade notes.** A digest written by dream 0.3.0 has no generation event: it is not shown, and
83
+ `sweep` reports it for regeneration. The blockchain block of a digest event is now
84
+ `dream_digest_event` with the event id alone (was `dream_digest_generation` with the provenance
85
+ refs). dream 0.4.0 needs this core (`min_core_version` 3.101.0).
86
+ - Reviewed in two implementation-review rounds by nine seats; one blocking finding in round 1 (a write
87
+ that dropped a vanished source recorded too narrow an access scope), fixed, none in round 2. Left
88
+ open: a source edited between `package` and `write` is recorded with its new hash; the event log is
89
+ never compacted; a topic name is one namespace across user contexts.
90
+
9
91
  ## [3.100.1] - 2026-11-18
10
92
 
11
93
  ### Changed — multi_llm_review codex seat moves to gpt-6.2-astra
@@ -25,6 +25,11 @@ module KairosMcp
25
25
  # (forward-compat) but skipped on traverse.
26
26
  KNOWN_TYPES = %w[informed_by].freeze
27
27
 
28
+ # Succession edges: an L2 node declares that it replaces or corrects another L2 node,
29
+ # wholly or in a named part. The edge is held by the node that replaces. Any other type
30
+ # name, and any mark kept outside relations[], declares no succession.
31
+ SUCCESSION_TYPES = %w[replaces corrects].freeze
32
+
28
33
  # Target canonical regex (v2.1 §2). Permissive enough to reference both
29
34
  # canonical session_ids (session_<8>_<6>_<8hex>) and the human-readable
30
35
  # forms already on disk (e.g. coaching_insights_20260327, received_skills).
@@ -58,6 +63,7 @@ module KairosMcp
58
63
  class SymlinkRejectedError < Error; end
59
64
  class PathResolutionError < Error; end
60
65
  class InvalidFrontmatterError < Error; end
66
+ class SuccessionRefusedError < Error; end
61
67
 
62
68
  module_function
63
69
 
@@ -150,6 +156,43 @@ module KairosMcp
150
156
  nil
151
157
  end
152
158
 
159
+ # True if a relations[] item is a succession edge.
160
+ def succession_edge?(item)
161
+ item.is_a?(Hash) && SUCCESSION_TYPES.include?(item['type'] || item[:type])
162
+ end
163
+
164
+ # The two conditions under which a succession edge is valid: it carries grounds, and its
165
+ # target, written in the formal form, exists under context_root (a soft-archived node
166
+ # exists). The same two are evaluated when a node is saved and whenever the edge is read;
167
+ # both callers use this method, each with its own context_root and at its own time.
168
+ #
169
+ # @return [Array<Symbol>] the conditions that fail (:no_grounds, :target_missing); [] = valid
170
+ def succession_edge_failures(item, context_root)
171
+ failures = []
172
+ failures << :no_grounds unless succession_grounds?(item['grounds'] || item[:grounds])
173
+ failures << :target_missing unless succession_target_exists?(item['target'] || item[:target], context_root)
174
+ failures
175
+ end
176
+
177
+ # Grounds are what made the change: the words, quoted, and whose words they are; or, for a
178
+ # correction of fact, a reference to the node that contradicts the replaced one. Their
179
+ # presence is checked. Whether quoted words were said, and whether a reference resolves,
180
+ # is not.
181
+ def succession_grounds?(grounds)
182
+ return false unless grounds.is_a?(Hash)
183
+
184
+ present = ->(key) { v = grounds[key] || grounds[key.to_sym]; v.is_a?(String) && !v.strip.empty? }
185
+ (present.call('quote') && present.call('by')) || present.call('contradicted_by')
186
+ end
187
+
188
+ # True if the target names a node that exists under context_root. A target that is
189
+ # malformed, dangling, or that cannot be resolved does not exist for this caller.
190
+ def succession_target_exists?(target, context_root)
191
+ resolve_target(target, context_root)[:status] == :ok
192
+ rescue Error
193
+ false
194
+ end
195
+
153
196
  # Recursively check that a value tree contains only SAFE_VALUE_TYPES.
154
197
  # Bounded by MAX_VALUE_NESTING to prevent SystemStackError from
155
198
  # pathological frontmatter input.
@@ -146,6 +146,26 @@ module KairosMcp
146
146
  target = item['target'] || item[:target]
147
147
  ContextGraph.resolve_target(target, @context_dir)
148
148
  end
149
+
150
+ refuse_failing_succession_edges!(relations)
151
+ end
152
+
153
+ # Formal targets (v1:<session id>/<name>) of every node under this manager's context root
154
+ # that bears the given name. A writer holds names; an edge stores only the formal form,
155
+ # which names one node.
156
+ #
157
+ # @param name [String] a context name
158
+ # @return [Array<String>] sorted formal targets; [] if the name is not a safe segment
159
+ def formal_targets_for(name)
160
+ return [] unless segments?(name)
161
+
162
+ session_dirs.filter_map do |session_dir|
163
+ node_file = File.join(session_dir, name, "#{name}.md")
164
+ next unless contained?(node_file) && File.file?(node_file)
165
+
166
+ target = "v1:#{File.basename(session_dir)}/#{name}"
167
+ target if ContextGraph.parse_target(target)
168
+ end.sort
149
169
  end
150
170
 
151
171
  # Delete a context
@@ -248,6 +268,46 @@ module KairosMcp
248
268
 
249
269
  private
250
270
 
271
+ # A save whose succession edge fails either validity condition is refused and stores
272
+ # nothing. Evaluated from what is on disk now, under this manager's context root (the
273
+ # saving principal's). Only succession edges are looked at, so a node that declares none
274
+ # is never refused here. Reading an edge evaluates the same conditions again and decides;
275
+ # this refusal anticipates that evaluation and does not replace it.
276
+ #
277
+ # @raise ContextGraph::SuccessionRefusedError
278
+ def refuse_failing_succession_edges!(relations)
279
+ relations.each_with_index do |item, idx|
280
+ next unless ContextGraph.succession_edge?(item)
281
+
282
+ failures = ContextGraph.succession_edge_failures(item, @context_dir)
283
+ next if failures.empty?
284
+
285
+ type = item['type'] || item[:type]
286
+ target = item['target'] || item[:target]
287
+ reasons = []
288
+ if failures.include?(:no_grounds)
289
+ reasons << 'it carries no grounds (grounds.quote with grounds.by, or grounds.contradicted_by)'
290
+ end
291
+ if failures.include?(:target_missing)
292
+ reasons << "its target #{target} does not exist#{formal_target_hint(target)}"
293
+ end
294
+ raise ContextGraph::SuccessionRefusedError,
295
+ "relations[#{idx}] (#{type}) is refused: #{reasons.join('; ')}. Nothing was stored. " \
296
+ 'Correct the edge, or save the node without it.'
297
+ end
298
+ end
299
+
300
+ # For a refused target: the nodes that do bear its name, so the writer can pick one.
301
+ def formal_target_hint(target)
302
+ name = ContextGraph.parse_target(target)&.fetch(:name)
303
+ candidates = name ? formal_targets_for(name) : []
304
+ return '' if candidates.empty?
305
+
306
+ shown = candidates.first(10)
307
+ more = candidates.size > shown.size ? " (#{candidates.size - shown.size} more)" : ''
308
+ " (nodes named #{name}: #{shown.join(', ')}#{more})"
309
+ end
310
+
251
311
  # True if a path built from a caller-supplied session_id / name still
252
312
  # resolves inside the context store.
253
313
  def contained?(path)
@@ -12,7 +12,11 @@ module KairosMcp
12
12
  end
13
13
 
14
14
  def description
15
- 'Save (create or update) a L2 context. No blockchain recording - free modification for temporary work.'
15
+ 'Save (create or update) a L2 context. No blockchain recording - free modification for temporary work. ' \
16
+ 'A node that replaces or corrects an earlier L2 node says so in its own frontmatter: ' \
17
+ 'relations: [{type: replaces|corrects, target: "v1:<session_id>/<name>", part: <optional>, ' \
18
+ 'grounds: {quote: <the words>, by: <whose words>} or {contradicted_by: <node>}}]. ' \
19
+ 'A save whose such edge has no grounds or names a node that does not exist is refused.'
16
20
  end
17
21
 
18
22
  def category
@@ -1,4 +1,4 @@
1
1
  module KairosMcp
2
- VERSION = "3.100.1"
2
+ VERSION = "3.102.0"
3
3
  CHANGELOG_URL = "https://github.com/masaomi/KairosChain_2026/blob/main/CHANGELOG.md"
4
4
  end
@@ -3,6 +3,7 @@
3
3
  require 'digest'
4
4
  require 'fileutils'
5
5
  require 'yaml'
6
+ require 'date'
6
7
  require 'zlib'
7
8
  require 'time'
8
9
 
@@ -349,6 +350,11 @@ module KairosMcp
349
350
  'has_references' => has_references,
350
351
  'summary' => summary
351
352
  }
353
+ # The edges a node declares are part of what it states to the context graph. A stub
354
+ # that dropped them would withdraw, by archiving, a succession the node declared.
355
+ %w[relations_schema relations].each do |key|
356
+ frontmatter[key] = original_meta[key] if original_meta.key?(key)
357
+ end
352
358
 
353
359
  includes = []
354
360
  includes << 'scripts/' if has_scripts
@@ -388,8 +394,11 @@ module KairosMcp
388
394
  # ---------------------------------------------------------------
389
395
 
390
396
  def extract_frontmatter(content)
391
- if content =~ /\A---\n(.*?)\n---/m
392
- YAML.safe_load($1, permitted_classes: [Symbol]) || {}
397
+ # Date and Time are permitted, as on the save path: a node with a date in its
398
+ # frontmatter must not read as empty here, or its stub would lose what it declares.
399
+ if content =~ /\A---\r?\n(.*?)\r?\n---/m
400
+ meta = YAML.safe_load($1, permitted_classes: [Symbol, Date, Time])
401
+ meta.is_a?(Hash) ? meta : {}
393
402
  else
394
403
  {}
395
404
  end
@@ -0,0 +1,160 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'digest'
4
+ require 'fileutils'
5
+ require 'json'
6
+ require 'time'
7
+
8
+ module KairosMcp
9
+ module SkillSets
10
+ module Dream
11
+ # DigestEvents — the generation and check events of dream_digest (design v0.13, I7).
12
+ #
13
+ # One append-only log per topic, kept apart from the digest artifact: the artifact is
14
+ # derived and may be deleted or regenerated without losing an event. An event is one
15
+ # line. The store, not the caller, sets what orders and identifies it: `seq`, `prev`
16
+ # (the id of the event before it), `recorded_at`, and `id`, the hash of everything else
17
+ # in the line. A log in which any line fails that chain is not read at all.
18
+ #
19
+ # This class has no method that changes or removes an event. It cannot stop a process
20
+ # with write access to the data directory from replacing the file; the chain makes a
21
+ # partial rewrite detectable, and the id anchored on the instance's blockchain by the
22
+ # tool makes a whole one detectable by audit. Labels do not consult the anchor.
23
+ class DigestEvents
24
+ class CorruptError < StandardError; end
25
+
26
+ # A verified log, oldest event first.
27
+ class Log
28
+ attr_reader :events
29
+
30
+ def initialize(events)
31
+ @events = events
32
+ end
33
+
34
+ # The latest generation event recorded for the topic: the same event for every reader.
35
+ def current_generation
36
+ @events.reverse_each.find { |e| e['kind'] == 'generation' }
37
+ end
38
+
39
+ def generation(id)
40
+ @events.find { |e| e['kind'] == 'generation' && e['id'] == id }
41
+ end
42
+
43
+ def checks_naming(generation_id)
44
+ @events.select { |e| e['kind'] == 'check' && e['generation'] == generation_id }
45
+ end
46
+ end
47
+
48
+ def initialize(base_dir)
49
+ @base_dir = base_dir
50
+ end
51
+
52
+ # Topic slugs that have a log.
53
+ def slugs
54
+ return [] unless Dir.exist?(@base_dir)
55
+
56
+ Dir.children(@base_dir).filter_map { |f| f[/\A([a-z0-9_]+)\.jsonl\z/, 1] }.sort
57
+ end
58
+
59
+ # @return [Log] empty when the topic has no log
60
+ # @raise [CorruptError] when the log does not verify
61
+ def load(slug)
62
+ path = path_for(slug)
63
+ return Log.new([]) unless File.exist?(path)
64
+
65
+ Log.new(verified(complete_lines(File.read(path, encoding: 'UTF-8'))))
66
+ end
67
+
68
+ # Append one event. The block receives the verified log as it stands under the lock and
69
+ # returns the event's fields; raising in the block appends nothing.
70
+ #
71
+ # @return [Hash] the event as recorded
72
+ def append(slug)
73
+ FileUtils.mkdir_p(@base_dir)
74
+ File.open(path_for(slug), File::RDWR | File::CREAT, 0o600, encoding: 'UTF-8') do |f|
75
+ f.flock(File::LOCK_EX)
76
+ lines = complete_lines(f.read)
77
+ events = verified(lines)
78
+ fields = yield Log.new(events)
79
+
80
+ event = seal(fields, seq: events.size + 1, prev: events.last && events.last['id'])
81
+ # A fragment left by an append that never completed was never an event; the next
82
+ # event starts where the last complete one ends.
83
+ kept = lines.sum { |l| l.bytesize + 1 }
84
+ f.truncate(kept)
85
+ f.seek(kept)
86
+ f.write("#{JSON.generate(event)}\n")
87
+ f.flush
88
+ f.fsync
89
+ event
90
+ end
91
+ end
92
+
93
+ private
94
+
95
+ def path_for(slug)
96
+ raise ArgumentError, "not a topic slug: #{slug.inspect}" unless slug.to_s.match?(/\A[a-z0-9_]+\z/)
97
+
98
+ File.join(@base_dir, "#{slug}.jsonl")
99
+ end
100
+
101
+ # Lines terminated by a newline. Bytes after the last newline are an append that did
102
+ # not complete.
103
+ def complete_lines(raw)
104
+ raw = raw.to_s
105
+ cut = raw.rindex("\n")
106
+ cut ? raw[0..cut].split("\n") : []
107
+ end
108
+
109
+ def verified(lines)
110
+ prev = nil
111
+ lines.each_with_index.map do |line, i|
112
+ event = begin
113
+ JSON.parse(line)
114
+ rescue JSON::ParserError, EncodingError
115
+ raise CorruptError, "event #{i + 1} is not a record"
116
+ end
117
+ ok = event.is_a?(Hash) && event['seq'] == i + 1 && event['prev'] == prev &&
118
+ event['id'] == event_id(event)
119
+ raise CorruptError, "event #{i + 1} does not verify" unless ok
120
+
121
+ prev = event['id']
122
+ event
123
+ end
124
+ end
125
+
126
+ def seal(fields, seq:, prev:)
127
+ event = stringify(fields)
128
+ %w[id seq prev recorded_at].each { |k| event.delete(k) }
129
+ event['seq'] = seq
130
+ event['prev'] = prev
131
+ event['recorded_at'] = Time.now.utc.iso8601(6)
132
+ event['id'] = event_id(event)
133
+ event
134
+ end
135
+
136
+ def event_id(event)
137
+ Digest::SHA256.hexdigest("dream_digest.event\0#{canonical(event.reject { |k, _| k == 'id' })}")
138
+ end
139
+
140
+ # JSON with keys in sorted order at every depth: one byte sequence per event content.
141
+ def canonical(value)
142
+ case value
143
+ when Hash then "{#{value.sort_by { |k, _| k.to_s }.map { |k, v| "#{JSON.generate(k.to_s)}:#{canonical(v)}" }.join(',')}}"
144
+ when Array then "[#{value.map { |v| canonical(v) }.join(',')}]"
145
+ else JSON.generate(value)
146
+ end
147
+ end
148
+
149
+ def stringify(value)
150
+ case value
151
+ when Hash then value.each_with_object({}) { |(k, v), acc| acc[k.to_s] = stringify(v) }
152
+ when Array then value.map { |v| stringify(v) }
153
+ when Symbol then value.to_s
154
+ else value
155
+ end
156
+ end
157
+ end
158
+ end
159
+ end
160
+ end