Skip to content

fix(agent): propagate custom-agent request cancellation - #2330

Merged
DeliciousBuding merged 1 commit into
masterfrom
fix/custom-agent-request-context
Sep 6, 2026
Merged

fix(agent): propagate custom-agent request cancellation#2330
DeliciousBuding merged 1 commit into
masterfrom
fix/custom-agent-request-context

Conversation

@DeliciousBuding

@DeliciousBuding DeliciousBuding commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

Closes #2329
Refs #2256 (only the custom-agent request-context slice; other candidates remain open).

  • Bind all six custom-agent CRUD database operations to the supplied request context, without changing the shared GORM handle, service signatures, ownership checks, or Timeout lifecycle synchronization.
  • L0 asserts persisted data for canceled create/list/update/delete and cancellation after the ownership SELECT.
  • L1 runs the real HTTP handler/service/repository against PostgreSQL with a table lock and a dedicated single-connection pool. Both a deadline and client disconnect must finish server-side work and unblock a queued caller while that lock remains held.

Evidence

  • Red before fix: all six new L0 subcases failed; canceled create/update/delete still mutated persisted rows.
  • Red L1: after cancellation plus a 2 s observation window, both modes still held the only connection (InUse=1, Idle=0, one queued caller). SQL completed only after fixture cleanup released the lock.
  • Green focused L0/L1: canceled mutations, normal CRUD, narrow-update/ownership and structured-output regressions pass. On one Windows/amd64 Go 1.26.5 run with PostgreSQL 16 and Redis 7, observed cancellation-to-release was about 24 ms for the 1 s deadline and 6 ms for client disconnect; HTTP deadline returned 504. These are isolated L1 observations, not production throughput claims.
  • Linux/amd64 CGO race: full service/agent, repository, and middleware packages pass.
  • Hub go vet and staticcheck 2026.1 pass; doc-SSOT, CI-policy and diff checks pass.
  • Full Linux Hub L0 (go test ./... -short -count=1) passes. Full PostgreSQL + Redis L1 with -race passes (33.339 s test runtime); both new cancellation cases also pass under race. Migration 0040 PostgreSQL audit also passes (2 tests). Required CI gates are checked separately before merge.

Environment / not claimed

The local Windows CGO compiler probe fails independently of the changed code; CGO=0 cannot run existing go-sqlite3 tests, so it is not accepted as a full-L0 substitute. Linux CGO/race is used instead and Windows CI remains required. An existing integration helper hard-codes localhost:5432, so a temporary loopback relay targets the disposable fixture for the full local L1 suite. No production or development service, credentials, DNS/ACL, runtime configuration, or deployment was changed. Identity in this test is a fixture; no L3/L4 claim.

Bind every custom-agent CRUD database operation to the caller context. Cover canceled mutations and the ownership-read boundary in L0; prove HTTP deadline/disconnect releases blocked PostgreSQL queries and pool capacity before unlock in L1.

Refs #2329
Refs #2256

Co-authored-by: Codex <codex@vectorcontrol.tech>
@coderabbitai

coderabbitai Bot commented Sep 6, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: 70aac7c3-b62d-45ed-a6f2-a5f42085352b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@DeliciousBuding
DeliciousBuding marked this pull request as ready for review September 6, 2026 04:42
@DeliciousBuding
DeliciousBuding merged commit 97c5146 into master Sep 6, 2026
41 checks passed
@DeliciousBuding
DeliciousBuding deleted the fix/custom-agent-request-context branch September 6, 2026 04:48
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.

fix(agent): propagate custom-agent request cancellation to database operations

1 participant