active_harness 0.2.1 → 0.2.3

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: e13cc7f12afbddbea9116cae2b3f5c571386ff21a5d7246107a62ceadc3253be
4
- data.tar.gz: 8f4cdcf1333b9f10acdd664e36568e741bf09652f4b8898d028dc3bf601024d9
3
+ metadata.gz: 491b57221c1f401f55e454985bab3eb03da61bac7f03b87a0f3c0251784b3d66
4
+ data.tar.gz: 7932e5787bed0fbf4b8f987b8f8e77c4f56e827b1a608ac10402199e09f8f28a
5
5
  SHA512:
6
- metadata.gz: bf13a6f23ac3053316b31890505d39369bb2e932def11dcc7ecdcb2e948aed9466f91d9b1fe1b356dba35112698f7d2e901f1971e93356f32a3b34743d731e7c
7
- data.tar.gz: 43e7202af753ffd6c6761f21ba2543498c6d04c70e52a57fb9c1aa2cb5063922f536036e28e99bc7710f7e079c50a19839ad510b97ba33841a6d6ff7b15d3220
6
+ metadata.gz: 4bfd567d16e8d5b557462d351169b6b5f6a5f151c31a07728edb3665fe1095a03b8e15286b72aa0f0726a41809c071fc66b6d3cd794f91f0ed540cebd37d4c56
7
+ data.tar.gz: 99784cf80f2aee2dd505643cbea083e09f79d188a75b6d782bcdcc8e6d17875febccf34df3fde9ceee07cd8b7c8996b2085b8e69f7839dcdde437260e4573810
@@ -29,7 +29,7 @@ module ActiveHarness
29
29
  # Instance API
30
30
  # -------------------------------------------------------------------------
31
31
  attr_accessor :input
32
- attr_reader :context
32
+ attr_reader :context, :result
33
33
 
34
34
  def initialize(input: nil, context: {}, models: nil, memory: nil, stream: nil)
35
35
  @input = input
@@ -63,6 +63,7 @@ module ActiveHarness
63
63
  result = build_result(response, entry, attempts, elapsed)
64
64
  save_to_memory(result)
65
65
  run_hook(:after_call, result)
66
+ @result = result
66
67
  return result
67
68
  rescue *RETRYABLE_ERRORS => e
68
69
  elapsed = (Process.clock_gettime(Process::CLOCK_MONOTONIC) - t0).round(3)
@@ -17,21 +17,21 @@ module ActiveHarness
17
17
  end
18
18
 
19
19
  def copy_controller
20
- target = File.join(destination_root, "app", "controllers", "ai_test_support_controller.rb")
20
+ target = File.join(destination_root, "app", "controllers", "ai_support_controller.rb")
21
21
  return if File.exist?(target)
22
22
 
23
23
  copy_file "controllers/ai_controller.rb",
24
- "app/controllers/ai_test_support_controller.rb"
24
+ "app/controllers/ai_support_controller.rb"
25
25
  end
26
26
 
27
27
  def inject_routes
28
28
  route <<~ROUTES.strip
29
- # ActiveHarness — AI test support endpoints
30
- post "ai/agent", to: "ai_test_support#agent"
31
- post "ai/agent_memory", to: "ai_test_support#agent_memory"
32
- post "ai/tribunal", to: "ai_test_support#tribunal"
33
- post "ai/pipeline", to: "ai_test_support#pipeline"
34
- get "ai/agent_stream", to: "ai_test_support#agent_stream"
29
+ # ActiveHarness — AI support endpoints
30
+ post "ai/agent", to: "ai_support#agent"
31
+ post "ai/agent_memory", to: "ai_support#agent_memory"
32
+ post "ai/tribunal", to: "ai_support#tribunal"
33
+ post "ai/pipeline", to: "ai_support#pipeline"
34
+ get "ai/agent_stream", to: "ai_support#agent_stream"
35
35
  ROUTES
36
36
  end
37
37
 
@@ -1,7 +1,7 @@
1
- require_relative "../prompts/test_support_prompt"
1
+ require_relative "../prompts/support_prompt"
2
2
 
3
- class TestSupportAgent < ActiveHarness::Agent
4
- system_prompt TestSupportPrompt
3
+ class SupportAgent < ActiveHarness::Agent
4
+ system_prompt SupportPrompt
5
5
 
6
6
  model do
7
7
  use provider: :openrouter, model: "mistralai/mistral-nemo"
@@ -1,7 +1,7 @@
1
- require_relative "../prompts/test_support_guard_prompt"
1
+ require_relative "../prompts/support_guard_prompt"
2
2
 
3
- class TestSupportGuardAgent < ActiveHarness::Agent
4
- system_prompt TestSupportGuardPrompt
3
+ class SupportGuardAgent < ActiveHarness::Agent
4
+ system_prompt SupportGuardPrompt
5
5
  format :json
6
6
 
7
7
  model do
@@ -1,4 +1,4 @@
1
- class AiTestSupportController < ApplicationController
1
+ class AiSupportController < ApplicationController
2
2
  include ActionController::Live
3
3
 
4
4
  # ---------------------------------------------------------------------------
@@ -6,7 +6,7 @@ class AiTestSupportController < ApplicationController
6
6
  # body: { input: "What is your return policy?" }
7
7
  # ---------------------------------------------------------------------------
8
8
  def agent
9
- result = TestSupportAgent.call(input: params.require(:input))
9
+ result = SupportAgent.call(input: params.require(:input))
10
10
 
11
11
  render json: {
12
12
  output: result.output,
@@ -23,8 +23,8 @@ class AiTestSupportController < ApplicationController
23
23
  # across multiple requests.
24
24
  # ---------------------------------------------------------------------------
25
25
  def agent_memory
26
- memory = TestSupportMemory.new(session_id: params.require(:session_id))
27
- result = TestSupportAgent.call(input: params.require(:input), memory: memory)
26
+ memory = AppMemory.new(session_id: params.require(:session_id))
27
+ result = SupportAgent.call(input: params.require(:input), memory: memory)
28
28
 
29
29
  render json: {
30
30
  output: result.output,
@@ -41,7 +41,7 @@ class AiTestSupportController < ApplicationController
41
41
  # Returns verdict: true (safe) or false (rejected).
42
42
  # ---------------------------------------------------------------------------
43
43
  def tribunal
44
- result = TestSupportGuardTribunal.call(input: params.require(:input))
44
+ result = SupportGuardTribunal.call(input: params.require(:input))
45
45
 
46
46
  render json: {
47
47
  verdict: result.verdict,
@@ -57,7 +57,7 @@ class AiTestSupportController < ApplicationController
57
57
  # If a guard step stops the pipeline early, stopped: true is returned.
58
58
  # ---------------------------------------------------------------------------
59
59
  def pipeline
60
- pipe = TestSupportPipeline.new(input: params.require(:input))
60
+ pipe = SupportPipeline.new(input: params.require(:input))
61
61
  pipe.call
62
62
 
63
63
  if pipe.stopped?
@@ -91,7 +91,7 @@ class AiTestSupportController < ApplicationController
91
91
 
92
92
  sse = ActionController::Live::SSE.new(response.stream, event: "message")
93
93
 
94
- TestSupportAgent.call(
94
+ SupportAgent.call(
95
95
  input: input,
96
96
  stream: ->(token) { sse.write({ token: token }.to_json) }
97
97
  )
@@ -1,5 +1,5 @@
1
- class TestSupportMemory < ActiveHarness::Memory
2
- # Usage: TestSupportMemory.new(session_id: "user_42")
1
+ class AppMemory < ActiveHarness::Memory
2
+ # Usage: AppMemory.new(session_id: "user_42")
3
3
  #
4
4
  # Wraps ActiveHarness::Memory with project defaults so callers
5
5
  # only need to pass a session_id.
@@ -1,17 +1,17 @@
1
- require_relative "../tribunals/test_support_guard_tribunal"
2
- require_relative "../agents/test_support_agent"
1
+ require_relative "../tribunals/support_guard_tribunal"
2
+ require_relative "../agents/support_agent"
3
3
 
4
4
  # Two-step pipeline: spam guard → answer.
5
5
  # Add more steps between them as needed.
6
- class TestSupportPipeline < ActiveHarness::Pipeline
6
+ class SupportPipeline < ActiveHarness::Pipeline
7
7
  # Step 1 — GUARD: reject spam before spending tokens on an answer
8
8
  step :spam_guard do
9
- use TestSupportGuardTribunal
9
+ use SupportGuardTribunal
10
10
  stop_if ->(result) { result.verdict == false }
11
11
  end
12
12
 
13
13
  # Step 2 — RESPOND: generate the actual answer
14
- step :respond, TestSupportAgent
14
+ step :respond, SupportAgent
15
15
 
16
16
  before :step do |step_name, _payload|
17
17
  puts "[pipeline] → :#{step_name}"
@@ -1,4 +1,4 @@
1
- class TestSupportGuardPrompt
1
+ class SupportGuardPrompt
2
2
  def call
3
3
  <<~PROMPT.strip
4
4
  You are a spam detection filter.
@@ -1,4 +1,4 @@
1
- class TestSupportPrompt
1
+ class SupportPrompt
2
2
  def call
3
3
  "You are a concise and helpful assistant. Answer in 1-2 sentences."
4
4
  end
@@ -0,0 +1,11 @@
1
+ require_relative "../agents/support_guard_agent"
2
+
3
+ # Runs SupportGuardAgent in parallel (single agent here, extendable).
4
+ # Verdict is true (safe) when no spam is detected.
5
+ class SupportGuardTribunal < ActiveHarness::Tribunal
6
+ agents SupportGuardAgent
7
+
8
+ process do |results|
9
+ results.none? { |r| r.parsed["spam"] == true }
10
+ end
11
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_harness
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - the-teacher
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-05-20 00:00:00.000000000 Z
11
+ date: 2026-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -59,14 +59,14 @@ files:
59
59
  - lib/generators/active_harness/agent/agent_generator.rb
60
60
  - lib/generators/active_harness/agent/templates/agent.rb.tt
61
61
  - lib/generators/active_harness/install/install_generator.rb
62
- - lib/generators/active_harness/install/templates/agents/test_support_agent.rb
63
- - lib/generators/active_harness/install/templates/agents/test_support_guard_agent.rb
62
+ - lib/generators/active_harness/install/templates/agents/support_agent.rb
63
+ - lib/generators/active_harness/install/templates/agents/support_guard_agent.rb
64
64
  - lib/generators/active_harness/install/templates/controllers/ai_controller.rb
65
- - lib/generators/active_harness/install/templates/memory/test_support_memory.rb
66
- - lib/generators/active_harness/install/templates/pipelines/test_support_pipeline.rb
67
- - lib/generators/active_harness/install/templates/prompts/test_support_guard_prompt.rb
68
- - lib/generators/active_harness/install/templates/prompts/test_support_prompt.rb
69
- - lib/generators/active_harness/install/templates/tribunals/test_support_guard_tribunal.rb
65
+ - lib/generators/active_harness/install/templates/memory/app_memory.rb
66
+ - lib/generators/active_harness/install/templates/pipelines/support_pipeline.rb
67
+ - lib/generators/active_harness/install/templates/prompts/support_guard_prompt.rb
68
+ - lib/generators/active_harness/install/templates/prompts/support_prompt.rb
69
+ - lib/generators/active_harness/install/templates/tribunals/support_guard_tribunal.rb
70
70
  - lib/generators/active_harness/memory/memory_generator.rb
71
71
  - lib/generators/active_harness/memory/templates/memory.rb.tt
72
72
  - lib/generators/active_harness/pipeline/pipeline_generator.rb
@@ -1,11 +0,0 @@
1
- require_relative "../agents/test_support_guard_agent"
2
-
3
- # Runs TestSupportGuardAgent in parallel (single agent here, extendable).
4
- # Verdict is true (safe) when no spam is detected.
5
- class TestSupportGuardTribunal < ActiveHarness::Tribunal
6
- agents TestSupportGuardAgent
7
-
8
- process do |results|
9
- results.none? { |r| r.parsed["spam"] == true }
10
- end
11
- end