Skip to content

Scope golden liveness errors to the exact response request - #178

Merged
lawrencecchen merged 3 commits into
mainfrom
fix/golden-exact-connection-errors
Aug 5, 2026
Merged

lawrencecchen merged 3 commits into
mainfrom
fix/golden-exact-connection-errors

Conversation

@lawrencecchen

@lawrencecchen lawrencecchen commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

The staging golden gate observed a healthy accepted Responses connection emitting paced chunks every 500 ms, but an unrelated Codex metadata GET returned 502 on another connection. The aggregate observer error count incorrectly invalidated exact-connection liveness and caused a safe rollback.\n\nThis records observer error identities and scopes liveness, turn validation, and summaries to Responses requests while retaining fail-closed behavior for the exact request and all evidence-recording failures.\n\nVerification:\n- regression test fails on the test-only commit and passes with the fix\n- focused observer package tests pass\n- both timing-sensitive failures from the first concurrent full run pass in isolation\n- serialized full suite is running


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Scopes golden observer liveness, validation, and closure to the exact /v1/responses request/connection so unrelated proxy errors don’t trigger false failures. Keeps fail-closed behavior for the affected request and for evidence recording errors.

  • Bug Fixes
    • Store observer errors as events in observerStats and add errorSnapshot().
    • Add observerScopedErrorCount() and observerResponseErrorCount() to filter by path/connection/request.
    • Scope checks in waitGoldenObserverRequestConnectionsClosed (still fails on response errors), waitGoldenConnectionResponseChunkAfter, validateObserverTurns, and summarizeGoldenSession.
    • Add regression tests for liveness, validation, and observer closure: ignore unrelated request errors; still fail on response request errors and recording_error.

Written for commit 6f973e6. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Bug Fixes

    • Improved observer validation by distinguishing response-related errors from unrelated request errors.
    • Response connection checks now remain valid when errors occur on unrelated requests.
    • Recording errors and errors affecting the response request continue to correctly invalidate validation.
    • Error reporting and session summaries now accurately include relevant errors, including resumed sessions.
  • Tests

    • Added regression coverage for response connection liveness and scoped observer error handling.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

Observer error scoping

Layer / File(s) Summary
Record observer error events
cmd/subrouter-transport-observer/main.go
Observer statistics store error events instead of only a count. Snapshot methods derive counts and return copied events.
Apply scoped validation
cmd/subrouter-transport-observer/golden.go, cmd/subrouter-transport-observer/golden_migration_transition.go
Validation filters recording errors and response-endpoint proxy errors by target request IDs.
Aggregate response errors and regressions
cmd/subrouter-transport-observer/golden.go, cmd/subrouter-transport-observer/golden_acceptance_regression_test.go
Session summaries include response errors from initial and resumed observers. Regression tests cover unrelated, response-specific, and recording errors.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Observer
  participant GoldenValidation
  participant ResponseConnection
  Observer->>GoldenValidation: provide recorded transport errors
  GoldenValidation->>GoldenValidation: filter errors by request ID and response endpoint
  GoldenValidation->>ResponseConnection: validate response liveness
  GoldenValidation->>GoldenValidation: aggregate response errors across observers
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: scoping golden liveness errors to the exact Responses request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/golden-exact-connection-errors

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cmd/subrouter-transport-observer/golden.go`:
- Around line 3026-3043: Update observerResponseErrorCount and its
turn-validation call sites around the validated response flow to scope proxy
errors by request IDs from validatedGoldenResponseRequests, while retaining
recording_error handling. Pass the validated request-ID set into
observerScopedErrorCount for turn validation, but preserve endpoint-wide
aggregation for session summaries. Add a regression test covering two Responses
request IDs on one observer, ensuring an error for the unrelated ID does not
fail the validated request.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ca26a2bc-9063-4e56-9bd0-2a30b4eaa7a1

📥 Commits

Reviewing files that changed from the base of the PR and between 70394a8 and c050246.

📒 Files selected for processing (4)
  • cmd/subrouter-transport-observer/golden.go
  • cmd/subrouter-transport-observer/golden_acceptance_regression_test.go
  • cmd/subrouter-transport-observer/golden_migration_transition.go
  • cmd/subrouter-transport-observer/main.go

Comment on lines +3026 to +3043
func observerScopedErrorCount(stats *observerStats, matchesProxyError func(transportEvent) bool) int {
if stats == nil {
return 1
}
count := 0
for _, event := range stats.errorSnapshot() {
if event.Kind == "recording_error" ||
(event.Kind == "proxy_error" && matchesProxyError != nil && matchesProxyError(event)) {
count++
}
}
return count
}

func observerResponseErrorCount(stats *observerStats) int {
return observerScopedErrorCount(stats, func(event transportEvent) bool {
return event.Path == "/v1/responses" || event.Path == "/responses"
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Scope response-turn errors to validated request IDs.

observerResponseErrorCount filters only by Path. If the observer records a proxy_error for a different /v1/responses request, Line 3261 fails the healthy validated request.

Build a request-ID set from validatedGoldenResponseRequests. Pass that set to observerScopedErrorCount for turn validation. Keep endpoint-wide aggregation for session summaries.

Add a regression test with two Responses request IDs on one observer. The unrelated request error must not fail the validated request.

Also applies to: 3260-3261

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmd/subrouter-transport-observer/golden.go` around lines 3026 - 3043, Update
observerResponseErrorCount and its turn-validation call sites around the
validated response flow to scope proxy errors by request IDs from
validatedGoldenResponseRequests, while retaining recording_error handling. Pass
the validated request-ID set into observerScopedErrorCount for turn validation,
but preserve endpoint-wide aggregation for session summaries. Add a regression
test covering two Responses request IDs on one observer, ensuring an error for
the unrelated ID does not fail the validated request.

@lawrencecchen
lawrencecchen merged commit 93c2288 into main Aug 5, 2026
7 checks passed
@lawrencecchen
lawrencecchen deleted the fix/golden-exact-connection-errors branch August 5, 2026 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant