phronomy 0.33.0 → 0.35.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 +4 -4
- data/CHANGELOG.md +104 -0
- data/CONTRIBUTING.md +5 -5
- data/README.md +17 -2
- data/RELEASE_CHECKLIST.md +3 -1
- data/SECURITY.md +1 -1
- data/VERIFY.sh +1 -9
- data/docs/architecture/backend-groups.md +69 -19
- data/docs/architecture/error-api-review.md +6 -2
- data/docs/architecture/storage-execution-boundaries.md +49 -29
- data/docs/architecture/structured-output-and-scope.md +3 -4
- data/docs/decisions/016-semantic-multi-agent-handoff.md +6 -5
- data/docs/decisions/027-llm-adapter-provider-boundary.md +7 -1
- data/docs/decisions/059-backend-contracts-and-async-clients.md +16 -4
- data/docs/features.md +4 -3
- data/docs/migrations/cleanup-audit.md +89 -0
- data/docs/migrations/legacy-format-removal.md +55 -0
- data/docs/migrations/r8-unit6.md +4 -2
- data/docs/migrations/storage-async-client.md +47 -17
- data/docs/migrations/vector-async-clients.md +24 -10
- data/docs/persistence-backends.md +50 -5
- data/docs/shared-state-sharing.md +14 -4
- data/lib/phronomy/agent/execution/agent_invocation.rb +0 -4
- data/lib/phronomy/agent/handoff/transfer_projection.rb +0 -9
- data/lib/phronomy/agent/journal/journal_record.rb +2 -2
- data/lib/phronomy/agent/recovery/recovery_rules.rb +0 -12
- data/lib/phronomy/agent/store.rb +3 -8
- data/lib/phronomy/agent/tool_execution/tool_invocation.rb +0 -3
- data/lib/phronomy/context/context_policy.rb +3 -7
- data/lib/phronomy/context/llm_input_manifest.rb +3 -3
- data/lib/phronomy/engine/runtime/shutdown_result.rb +0 -5
- data/lib/phronomy/execution/execution.rb +0 -11
- data/lib/phronomy/multi_agent/shared_state.rb +5 -8
- data/lib/phronomy/persistence/content_repository.rb +2 -1
- data/lib/phronomy/persistence_composition/stores.rb +14 -2
- data/lib/phronomy/storage/async/async_client.rb +0 -12
- data/lib/phronomy/vector_store/async/async_client.rb +3 -3
- data/lib/phronomy/version.rb +1 -1
- data/scripts/api_snapshot.rb +2 -2
- data/sig/phronomy/persistence_composition.rbs +2 -0
- data/sig/phronomy/vector_store/async/async_client.rbs +2 -2
- metadata +4 -11
- data/lib/phronomy/execution/scheduler_reentrancy_error.rb +0 -9
- data/lib/phronomy/persistence/migration/initial_format_migration.rb +0 -226
- data/scripts/add_to_h_to_token_doubles.rb +0 -33
- data/scripts/add_to_h_unnamed_doubles.rb +0 -27
- data/scripts/migrate_generator_verifier_result.rb +0 -18
- data/scripts/migrate_spec_agent_definition.rb +0 -108
- data/scripts/migrate_spec_agent_definition_pass2.rb +0 -53
- data/scripts/migrate_spec_inline_pass3.rb +0 -24
- data/sig/phronomy/persistence/migration.rbs +0 -13
|
@@ -149,9 +149,9 @@ module Phronomy
|
|
|
149
149
|
freeze
|
|
150
150
|
end
|
|
151
151
|
|
|
152
|
-
# Current-format-only durable decoder. Historical
|
|
153
|
-
#
|
|
154
|
-
#
|
|
152
|
+
# Current-format-only durable decoder. Historical versions are rejected.
|
|
153
|
+
# Unlike the Ruby construction API, this decoder never coerces durable
|
|
154
|
+
# field types.
|
|
155
155
|
def self.from_h(hash)
|
|
156
156
|
source = strict_source!(
|
|
157
157
|
hash,
|
|
@@ -52,11 +52,6 @@ module Phronomy
|
|
|
52
52
|
%i[not_started terminated].include?(@event_loop_status) &&
|
|
53
53
|
@task_registry_status == :empty
|
|
54
54
|
end
|
|
55
|
-
|
|
56
|
-
# Runtime reset is safe when cleanup completed, even if execution failed.
|
|
57
|
-
def success?
|
|
58
|
-
cleanup_complete?
|
|
59
|
-
end
|
|
60
55
|
end
|
|
61
56
|
end
|
|
62
57
|
end
|
|
@@ -127,22 +127,11 @@ module Phronomy
|
|
|
127
127
|
observed
|
|
128
128
|
end
|
|
129
129
|
|
|
130
|
-
# Scope/admission hooks shared with framework-owned operations.
|
|
131
|
-
# @api private
|
|
132
|
-
def __while_open(&block)
|
|
133
|
-
@scope.__while_open(&block)
|
|
134
|
-
end
|
|
135
|
-
|
|
136
130
|
# @api private
|
|
137
131
|
def __open?
|
|
138
132
|
@scope.__open?
|
|
139
133
|
end
|
|
140
134
|
|
|
141
|
-
# @api private
|
|
142
|
-
def __cancellation_token
|
|
143
|
-
@token
|
|
144
|
-
end
|
|
145
|
-
|
|
146
135
|
# @api private
|
|
147
136
|
def __cancellation_error
|
|
148
137
|
@scope.__cancellation_error
|
|
@@ -323,14 +323,11 @@ module Phronomy
|
|
|
323
323
|
# application's definition-version namespace independent from framework
|
|
324
324
|
# instrumentation.
|
|
325
325
|
instrumented_def = instrumented_definition_for(researcher_class)
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
)
|
|
332
|
-
tools(definitions)
|
|
333
|
-
end
|
|
326
|
+
researcher_class.with_tools(
|
|
327
|
+
definitions,
|
|
328
|
+
id: instrumented_def.fetch(:id),
|
|
329
|
+
version: instrumented_def.fetch(:version)
|
|
330
|
+
)
|
|
334
331
|
end
|
|
335
332
|
|
|
336
333
|
def build_read_tool(store)
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
module Phronomy
|
|
4
4
|
class Persistence
|
|
5
5
|
# Domain-facing content access uses the Persistence failure vocabulary.
|
|
6
|
-
# ContentStore
|
|
6
|
+
# ContentStore remains a content service over neutral Storage; this facade
|
|
7
|
+
# translates known Storage failures without selecting a physical backend.
|
|
7
8
|
# @api private
|
|
8
9
|
class ContentRepository < Phronomy::ContentStore::Base
|
|
9
10
|
def initialize(store)
|
|
@@ -6,10 +6,22 @@ module Phronomy
|
|
|
6
6
|
# Pass only the corresponding domain store to each domain's API.
|
|
7
7
|
Stores = Data.define(:coordinator, :agent, :multi_agent, :workflow)
|
|
8
8
|
|
|
9
|
+
# Canonical declarations for a backend supplied to .build. This frozen list
|
|
10
|
+
# preserves Resource identity without constructing stores, a backend or Runtime.
|
|
11
|
+
# @return [Array<Storage::Resource>] the complete domain and content catalog
|
|
12
|
+
# @api public
|
|
13
|
+
def self.resources = StorageSchema.resources
|
|
14
|
+
|
|
15
|
+
# Canonical declarations for a backend supplied to .agent. This frozen list
|
|
16
|
+
# includes Agent and content resources without loading Team or Workflow schemas.
|
|
17
|
+
# @return [Array<Storage::Resource>] the Agent and content catalog
|
|
18
|
+
# @api public
|
|
19
|
+
def self.agent_resources = StorageSchema.agent_resources
|
|
20
|
+
|
|
9
21
|
# An ordinary Agent needs only its own records and content. Do not load or
|
|
10
22
|
# instantiate Team/Workflow implementations merely to construct an Agent.
|
|
11
23
|
def self.agent(backend: nil)
|
|
12
|
-
resources =
|
|
24
|
+
resources = agent_resources
|
|
13
25
|
backend ||= Phronomy::Storage::Backends::InMemory.new(resources: resources)
|
|
14
26
|
coordinator = Phronomy::Persistence.new(backend: backend)
|
|
15
27
|
Phronomy::Persistence::StorageBoundary.call do
|
|
@@ -28,7 +40,7 @@ module Phronomy
|
|
|
28
40
|
end
|
|
29
41
|
|
|
30
42
|
def self.in_memory
|
|
31
|
-
build(backend: Phronomy::Storage::Backends::InMemory.new(resources:
|
|
43
|
+
build(backend: Phronomy::Storage::Backends::InMemory.new(resources: resources))
|
|
32
44
|
end
|
|
33
45
|
end
|
|
34
46
|
end
|
|
@@ -38,18 +38,6 @@ module Phronomy
|
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
-
# Submit an existing domain-owned synchronous storage unit unchanged.
|
|
42
|
-
# It may already open transactions or perform reads/reconciliation. Do not
|
|
43
|
-
# add a transaction, timeout or cancellation condition around that unit.
|
|
44
|
-
# The owner supplies its current runtime's pool and applies the result.
|
|
45
|
-
#
|
|
46
|
-
# @api private
|
|
47
|
-
def self.submit(pool:, &operation)
|
|
48
|
-
raise ArgumentError, "storage submit requires a block" unless operation
|
|
49
|
-
|
|
50
|
-
Phronomy::Execution.submit(pool: pool, on_full: :raise, &operation)
|
|
51
|
-
end
|
|
52
|
-
|
|
53
41
|
private
|
|
54
42
|
|
|
55
43
|
def default_pool
|
|
@@ -24,7 +24,7 @@ module Phronomy
|
|
|
24
24
|
# Async variant of {VectorStore::Base#add}.
|
|
25
25
|
#
|
|
26
26
|
# @param id [String]
|
|
27
|
-
# @param embedding [Array<
|
|
27
|
+
# @param embedding [Array<Numeric>]
|
|
28
28
|
# @param metadata [Hash]
|
|
29
29
|
# @param cancellation_token [Phronomy::Concurrency::CancellationToken, nil]
|
|
30
30
|
# @param timeout [Numeric, nil]
|
|
@@ -41,8 +41,8 @@ module Phronomy
|
|
|
41
41
|
|
|
42
42
|
# Async variant of {VectorStore::Base#search}.
|
|
43
43
|
#
|
|
44
|
-
# @param query_embedding [Array<
|
|
45
|
-
# @param k [Integer]
|
|
44
|
+
# @param query_embedding [Array<Numeric>]
|
|
45
|
+
# @param k [Integer, String] positive integer or its decimal string
|
|
46
46
|
# @param cancellation_token [Phronomy::Concurrency::CancellationToken, nil]
|
|
47
47
|
# @param timeout [Numeric, nil]
|
|
48
48
|
# @return [Phronomy::TaskResult]
|
data/lib/phronomy/version.rb
CHANGED
data/scripts/api_snapshot.rb
CHANGED
|
@@ -55,6 +55,7 @@ PUBLIC_API_ENTRIES = [
|
|
|
55
55
|
Phronomy::Runnable,
|
|
56
56
|
Phronomy::Context::PromptTemplate,
|
|
57
57
|
# Beta
|
|
58
|
+
Phronomy::PersistenceComposition,
|
|
58
59
|
Phronomy::Tool::Schema,
|
|
59
60
|
Phronomy::Tool::CallRequest,
|
|
60
61
|
Phronomy::Tool::Operation,
|
|
@@ -112,8 +113,7 @@ def snapshot_entry(klass)
|
|
|
112
113
|
else []
|
|
113
114
|
end
|
|
114
115
|
instance_methods = (klass.public_instance_methods - BASELINE_INSTANCE_METHODS - internal_methods).sort
|
|
115
|
-
|
|
116
|
-
class_methods = (klass.public_methods(false) - BASELINE_CLASS_METHODS - internal_class_methods).sort
|
|
116
|
+
class_methods = (klass.public_methods(false) - BASELINE_CLASS_METHODS).sort
|
|
117
117
|
{
|
|
118
118
|
"name" => klass.name,
|
|
119
119
|
"type" => "class",
|
|
@@ -12,6 +12,8 @@ module Phronomy
|
|
|
12
12
|
def self.convert: (Hash[String, json_value] snapshot, quiescent: bool) -> Hash[String, json_value]
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
+
def self.resources: () -> Array[Storage::Resource]
|
|
16
|
+
def self.agent_resources: () -> Array[Storage::Resource]
|
|
15
17
|
def self.agent: (?backend: _StorageBackend?) -> Agent::Store
|
|
16
18
|
def self.build: (backend: _StorageBackend) -> Stores
|
|
17
19
|
def self.in_memory: () -> Stores
|
|
@@ -3,8 +3,8 @@ module Phronomy
|
|
|
3
3
|
class AsyncClient
|
|
4
4
|
# pool is an optional internal execution-pool injection; ordinary callers omit it.
|
|
5
5
|
def initialize: (backend: Base, ?pool: untyped) -> void
|
|
6
|
-
def add_async: (id: String, embedding: Array[
|
|
7
|
-
def search_async: (query_embedding: Array[
|
|
6
|
+
def add_async: (id: String, embedding: Array[Numeric], ?metadata: Hash[untyped, untyped], ?cancellation_token: Concurrency::CancellationToken?, ?timeout: Numeric?) -> TaskResult[untyped]
|
|
7
|
+
def search_async: (query_embedding: Array[Numeric], ?k: Integer | String, ?cancellation_token: Concurrency::CancellationToken?, ?timeout: Numeric?) -> TaskResult[Array[Hash[Symbol, untyped]]]
|
|
8
8
|
def remove_async: (id: String, ?cancellation_token: Concurrency::CancellationToken?, ?timeout: Numeric?) -> TaskResult[untyped]
|
|
9
9
|
def clear_async: (?cancellation_token: Concurrency::CancellationToken?, ?timeout: Numeric?) -> TaskResult[untyped]
|
|
10
10
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: phronomy
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.35.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Raizo T.C.S
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-11-
|
|
11
|
+
date: 2026-11-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: ruby_llm
|
|
@@ -345,8 +345,10 @@ files:
|
|
|
345
345
|
- docs/migrations/0.19.md
|
|
346
346
|
- docs/migrations/0.22.md
|
|
347
347
|
- docs/migrations/0.31.md
|
|
348
|
+
- docs/migrations/cleanup-audit.md
|
|
348
349
|
- docs/migrations/durable-semantic-coordination-v2.md
|
|
349
350
|
- docs/migrations/handoff-runner-multi-agent.md
|
|
351
|
+
- docs/migrations/legacy-format-removal.md
|
|
350
352
|
- docs/migrations/neutral-storage-spi.md
|
|
351
353
|
- docs/migrations/parallel-tool-chat-removal.md
|
|
352
354
|
- docs/migrations/persistence-failure-contracts.md
|
|
@@ -561,7 +563,6 @@ files:
|
|
|
561
563
|
- lib/phronomy/execution/runnable.rb
|
|
562
564
|
- lib/phronomy/execution/runtime_shutdown_error.rb
|
|
563
565
|
- lib/phronomy/execution/runtime_shutdown_reentrancy_error.rb
|
|
564
|
-
- lib/phronomy/execution/scheduler_reentrancy_error.rb
|
|
565
566
|
- lib/phronomy/execution/task_result.rb
|
|
566
567
|
- lib/phronomy/execution/timeout_error.rb
|
|
567
568
|
- lib/phronomy/execution/wait_policy.rb
|
|
@@ -636,7 +637,6 @@ files:
|
|
|
636
637
|
- lib/phronomy/output_parser/structured_parser.rb
|
|
637
638
|
- lib/phronomy/persistence/content_repository.rb
|
|
638
639
|
- lib/phronomy/persistence/errors.rb
|
|
639
|
-
- lib/phronomy/persistence/migration/initial_format_migration.rb
|
|
640
640
|
- lib/phronomy/persistence/persistence.rb
|
|
641
641
|
- lib/phronomy/persistence/save_outcome.rb
|
|
642
642
|
- lib/phronomy/persistence/snapshot_comparison.rb
|
|
@@ -749,16 +749,10 @@ files:
|
|
|
749
749
|
- lib/phronomy/workflow/runtime_binding/workflow_phase_machine_builder.rb
|
|
750
750
|
- lib/phronomy/workflow/runtime_binding/workflow_task_session.rb
|
|
751
751
|
- lib/phronomy/workflow/runtime_binding/workflow_terminal_policy.rb
|
|
752
|
-
- scripts/add_to_h_to_token_doubles.rb
|
|
753
|
-
- scripts/add_to_h_unnamed_doubles.rb
|
|
754
752
|
- scripts/api_snapshot.rb
|
|
755
753
|
- scripts/check_api_annotations.rb
|
|
756
754
|
- scripts/check_readme_ruby.rb
|
|
757
755
|
- scripts/check_readme_runnable.rb
|
|
758
|
-
- scripts/migrate_generator_verifier_result.rb
|
|
759
|
-
- scripts/migrate_spec_agent_definition.rb
|
|
760
|
-
- scripts/migrate_spec_agent_definition_pass2.rb
|
|
761
|
-
- scripts/migrate_spec_inline_pass3.rb
|
|
762
756
|
- scripts/run_mutation.sh
|
|
763
757
|
- scripts/storage_spi_snapshot.rb
|
|
764
758
|
- sig/_private/phronomy/agent/settings.rbs
|
|
@@ -820,7 +814,6 @@ files:
|
|
|
820
814
|
- sig/phronomy/multi_agent/team_not_found_error.rbs
|
|
821
815
|
- sig/phronomy/persistence.rbs
|
|
822
816
|
- sig/phronomy/persistence/errors.rbs
|
|
823
|
-
- sig/phronomy/persistence/migration.rbs
|
|
824
817
|
- sig/phronomy/persistence/transaction.rbs
|
|
825
818
|
- sig/phronomy/persistence_composition.rbs
|
|
826
819
|
- sig/phronomy/runtime_composition/configuration.rbs
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "event_loop_reentrancy_error"
|
|
4
|
-
|
|
5
|
-
module Phronomy
|
|
6
|
-
# Backward-compatible error class name for callers that still rescue the old
|
|
7
|
-
# scheduler-oriented exception. New code should use EventLoopReentrancyError.
|
|
8
|
-
class SchedulerReentrancyError < EventLoopReentrancyError; end
|
|
9
|
-
end
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Phronomy
|
|
4
|
-
class Persistence
|
|
5
|
-
module Migration
|
|
6
|
-
# Explicit logical conversion from the pre-S3 unversioned representations
|
|
7
|
-
# present at the ACS-06 fixed base to the initial 0.1 durable formats.
|
|
8
|
-
#
|
|
9
|
-
# This module does not scan a database or write records. A backend-specific
|
|
10
|
-
# migration runner is responsible for physical enumeration, transactions,
|
|
11
|
-
# and replacement. Normal Runtime load never calls these methods.
|
|
12
|
-
#
|
|
13
|
-
# @api public
|
|
14
|
-
module InitialFormatMigration
|
|
15
|
-
PRE_S3_AGENT_ROOT_KEYS = Phronomy::Agent::AgentRoot::ATTRIBUTES.map(&:to_s).freeze
|
|
16
|
-
PRE_S3_AGENT_EXECUTION_KEYS = Phronomy::Agent::AgentExecution::ATTRIBUTES.map(&:to_s).freeze
|
|
17
|
-
PRE_S3_JOURNAL_KEYS = Phronomy::Agent::JournalRecord::ATTRIBUTES.map(&:to_s).freeze
|
|
18
|
-
PRE_S3_LLM_CALL_KEYS = Phronomy::Agent::LLMCallRecord::ATTRIBUTES.map(&:to_s).freeze
|
|
19
|
-
PRE_S3_APPROVAL_REQUIRED_KEYS = %w[id items created_at].freeze
|
|
20
|
-
PRE_S3_APPROVAL_PARENT_KEYS = %w[execution_id agent_invocation_id].freeze
|
|
21
|
-
PRE_S3_APPROVAL_OPTIONAL_KEYS = %w[approved].freeze
|
|
22
|
-
PRE_S3_APPROVAL_ITEM_KEYS = %w[
|
|
23
|
-
tool_invocation_id tool_call_id tool_name arguments facts reason origin metadata
|
|
24
|
-
].freeze
|
|
25
|
-
|
|
26
|
-
module_function
|
|
27
|
-
|
|
28
|
-
def agent_root(hash)
|
|
29
|
-
source = stringify_keys(hash)
|
|
30
|
-
validate_exact_keys!(
|
|
31
|
-
source,
|
|
32
|
-
PRE_S3_AGENT_ROOT_KEYS,
|
|
33
|
-
label: "pre-S3 AgentRoot"
|
|
34
|
-
)
|
|
35
|
-
Phronomy::Agent::Persistence::Codec.encode_agent_root(
|
|
36
|
-
Phronomy::Agent::AgentRoot.from_h(source)
|
|
37
|
-
)
|
|
38
|
-
rescue Phronomy::Storage::SerializationError
|
|
39
|
-
raise
|
|
40
|
-
rescue => error
|
|
41
|
-
migration_error("AgentRoot", error)
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def agent_execution(hash)
|
|
45
|
-
source = stringify_keys(hash)
|
|
46
|
-
validate_exact_keys!(
|
|
47
|
-
source,
|
|
48
|
-
PRE_S3_AGENT_EXECUTION_KEYS,
|
|
49
|
-
label: "pre-S3 AgentExecution"
|
|
50
|
-
)
|
|
51
|
-
source["working_records"] = Array(source.fetch("working_records")).map.with_index do |record, index|
|
|
52
|
-
normalize_legacy_journal_record(
|
|
53
|
-
record,
|
|
54
|
-
label: "pre-S3 AgentExecution working_records[#{index}]"
|
|
55
|
-
)
|
|
56
|
-
end
|
|
57
|
-
source["llm_calls"] = Array(source.fetch("llm_calls")).map.with_index do |call, index|
|
|
58
|
-
normalized = stringify_keys(call)
|
|
59
|
-
validate_exact_keys!(
|
|
60
|
-
normalized,
|
|
61
|
-
PRE_S3_LLM_CALL_KEYS,
|
|
62
|
-
label: "pre-S3 AgentExecution llm_calls[#{index}]"
|
|
63
|
-
)
|
|
64
|
-
normalized
|
|
65
|
-
end
|
|
66
|
-
source["approval_request"] = normalize_legacy_approval_request(
|
|
67
|
-
source["approval_request"],
|
|
68
|
-
execution_id: source.fetch("execution_id")
|
|
69
|
-
)
|
|
70
|
-
execution = Phronomy::Agent::AgentExecution.from_h(source)
|
|
71
|
-
Phronomy::Agent::Persistence::Codec.encode_agent_execution(execution)
|
|
72
|
-
rescue Phronomy::Storage::SerializationError
|
|
73
|
-
raise
|
|
74
|
-
rescue => error
|
|
75
|
-
migration_error("AgentExecution", error)
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def journal_record(hash)
|
|
79
|
-
source = normalize_legacy_journal_record(hash, label: "pre-S3 JournalRecord")
|
|
80
|
-
Phronomy::Agent::Persistence::Codec.encode_journal_record(
|
|
81
|
-
Phronomy::Agent::JournalRecord.from_h(source)
|
|
82
|
-
)
|
|
83
|
-
rescue Phronomy::Storage::SerializationError
|
|
84
|
-
raise
|
|
85
|
-
rescue => error
|
|
86
|
-
migration_error("JournalRecord", error)
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
def workflow_state(workflow_instance_id:, revision:, snapshot:)
|
|
90
|
-
Phronomy::Workflow::Persistence::Codec.encode_workflow_state(
|
|
91
|
-
workflow_instance_id: workflow_instance_id,
|
|
92
|
-
workflow_revision: Integer(revision),
|
|
93
|
-
snapshot: snapshot
|
|
94
|
-
)
|
|
95
|
-
rescue Phronomy::Storage::SerializationError
|
|
96
|
-
raise
|
|
97
|
-
rescue => error
|
|
98
|
-
migration_error("Workflow state", error)
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
# LLMInputManifest is a ContentStore codec boundary, not a
|
|
102
|
-
# Storage::DurableRecord. Its pre-CG-07 integer version 1 is migrated
|
|
103
|
-
# explicitly to the pre-1.0 string version "0.1".
|
|
104
|
-
def llm_input_manifest(hash)
|
|
105
|
-
source = stringify_keys(hash)
|
|
106
|
-
old_version = source.fetch("version")
|
|
107
|
-
unless old_version == 1 || old_version == "1"
|
|
108
|
-
raise Phronomy::Storage::SerializationError,
|
|
109
|
-
"unsupported pre-S3 LLMInputManifest version: #{old_version.inspect}"
|
|
110
|
-
end
|
|
111
|
-
source["version"] = Phronomy::Context::LLMInputManifest::VERSION
|
|
112
|
-
Phronomy::Context::LLMInputManifest.from_h(source).to_h
|
|
113
|
-
rescue Phronomy::Storage::SerializationError
|
|
114
|
-
raise
|
|
115
|
-
rescue => error
|
|
116
|
-
migration_error("LLMInputManifest", error)
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
def normalize_legacy_journal_record(hash, label:)
|
|
120
|
-
source = stringify_keys(hash)
|
|
121
|
-
validate_allowed_keys!(
|
|
122
|
-
source,
|
|
123
|
-
required_keys: PRE_S3_JOURNAL_KEYS,
|
|
124
|
-
optional_keys: ["correlation_id"],
|
|
125
|
-
label: label
|
|
126
|
-
)
|
|
127
|
-
source.delete("correlation_id")
|
|
128
|
-
source
|
|
129
|
-
end
|
|
130
|
-
private_class_method :normalize_legacy_journal_record
|
|
131
|
-
|
|
132
|
-
def normalize_legacy_approval_request(request, execution_id:)
|
|
133
|
-
return nil unless request
|
|
134
|
-
|
|
135
|
-
source = stringify_keys(request)
|
|
136
|
-
validate_allowed_keys!(
|
|
137
|
-
source,
|
|
138
|
-
required_keys: PRE_S3_APPROVAL_REQUIRED_KEYS,
|
|
139
|
-
optional_keys: PRE_S3_APPROVAL_PARENT_KEYS + PRE_S3_APPROVAL_OPTIONAL_KEYS,
|
|
140
|
-
label: "pre-S3 approval_request"
|
|
141
|
-
)
|
|
142
|
-
parents = PRE_S3_APPROVAL_PARENT_KEYS.select { |key| source.key?(key) }
|
|
143
|
-
unless parents.length == 1
|
|
144
|
-
raise Phronomy::Storage::SerializationError,
|
|
145
|
-
"pre-S3 approval_request must contain exactly one parent identity, got #{parents.inspect}"
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
items = source.fetch("items")
|
|
149
|
-
unless items.is_a?(Array) && !items.empty?
|
|
150
|
-
raise Phronomy::Storage::SerializationError,
|
|
151
|
-
"pre-S3 approval_request items must be a non-empty Array"
|
|
152
|
-
end
|
|
153
|
-
source["items"] = items.map.with_index do |item, index|
|
|
154
|
-
normalized = stringify_keys(item)
|
|
155
|
-
validate_exact_keys!(
|
|
156
|
-
normalized,
|
|
157
|
-
PRE_S3_APPROVAL_ITEM_KEYS,
|
|
158
|
-
label: "pre-S3 approval_request items[#{index}]"
|
|
159
|
-
)
|
|
160
|
-
normalized
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
if source.key?("agent_invocation_id")
|
|
164
|
-
source.delete("agent_invocation_id")
|
|
165
|
-
source["execution_id"] = execution_id.to_s
|
|
166
|
-
elsif source.fetch("execution_id").to_s != execution_id.to_s
|
|
167
|
-
raise Phronomy::Storage::SerializationError,
|
|
168
|
-
"pre-S3 approval_request execution_id does not match AgentExecution"
|
|
169
|
-
end
|
|
170
|
-
source
|
|
171
|
-
end
|
|
172
|
-
private_class_method :normalize_legacy_approval_request
|
|
173
|
-
|
|
174
|
-
def validate_allowed_keys!(hash, required_keys:, optional_keys:, label:)
|
|
175
|
-
actual = hash.keys.sort
|
|
176
|
-
missing = required_keys.sort - actual
|
|
177
|
-
unknown = actual - (required_keys + optional_keys).sort
|
|
178
|
-
return hash if missing.empty? && unknown.empty?
|
|
179
|
-
|
|
180
|
-
details = []
|
|
181
|
-
details << "missing=#{missing.inspect}" unless missing.empty?
|
|
182
|
-
details << "unknown=#{unknown.inspect}" unless unknown.empty?
|
|
183
|
-
raise Phronomy::Storage::SerializationError,
|
|
184
|
-
"#{label} schema mismatch (#{details.join(", ")})"
|
|
185
|
-
end
|
|
186
|
-
private_class_method :validate_allowed_keys!
|
|
187
|
-
|
|
188
|
-
def validate_exact_keys!(hash, expected_keys, label:)
|
|
189
|
-
validate_allowed_keys!(
|
|
190
|
-
hash,
|
|
191
|
-
required_keys: expected_keys,
|
|
192
|
-
optional_keys: [],
|
|
193
|
-
label: label
|
|
194
|
-
)
|
|
195
|
-
end
|
|
196
|
-
private_class_method :validate_exact_keys!
|
|
197
|
-
|
|
198
|
-
def stringify_keys(hash)
|
|
199
|
-
unless hash.is_a?(Hash)
|
|
200
|
-
raise Phronomy::Storage::SerializationError,
|
|
201
|
-
"migration input must be a Hash"
|
|
202
|
-
end
|
|
203
|
-
hash.each_with_object({}) do |(key, value), result|
|
|
204
|
-
unless key.is_a?(String) || key.is_a?(Symbol)
|
|
205
|
-
raise Phronomy::Storage::SerializationError,
|
|
206
|
-
"migration key must be String or Symbol, got #{key.class}"
|
|
207
|
-
end
|
|
208
|
-
string_key = key.to_s
|
|
209
|
-
if result.key?(string_key)
|
|
210
|
-
raise Phronomy::Storage::SerializationError,
|
|
211
|
-
"duplicate migration key after normalization: #{string_key.inspect}"
|
|
212
|
-
end
|
|
213
|
-
result[string_key] = value
|
|
214
|
-
end
|
|
215
|
-
end
|
|
216
|
-
private_class_method :stringify_keys
|
|
217
|
-
|
|
218
|
-
def migration_error(label, error)
|
|
219
|
-
raise Phronomy::Storage::SerializationError,
|
|
220
|
-
"cannot migrate pre-S3 #{label}: #{error.class}: #{error.message}"
|
|
221
|
-
end
|
|
222
|
-
private_class_method :migration_error
|
|
223
|
-
end
|
|
224
|
-
end
|
|
225
|
-
end
|
|
226
|
-
end
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
# Adds to_h to all Tokens-like doubles so ExecutionCoordinator can serialize usage.
|
|
5
|
-
|
|
6
|
-
files = Dir.glob("spec/**/*.rb").sort
|
|
7
|
-
|
|
8
|
-
total = 0
|
|
9
|
-
files.each do |f|
|
|
10
|
-
content = File.read(f)
|
|
11
|
-
modified = content.gsub(
|
|
12
|
-
/double\(("[^"]+"),\s*(input: \d+, output: \d+, cached: \d+, cache_creation: \d+)\)/
|
|
13
|
-
) do
|
|
14
|
-
name = $1
|
|
15
|
-
attrs = $2
|
|
16
|
-
next $& if $&.include?("to_h")
|
|
17
|
-
|
|
18
|
-
h_entries = attrs.split(",").map(&:strip).map do |pair|
|
|
19
|
-
k, v = pair.split(":").map(&:strip)
|
|
20
|
-
"\"#{k}\" => #{v}"
|
|
21
|
-
end.join(", ")
|
|
22
|
-
|
|
23
|
-
total += 1
|
|
24
|
-
"double(#{name}, #{attrs}, to_h: {#{h_entries}})"
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
if modified != content
|
|
28
|
-
File.write(f, modified)
|
|
29
|
-
puts " patched: #{f}"
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
puts "\nAdded to_h to #{total} Tokens doubles."
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
# Adds to_h to unnamed (no-string-name) Tokens doubles like double(input: 5, ...)
|
|
5
|
-
|
|
6
|
-
files = Dir.glob("spec/**/*.rb").sort
|
|
7
|
-
|
|
8
|
-
total = 0
|
|
9
|
-
files.each do |f|
|
|
10
|
-
content = File.read(f)
|
|
11
|
-
modified = content.gsub(
|
|
12
|
-
/double\((input: (\d+), output: (\d+), cached: (\d+), cache_creation: (\d+))\)/
|
|
13
|
-
) do
|
|
14
|
-
attrs, a, b, c, d = $1, $2, $3, $4, $5
|
|
15
|
-
next $& if $&.include?("to_h")
|
|
16
|
-
|
|
17
|
-
total += 1
|
|
18
|
-
"double(#{attrs}, to_h: {\"input\" => #{a}, \"output\" => #{b}, \"cached\" => #{c}, \"cache_creation\" => #{d}})"
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
if modified != content
|
|
22
|
-
File.write(f, modified)
|
|
23
|
-
puts " patched: #{f}"
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
puts "\nAdded to_h to #{total} unnamed Tokens doubles."
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
# Explicit one-time conversion of a pre-structured-output Result JSON object.
|
|
5
|
-
# Never infer old formats in the runtime reader; never overwrite the source.
|
|
6
|
-
require_relative "../lib/phronomy"
|
|
7
|
-
|
|
8
|
-
abort "Usage: ruby scripts/migrate_generator_verifier_result.rb OLD.json NEW.json" unless ARGV.length == 2
|
|
9
|
-
source, destination = ARGV
|
|
10
|
-
value = JSON.parse(File.read(source), allow_duplicate_key: false, allow_nan: false,
|
|
11
|
-
allow_comments: false, allow_invalid_escape: false, allow_control_characters: false)
|
|
12
|
-
abort "Expected an old Result object without failure" unless value.is_a?(Hash) && !value.key?("failure")
|
|
13
|
-
value["failure"] = nil
|
|
14
|
-
result = Phronomy::GeneratorVerifier::Result.from_h(value)
|
|
15
|
-
File.open(destination, File::WRONLY | File::CREAT | File::EXCL) do |file|
|
|
16
|
-
file.write(JSON.pretty_generate(result.to_h))
|
|
17
|
-
file.write("\n")
|
|
18
|
-
end
|