Skip to content

Persist CommandLayer namespace claim requests in Neon/Postgres#282

Merged
GsCommand merged 1 commit into
mainfrom
codex/upgrade-claim-endpoint-for-persistence
May 22, 2026
Merged

Persist CommandLayer namespace claim requests in Neon/Postgres#282
GsCommand merged 1 commit into
mainfrom
codex/upgrade-claim-endpoint-for-persistence

Conversation

@GsCommand
Copy link
Copy Markdown
Contributor

Motivation

  • Upgrade /api/claim/commandlayer-namespace from validation-only to real persistent claim request creation and lifecycle recording in a Postgres-compatible DB (Neon) so activation requests are stored and auditable.
  • Fail explicitly when storage is not available so the endpoint does not silently fall back to validation-only behavior in production.
  • Keep existing validation rules and avoid adding payment, ENS provisioning, ERC-8004 registration, or persistence of any private key material.

Description

  • Add lib/db.js, a small Neon-compatible DB helper that reads process.env.DATABASE_URL, throws a clear error when missing, lazily requires @neondatabase/serverless, and exports a query helper for serverless use.
  • Update api/claim/commandlayer-namespace.js to retain all existing validation and, when DATABASE_URL is configured, create a transactional persistence flow that inserts into claim_requests, claim_agents, and claim_events, and returns CLAIM_REQUEST_CREATED with a lifecycle payload; the handler returns 503 STORAGE_UNAVAILABLE if DATABASE_URL is missing.
  • Add migration db/migrations/001_claim_requests.sql which creates claim_requests, claim_agents, and claim_events tables plus indexes and enables pgcrypto as requested.
  • Update public/claim.html to reflect the creation UX (show claim id, wallet, agent count) and to show a clear message when storage is unavailable, and add/adjust tests in tests/api-claim-commandlayer-namespace.test.js covering missing DATABASE_URL, pre-DB validation failures, successful mocked persistence, and attempted claim.created event insertion; also declare @neondatabase/serverless in package.json.

Testing

  • Ran npm test which executed the repository tests and all tests passed (42 tests passed).
  • Ran example checks with cd examples/webhook-auto-verify && npm install && npm run check which completed successfully.
  • Ran npm run build which failed because the repository does not define a build script (reported as a missing script).

Codex Task

@vercel
Copy link
Copy Markdown

vercel Bot commented May 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
commandlayer-commandlayer-org Ready Ready Preview, Comment May 22, 2026 8:25pm
commandlayer-org Ready Ready Preview, Comment May 22, 2026 8:25pm
commandlayer-org111 Ready Ready Preview, Comment May 22, 2026 8:25pm

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant