Pre-launch — Gluecron is in final validation. Public signups and git hosting for non-owner users open after launch review.
CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
claude/adoring-hopper-5x74bqclaude/affectionate-feynman-ykrf1hclaude/architecture-audit-design-wxprenclaude/build-status-update-3MXsfclaude/charming-meitner-mllb5rclaude/compare-gate-gluecron-s4mFQclaude/confident-faraday-tikcwbclaude/continue-work-XMTlIclaude/crontech-gluecron-deploy-7MIECclaude/crontech-platform-setup-SeKfwclaude/design-2026claude/ecstatic-ptolemy-jMdigclaude/enhance-github-integration-QNHdGclaude/fix-aa-loop-issue-PonMQclaude/fix-actions-and-processclaude/fix-desktop-errors-XqoW8claude/fix-red-workflowsclaude/fix-website-access-6FKJNclaude/gatetest-integration-hardeningclaude/github-audit-improvements-bDFr9claude/gluecron-launch-status-FoMRlclaude/hopeful-lamport-olfCTclaude/issue-to-pr-and-protectionsclaude/jolly-heisenberg-2sg1Qclaude/launch-preparation-QmTb6claude/new-session-xk1l7claude/plan-platform-architecture-kkN4yclaude/platform-analysis-roadmap-1nUGLclaude/platform-launch-assessment-8dWV8claude/polish-platform-release-AeDrUclaude/resume-previous-work-KzyLwclaude/review-crontech-handoff-qYEVqclaude/review-project-completeness-lHhS2claude/review-readme-docs-ulqPKclaude/serene-edison-rj87weclaude/setup-multi-repo-dev-BCwNQclaude/ship-fixes-and-tests-Jvz1cclaude/site-audit-competitive-pctlwgclaude/site-migration-vercel-XstpKclaude/standalone-product-repos-XHFTDcopilot/feat-smart-empty-states-keyboard-first-enhancementcopilot/feat-smart-morning-digest-review-context-restorecopilot/fix-and-process-workflowscopilot/update-ai-powered-code-reviewfeat/debt-mapfeat/push-policy-codeowners-hardeningfeat/smart-digest-contextfeat/stage-impactfeat/t1-secret-migrationfeat/u-polishfeat/w-self-hostfeat/w2-claude-configfix/agent-journey-orphan-sweepgatetest/auto-fix-1776586424172gatetest/auto-fix-1776586534814gatetest/auto-fix-1776590685143gatetest/auto-fix-1776590808199mainops/redeploy-retriggerstyle/dxt-cta-themeworktree-agent-a3377aad30d55da26worktree-agent-a7ef607b7ee1d6c74
0058_agent_multiplayer.sql3.3 KB · 72 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
-- Agent multiplayer v1 — per-agent namespacing + leases + budget caps.
--
-- Premise: when 10-100 AI agents push to the same repo, they must not step
-- on each other. Each agent gets a stable `agent_sessions` row with a
-- token, a branch-namespace prefix the git plumbing must enforce, and a
-- daily budget. Coordination on shared resources (issues, PRs, file
-- paths, branches) flows through `agent_leases` — a soft mutex with a
-- TTL. The autopilot resets `spent_cents_today` at midnight UTC and
-- expires stale leases.

CREATE TABLE IF NOT EXISTS agent_sessions (
  id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
  -- Human-facing handle: "claude-1", "holden-mercer", "release-bot". Not
  -- globally unique — uniqueness is enforced per owner_user_id via the
  -- partial index below so multiple humans can each have a "claude-1".
  name text NOT NULL,
  -- The human who manages this agent and pays for its actions.
  owner_user_id uuid NOT NULL REFERENCES users(id) ON DELETE CASCADE,
  -- Optional repo scope. NULL means the agent is global to the owner.
  repository_id uuid REFERENCES repositories(id) ON DELETE CASCADE,
  -- SHA-256 of the plaintext "agt_..." token. Never store plaintext.
  token_hash text NOT NULL UNIQUE,
  -- Branch prefix the git plumbing must enforce on every ref update,
  -- e.g. "agents/claude-1/". Should end with "/" so simple startsWith
  -- checks are unambiguous, but the helper normalises it.
  branch_namespace text NOT NULL,
  -- Daily spend cap in cents. Default $5.00 — enough for routine PR
  -- work, low enough that a runaway agent gets caught fast.
  budget_cents_per_day integer NOT NULL DEFAULT 500,
  spent_cents_today integer NOT NULL DEFAULT 0,
  last_active_at timestamptz,
  created_at timestamptz NOT NULL DEFAULT now()
);

-- An owner can't have two agents with the same name.
CREATE UNIQUE INDEX IF NOT EXISTS agent_sessions_owner_name
  ON agent_sessions (owner_user_id, name);

CREATE INDEX IF NOT EXISTS agent_sessions_owner
  ON agent_sessions (owner_user_id);

CREATE INDEX IF NOT EXISTS agent_sessions_repo
  ON agent_sessions (repository_id)
  WHERE repository_id IS NOT NULL;

CREATE TABLE IF NOT EXISTS agent_leases (
  id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
  agent_session_id uuid NOT NULL REFERENCES agent_sessions(id) ON DELETE CASCADE,
  -- What kind of thing the lease covers — keeps the (type, id) space
  -- naturally partitioned. Vocabulary is open-ended; the lib enforces
  -- the known set.
  target_type text NOT NULL,  -- 'issue' | 'pr' | 'file_path' | 'branch'
  target_id text NOT NULL,
  acquired_at timestamptz NOT NULL DEFAULT now(),
  expires_at timestamptz NOT NULL,
  status text NOT NULL DEFAULT 'active',  -- 'active' | 'released' | 'expired'
  created_at timestamptz NOT NULL DEFAULT now()
);

-- Per-target lookup — answers "who holds the lease on issue 42?" in O(1).
-- Partial unique on the active row prevents two agents holding the same
-- target simultaneously. Released/expired rows don't conflict.
CREATE UNIQUE INDEX IF NOT EXISTS agent_leases_active_target
  ON agent_leases (target_type, target_id)
  WHERE status = 'active';

CREATE INDEX IF NOT EXISTS agent_leases_agent
  ON agent_leases (agent_session_id, status);

CREATE INDEX IF NOT EXISTS agent_leases_expires
  ON agent_leases (expires_at)
  WHERE status = 'active';