MCPcopy
hub / github.com/openai/plugins / claim_handoff_delivery

Function claim_handoff_delivery

plugins/codex-security/scripts/workbench_db.py:1902–1936  ·  view source on GitHub ↗
(
    connection: sqlite3.Connection, args: argparse.Namespace
)

Source from the content-addressed store, hash-verified

1900
1901
1902def claim_handoff_delivery(
1903 connection: sqlite3.Connection, args: argparse.Namespace
1904) -> dict[str, Any]:
1905 scan_id = require_uuid(args.scan_id, "scan-id")
1906 claim_token = require_handoff_claim_token(args.claim_token)
1907 timestamp = now()
1908 with connection:
1909 scan = require_scan(connection, scan_id)
1910 if scan["handoff_status"] != "pending" or scan["handoff_claim_token"] == claim_token:
1911 return workspace_state(connection, scan["workspace_id"])
1912 updated = connection.execute(
1913 """
1914 UPDATE scans
1915 SET handoff_claimed_at = ?, handoff_claim_token = ?, updated_at = ?
1916 WHERE id = ? AND handoff_status = 'pending'
1917 AND (
1918 handoff_claim_token IS NULL
1919 OR (
1920 ? = 1
1921 AND (handoff_claimed_at IS NULL OR handoff_claimed_at <= ?)
1922 )
1923 )
1924 """,
1925 (
1926 timestamp,
1927 claim_token,
1928 timestamp,
1929 scan["id"],
1930 int(args.take_over_stale),
1931 stale_claim_before(),
1932 ),
1933 )
1934 if updated.rowcount != 1:
1935 return workspace_state(connection, scan["workspace_id"])
1936 return workspace_state(connection, scan["workspace_id"])
1937
1938
1939def release_handoff_delivery(

Callers 1

mainFunction · 0.85

Calls 6

require_uuidFunction · 0.90
nowFunction · 0.85
require_scanFunction · 0.85
workspace_stateFunction · 0.85
stale_claim_beforeFunction · 0.85

Tested by

no test coverage detected