From 514f5a969250e9b2bff36ee66879d2639945eac4 Mon Sep 17 00:00:00 2001 From: Eric Rakestraw Date: Wed, 25 Nov 2026 16:19:51 +0000 Subject: [PATCH] Verify concurrent core operation isolation --- docs/roadmap/implementation.md | 5 ++ .../pipeline/concurrent_evaluation_test.go | 70 +++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 internal/framework/pipeline/concurrent_evaluation_test.go diff --git a/docs/roadmap/implementation.md b/docs/roadmap/implementation.md index 76eea57c..8cff7bd0 100644 --- a/docs/roadmap/implementation.md +++ b/docs/roadmap/implementation.md @@ -793,6 +793,11 @@ assembled behavior rather than making compatibility wrappers for failing fixture ## Stage 21 — Verify Cross-Boundary And Concurrent Execution +**Status:** Complete. The specified framework, module, CLI, and preflight +suite passes, as do focused pipeline and reconciliation race checks. Existing +assembled recovery, handoff, capture, admission, and worker tests were reviewed; +a synchronized native-operation test covers concurrent evaluation isolation. + **Goal:** Establish behavior where correctness spans the new owners. **Inspect:** Core executor and stage adapters; existing pipeline worker, operation, diff --git a/internal/framework/pipeline/concurrent_evaluation_test.go b/internal/framework/pipeline/concurrent_evaluation_test.go new file mode 100644 index 00000000..f590be1c --- /dev/null +++ b/internal/framework/pipeline/concurrent_evaluation_test.go @@ -0,0 +1,70 @@ +package pipeline + +import ( + "context" + "fmt" + "testing" + "time" + + "gitea.maximumdirect.net/eric/notarius/internal/framework/contracts" + "go.maximumdirect.net/promptkit" +) + +func TestConcurrentNativeOperationsKeepTheirOwnEvaluations(t *testing.T) { + engine := nativeProducerEngine(t, producerClientFunc(func(_ context.Context, request promptkit.GenerateRequest) (*promptkit.GenerateResponse, error) { + value := 1 + if request.Prompt.SessionID == "second" { + value = 2 + } + return &promptkit.GenerateResponse{Content: fmt.Sprintf(`{"value":%d}`, value)}, nil + })) + ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) + defer cancel() + arrived := make(chan struct{}, 2) + release := make(chan struct{}) + type response struct { + want int + result OperationResult[int] + err error + } + responses := make(chan response, 2) + for _, run := range []struct { + session string + value int + }{{"first", 1}, {"second", 2}} { + go func(session string, want int) { + initial := nativeProducerInitial() + initial.SessionID = session + execution := ExecutionContext[int]{Engine: engine, Controls: contracts.ProducerControls{Mode: contracts.ModeStrict}, Assess: func(ctx context.Context, value int) (contracts.CandidateAssessment, error) { + arrived <- struct{}{} + select { + case <-release: + case <-ctx.Done(): + return contracts.CandidateAssessment{}, ctx.Err() + } + if value != want { + return contracts.CandidateAssessment{}, fmt.Errorf("assessment received %d, expected %d", value, want) + } + return contracts.CandidateAssessment{}, nil + }} + result, err := ExecuteOperation(ctx, execution, func(context.Context) (contracts.PreparedOperation[int], error) { + return contracts.NativeOperation[int]{Initial: initial, Interpret: interpretNumberEvaluation}, nil + }) + responses <- response{want: want, result: result, err: err} + }(run.session, run.value) + } + for range 2 { + select { + case <-arrived: + case <-ctx.Done(): + t.Fatal("concurrent assessments did not arrive") + } + } + close(release) + for range 2 { + got := <-responses + if got.err != nil || got.result.Value != got.want || got.result.Evaluation == nil || got.result.Evaluation.View().Candidate == nil || *got.result.Evaluation.View().Candidate != got.want { + t.Fatalf("operation want=%d result=%#v error=%v", got.want, got.result, got.err) + } + } +}