Skip to content

Commit af007a9

Browse files
committed
Prove GEPA adapter roundtrip
1 parent 446f8d6 commit af007a9

7 files changed

Lines changed: 140 additions & 11 deletions

File tree

examples/gepa_platform_roundtrip/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@
22

33
Deterministic governed GEPA roundtrip proof with mock model profiles, candidate
44
evaluation, comparison, promotion gates, rollback refs, and trace refs.
5+
6+
The proof path uses `GEPAFramework` plus `GEPA.MezzanineOptimizerAdapter`
7+
through `Mezzanine.OptimizationEngine.propose_candidates/3`, then projects the
8+
candidate through `AppKit.OptimizationSurface`. `gepa_buildout` is not required
9+
for this canary.

examples/gepa_platform_roundtrip/lib/stack_lab/examples/gepa_platform_roundtrip.ex

Lines changed: 108 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ defmodule StackLab.Examples.GEPAPlatformRoundtrip.Receipt do
99
:optimization_fabric_scan,
1010
:ai_run_lineage_scan,
1111
:framework_projection,
12+
:candidate_receipt,
13+
:appkit_projection,
1214
:promotion_ref,
1315
:rollback_ref,
1416
:trace_refs
@@ -22,6 +24,10 @@ defmodule StackLab.Examples.GEPAPlatformRoundtrip do
2224
Deterministic governed GEPA platform roundtrip proof.
2325
"""
2426

27+
alias AppKit.OptimizationSurface
28+
alias GEPAFramework.Runtime
29+
alias Mezzanine.AIExecution.RuntimeDeps
30+
alias Mezzanine.OptimizationEngine
2531
alias StackLab.AIRunLineageScanner
2632
alias StackLab.Examples.GEPAPlatformRoundtrip.Receipt
2733
alias StackLab.ModelInferenceScanner
@@ -31,7 +37,15 @@ defmodule StackLab.Examples.GEPAPlatformRoundtrip do
3137

3238
@spec run() :: {:ok, Receipt.t()} | {:error, term()}
3339
def run do
34-
with {:ok, buildout_result} <- GEPABuildout.run_domain_task(buildout_input()),
40+
with {:ok, framework_result} <- Runtime.run(framework_config(), examples: example_refs()),
41+
{:ok, [candidate_receipt]} <-
42+
OptimizationEngine.propose_candidates(optimization_spec(), runtime_deps(),
43+
examples: example_refs()
44+
),
45+
{:ok, appkit_projection} <-
46+
OptimizationSurface.candidate_projection(
47+
appkit_candidate_projection(candidate_receipt)
48+
),
3549
{:ok, model_scan} <- ModelInferenceScanner.scan(model_scan_input()),
3650
{:ok, fabric_scan} <- OptimizationFabricScanner.scan(fabric_scan_input()),
3751
{:ok, lineage_scan} <- AIRunLineageScanner.scan(lineage_scan_input()) do
@@ -40,24 +54,104 @@ defmodule StackLab.Examples.GEPAPlatformRoundtrip do
4054
receipt_ref: "gepa-platform-roundtrip://phase-8/mock",
4155
fixture_refs: @fixture_refs,
4256
status: status([model_scan, fabric_scan, lineage_scan]),
43-
provider_dependency?: buildout_result.framework_result.provider_dependency?,
57+
provider_dependency?: framework_result.provider_dependency?,
4458
model_inference_scan: model_scan,
4559
optimization_fabric_scan: fabric_scan,
4660
ai_run_lineage_scan: lineage_scan,
47-
framework_projection: buildout_result.projection,
61+
framework_projection: framework_projection(framework_result),
62+
candidate_receipt: candidate_receipt,
63+
appkit_projection: appkit_projection,
4864
promotion_ref: "promotion://gepa/candidate",
4965
rollback_ref: "rollback://gepa/candidate",
5066
trace_refs: ["trace://gepa/roundtrip", "trace://candidate/eval"]
5167
}}
5268
end
5369
end
5470

55-
defp buildout_input do
71+
defp runtime_deps do
72+
%RuntimeDeps{optimizer_adapter: GEPA.MezzanineOptimizerAdapter}
73+
end
74+
75+
defp example_refs, do: ["example://gepa/phase-13/1", "example://gepa/phase-13/2"]
76+
77+
defp framework_config do
78+
%{
79+
runtime_ref: "run:gepa:phase13",
80+
task: %{
81+
task_ref: "target://gepa/role-worker",
82+
dataset_ref: "dataset://gepa/phase-13"
83+
},
84+
components: [
85+
%{
86+
component_ref: "component:gepa:mezzanine:1",
87+
kind: :component,
88+
content_ref: "prompt-artifact://gepa/instruction/v1"
89+
}
90+
],
91+
evaluator: %{
92+
evaluator_ref: "eval-suite://gepa/phase-13",
93+
objective_refs: ["eval-suite://gepa/phase-13"]
94+
},
95+
proposer: %{
96+
proposer_ref: "proposer:gepa:mezzanine",
97+
strategy: :deterministic_reflection
98+
},
99+
merge: %{
100+
merge_ref: "merge:gepa:disabled",
101+
strategy: :disabled
102+
},
103+
tracing: %{trace_refs: ["trace://gepa/roundtrip"]},
104+
persistence: %{profile: :memory_ephemeral}
105+
}
106+
end
107+
108+
defp optimization_spec do
109+
%{
110+
run_ref: "optimization-run://gepa/phase-13",
111+
tenant_ref: "tenant://phase-13",
112+
authority_ref: "authority://citadel/optimization/promotion",
113+
target_ref: "target://gepa/role-worker",
114+
framework_run_ref: "run:gepa:phase13",
115+
checkpoint_ref: "checkpoint://gepa/memory",
116+
budget_ref: "budget://optimization",
117+
eval_suite_ref: "eval-suite://gepa/phase-13",
118+
replay_bundle_ref: "replay-bundle://gepa/phase-13",
119+
trace_ref: "trace://gepa/roundtrip",
120+
memory_ref_set: ["memory://gepa/promoted/context"],
121+
prompt_ref_set: ["prompt-artifact://gepa/instruction/v1"],
122+
context_budget_ref: "context-packet://gepa/phase-13",
123+
guardrail_ref_set: ["guardrail://gepa/input", "guardrail://gepa/output"],
124+
cost_budget_ref_set: ["cost://optimization"],
125+
drift_ref_set: ["drift://gepa/window"],
126+
persistence_ref_set: ["persistence://gepa/memory-ephemeral"],
127+
promotion_ref_set: ["promotion://gepa/candidate"],
128+
rollback_ref_set: ["rollback://gepa/candidate"]
129+
}
130+
end
131+
132+
defp framework_projection(framework_result) do
133+
%{
134+
task_ref: "target://gepa/role-worker",
135+
run_ref: framework_result.run_ref,
136+
candidate_refs: framework_result.candidate_refs,
137+
best_candidate_ref: framework_result.best_candidate_ref,
138+
checkpoint: GEPAFramework.Persistence.to_projection(framework_result.checkpoint),
139+
trace_refs: framework_result.trace_refs
140+
}
141+
end
142+
143+
defp appkit_candidate_projection(candidate_receipt) do
56144
%{
57-
task_ref: "task:gepa:phase-8",
58-
dataset_ref: "dataset://gepa/phase-8",
59-
example_refs: ["example://gepa/phase-8/1", "example://gepa/phase-8/2"],
60-
trace_ref: "trace://gepa/roundtrip"
145+
candidate_ref: candidate_receipt.candidate_ref,
146+
run_ref: candidate_receipt.gepa_run_ref,
147+
lineage_refs: candidate_receipt.lineage_refs,
148+
score_refs: [candidate_receipt.objective_score_ref],
149+
eval_refs: candidate_receipt.eval_refs,
150+
replay_refs: ["replay-bundle://gepa/phase-13"],
151+
budget_refs: ["budget://optimization"],
152+
trace_refs: [candidate_receipt.trace_ref],
153+
promotion_refs: candidate_receipt.promotion_refs,
154+
rollback_refs: candidate_receipt.rollback_refs
61155
}
62156
end
63157

@@ -85,7 +179,9 @@ defmodule StackLab.Examples.GEPAPlatformRoundtrip do
85179
optimization_facts: [
86180
%{
87181
candidate_lineage_refs: ["lineage://gepa/candidate"],
88-
eval_dataset_refs: ["dataset://gepa/phase-8"],
182+
context_packet_refs: ["context-packet://gepa/phase-13"],
183+
route_decision_refs: ["target://gepa/role-worker"],
184+
eval_dataset_refs: ["eval-suite://gepa/phase-13"],
89185
proposer_model_ref: "model-profile://mock/proposer",
90186
promotion_gate_refs: [
91187
"gate://eval",
@@ -96,7 +192,10 @@ defmodule StackLab.Examples.GEPAPlatformRoundtrip do
96192
"gate://canary",
97193
"gate://human-approval"
98194
],
195+
citadel_authority_refs: ["authority://citadel/optimization/promotion"],
196+
appkit_projection_refs: ["appkit://optimization/candidate"],
99197
budget_refs: ["budget://optimization"],
198+
cost_refs: ["cost://optimization"],
100199
trace_refs: ["trace://candidate/eval"],
101200
trace_redaction: :redacted,
102201
promotion_refs: ["promotion://gepa/candidate"],

examples/gepa_platform_roundtrip/mix.exs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ defmodule StackLab.GEPAPlatformRoundtrip.MixProject do
2525
defp deps do
2626
[
2727
{:gepa_framework, path: "../../../gepa_framework"},
28-
{:gepa_buildout, path: "../../../gepa_buildout"},
28+
{:mezzanine_optimization_engine, path: "../../../mezzanine/core/optimization_engine"},
29+
{:app_kit_optimization_surface, path: "../../../app_kit/core/optimization_surface"},
2930
{:stack_lab_model_inference_scanner, path: "../../support/model_inference_scanner"},
3031
{:stack_lab_optimization_fabric_scanner, path: "../../support/optimization_fabric_scanner"},
3132
{:stack_lab_ai_run_lineage_scanner, path: "../../support/ai_run_lineage_scanner"},

examples/gepa_platform_roundtrip/mix.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
"ex_doc": {:hex, :ex_doc, "0.40.1", "67542e4b6dde74811cfd580e2c0149b78010fd13001fda7cfeb2b2c2ffb1344d", [:mix], [{:earmark_parser, "~> 1.4.44", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "bcef0e2d360d93ac19f01a85d58f91752d930c0a30e2681145feea6bd3516e00"},
66
"file_system": {:hex, :file_system, "1.1.1", "31864f4685b0148f25bd3fbef2b1228457c0c89024ad67f7a81a3ffbc0bbad3a", [:mix], [], "hexpm", "7a15ff97dfe526aeefb090a7a9d3d03aa907e100e262a0f8f7746b78f8f87a5d"},
77
"jason": {:hex, :jason, "1.4.5", "2e3a008590b0b8d7388c20293e9dcc9cf3e5d642fd2a114e4cbbb52e595d940a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0 or ~> 3.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "b0c823996102bcd0239b3c2444eb00409b72f6a140c1950bc8b457d836b30684"},
8+
"jcs": {:hex, :jcs, "0.2.0", "e0524c23b576e8247f9f5f09d1b82cb3f92c7b132932b82d5d656461831c6c99", [:mix], [{:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "f52e86571f56fab695682bf0ab7fd697768acb20de16b30809e9654d1ec1c9dd"},
89
"makeup": {:hex, :makeup, "1.2.1", "e90ac1c65589ef354378def3ba19d401e739ee7ee06fb47f94c687016e3713d1", [:mix], [{:nimble_parsec, "~> 1.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "d36484867b0bae0fea568d10131197a4c2e47056a6fbe84922bf6ba71c8d17ce"},
910
"makeup_elixir": {:hex, :makeup_elixir, "1.0.1", "e928a4f984e795e41e3abd27bfc09f51db16ab8ba1aebdba2b3a575437efafc2", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "7284900d412a3e5cfd97fdaed4f5ed389b8f2b4cb49efc0eb3bd10e2febf9507"},
1011
"makeup_erlang": {:hex, :makeup_erlang, "1.0.3", "4252d5d4098da7415c390e847c814bad3764c94a814a0b4245176215615e1035", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "953297c02582a33411ac6208f2c6e55f0e870df7f80da724ed613f10e6706afd"},
1112
"nimble_parsec": {:hex, :nimble_parsec, "1.4.2", "8efba0122db06df95bfaa78f791344a89352ba04baedd3849593bfce4d0dc1c6", [:mix], [], "hexpm", "4b21398942dda052b403bbe1da991ccd03a053668d147d53fb8c4e0efe09c973"},
13+
"telemetry": {:hex, :telemetry, "1.4.2", "a0cb522801dffb1c49fe6e30561badffc7b6d0e180db1300df759faa22062855", [:rebar3], [], "hexpm", "928f6495066506077862c0d1646609eed891a4326bee3126ba54b60af61febb1"},
1214
}

examples/gepa_platform_roundtrip/test/stack_lab/examples/gepa_platform_roundtrip_test.exs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@ defmodule StackLab.Examples.GEPAPlatformRoundtripTest do
1414
assert receipt.ai_run_lineage_scan.status == :pass
1515

1616
assert receipt.framework_projection.best_candidate_ref ==
17-
"candidate:component:buildout:instruction:v1"
17+
"candidate:component:gepa:mezzanine:1"
18+
19+
assert receipt.candidate_receipt.candidate_ref ==
20+
receipt.framework_projection.best_candidate_ref
21+
22+
assert receipt.candidate_receipt.context_packet_ref == "context-packet://gepa/phase-13"
23+
assert receipt.candidate_receipt.route_decision_ref == "target://gepa/role-worker"
24+
assert receipt.appkit_projection.candidate_ref == receipt.candidate_receipt.candidate_ref
1825

1926
assert receipt.promotion_ref == "promotion://gepa/candidate"
2027
assert receipt.rollback_ref == "rollback://gepa/candidate"

support/optimization_fabric_scanner/lib/stack_lab/optimization_fabric_scanner.ex

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,15 @@ defmodule StackLab.OptimizationFabricScanner do
3232
@scanner_ref "stack-lab.optimization-fabric-scanner.v1"
3333
@rules [
3434
:candidate_lineage_refs,
35+
:context_packet_refs,
36+
:route_decision_refs,
3537
:eval_dataset_refs,
3638
:proposer_model_ref,
3739
:promotion_gate_refs,
40+
:citadel_authority_refs,
41+
:appkit_projection_refs,
3842
:budget_refs,
43+
:cost_refs,
3944
:trace_refs,
4045
:promotion_refs,
4146
:rollback_refs,

support/optimization_fabric_scanner/test/stack_lab/optimization_fabric_scanner_test.exs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,15 @@ defmodule StackLab.OptimizationFabricScannerTest do
2828

2929
assert Enum.map(receipt.findings, & &1.rule) == [
3030
:candidate_lineage_refs,
31+
:context_packet_refs,
32+
:route_decision_refs,
3133
:eval_dataset_refs,
3234
:proposer_model_ref,
3335
:promotion_gate_refs,
36+
:citadel_authority_refs,
37+
:appkit_projection_refs,
3438
:budget_refs,
39+
:cost_refs,
3540
:trace_refs,
3641
:promotion_refs,
3742
:rollback_refs,
@@ -58,6 +63,8 @@ defmodule StackLab.OptimizationFabricScannerTest do
5863
defp complete_fact do
5964
%{
6065
candidate_lineage_refs: ["lineage://candidate"],
66+
context_packet_refs: ["context-packet://candidate"],
67+
route_decision_refs: ["route-decision://candidate"],
6168
eval_dataset_refs: ["dataset://eval"],
6269
proposer_model_ref: "model-profile://mock/proposer",
6370
promotion_gate_refs: [
@@ -69,7 +76,10 @@ defmodule StackLab.OptimizationFabricScannerTest do
6976
"gate://canary",
7077
"gate://human-approval"
7178
],
79+
citadel_authority_refs: ["authority://citadel/optimization/promotion"],
80+
appkit_projection_refs: ["appkit://optimization/candidate"],
7281
budget_refs: ["budget://optimization"],
82+
cost_refs: ["cost://optimization"],
7383
trace_refs: ["trace://candidate/eval"],
7484
trace_redaction: :redacted,
7585
promotion_refs: ["promotion://candidate"],

0 commit comments

Comments
 (0)