Class PostgresSandboxExecutionGuard

java.lang.Object
io.agentscope.extensions.postgresql.sandbox.PostgresSandboxExecutionGuard
All Implemented Interfaces:
io.agentscope.harness.agent.sandbox.SandboxExecutionGuard

public final class PostgresSandboxExecutionGuard extends Object implements io.agentscope.harness.agent.sandbox.SandboxExecutionGuard
PostgreSQL advisory-lock-based SandboxExecutionGuard.

Each lock is identified by a 64-bit key derived from the SandboxIsolationKey's scope and value via MurmurHash3. The lock is acquired with pg_advisory_lock(key) and released with pg_advisory_unlock(key).

The lock is tied to the database connection — when the connection closes, the lock is automatically released. The returned SandboxLease.close() calls pg_advisory_unlock(key) and closes the underlying connection.

A configurable timeout is supported by polling pg_try_advisory_lock(key) until the lock is acquired or the timeout expires, matching the semantics of MySQL's GET_LOCK(name, timeout).