Skip to content

Qualify registration domain against disposable SQL proposal - #1271

Merged
sidneyswift merged 5 commits into
mainfrom
codex/application-registration-sql-composition-2104
Nov 18, 2026
Merged

sidneyswift merged 5 commits into
mainfrom
codex/application-registration-sql-composition-2104

Conversation

@sidneyswift

@sidneyswift sidneyswift commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

The registration create/read domain previously had fixture-backed adapter tests but no direct exercise against the reviewed SQL proposal. This adds a standalone disposable PostgreSQL harness that invokes the actual domain with one parameterized SQL function call per storage operation, checks real receipts and explicit authority, and recovers an actual committed response only through original-input replay.

The eight-file slice pins API and inactive Database proposal inputs, admits only the owned PostgreSQL Unix socket, preloads network guards before auth/test code, and reuses the reviewed Database lifecycle supervisor. Native DNS is denied; Vitest receives a fixed synthetic localhost answer. The native socket connector is module-private, protocol/listen denials have explicit assertions, and fault results require matching readiness and cleanup receipts. Ordinary unit discovery excludes this opt-in SQL suite.

The launcher binds physical tracked non-env API bytes/types to the accepted revision, requires its ancestry, and limits cumulative changes to the eight qualification paths. It rejects unexpected tracked/untracked source before workers start, independently of Git index flags, stat caches or clean filters. Existing selected hashes remain additional checks. Environment-file contents are not read.

Accepted API #1270 merge a2a6d6b70644fcda5b89c5bbec281573b2dab9e9 is composed normally. All six incoming files remain byte-identical; only this harness's Vercel source hash was refreshed, with original baseline and accepted-composition provenance retained. Database pins are unchanged.

Validation on final head 988263d81600afd77123cbf23496104ad04b04ee:

  • PostgreSQL 15.10 and 17.7: eight cases each on explicit Node 24.18.0 through the documented minimal env -i parent, with synthetic poison and confirmed worker/postmaster/socket cleanup.
  • Accepted adapter/MCP controlled suite: 61 cases passed.
  • Initialized-Node signal, child-wait timeout and worker-exit controls: expected failures with verified cleanup.
  • Eight source-binding negatives reject four unlisted auth changes, staged edits, assume-unchanged/skip-worktree concealment, and untracked source before worker execution.
  • Scoped static checks and independent exact-source review passed.
  • A separate isolated Node 23.6.1 comparison reproduced the socket/FIFO-stat loader failure and directory-stat repair. Node 22 composition-harness execution remains untested; ordinary CI and the existing controlled adapter job do not establish it.

This adds no production storage factory, public route, MCP/runtime wiring or policy adoption. Database #138 remains unchanged, draft, unmerged and unapplied. Ordinary CI is not execution evidence for this new PostgreSQL composition suite. Source publication only; final merge remains separately gated.


Summary by cubic

Adds a disposable PostgreSQL qualification harness that runs the actual registration create/read domain against the exact inactive Database 138 SQL proposal, replacing fixture-only adapter coverage with real SQL execution.

The suite lives under scripts/application-registration-proposal/sql-composition/ and is excluded from ordinary unit discovery. It pins API and Database source files by SHA-256, reuses the reviewed Database lifecycle supervisor to own a disposable cluster, and denies native DNS, TCP, UDP, and unrelated Unix sockets before auth code loads. Vitest receives a synthetic localhost answer.

  • Executes one parameterized SQL function call per create/read storage operation and validates receipts, explicit read authority, isolation, and denials against real 42501/P0001 errors without classifying failures from message text.
  • Recovers an actual committed response only through original-input replay; outcome_unknown is never inferred as a conflict.
  • Includes fault controls (signal, timeout, worker-exit) that must fail and still report verified worker/postmaster/socket cleanup, with network guard bypass paths closed and fault receipts validated.
  • Qualified on PostgreSQL 15.10 and 17.7 with Node 24.18.0; Node 22 execution remains untested.
  • No production storage factory, route, MCP wiring, or policy adoption; Database 138 remains draft, unmerged, and unapplied.

Written for commit 988263d. Summary will update on new commits.

View guided diff Turn on auto-fix

@vercel

vercel Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated
api Ready Ready Preview Nov 18, 2026 4:33am UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Pre-merge checks: Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Solid & Clean Code Warning The SOLID & Clean Code check fails. The eight new files under scripts/application-registration-proposal/sql-composition/ still contain the violations the standing FAIL cited. The code changed since … Split the orchestration into named, single-purpose units, and make file names match their primary export. 1. socket-guard.mjs: split installNativeOwnedSocketGuard into validateOwnedSocket, assertOwnedLineage, logOwnedLineage, and …
Full details: Solid & Clean Code

Explanation

The SOLID & Clean Code check fails. The eight new files under scripts/application-registration-proposal/sql-composition/ still contain the violations the standing FAIL cited. The code changed since that run, but the violations remain. Evidence from the checked-out head 988263d8: - Function length and SRP, socket-guard.mjs. installOwnedSocketGuard (L72-74) is now a three-line wrapper. Its body moved to installNativeOwnedSocketGuard (L76-146, about 70 lines). That function mixes lease validation (L77-105), parent-lineage checks (L106-109), a console log of lineage data (L110-124), and a monkey-patch of net.Socket.prototype.connect (L125-144). The check sets a limit of 20 lines per function. - File-function name match, socket-guard.mjs. The file exports installOwnedSocketGuard (L72). The file name does not match. The check requires the file name to match its single primary exported function. - Function length and SRP, supervise.py. run_worker (L32-72, about 40 lines) mixes fixture loading, environment construction, scope file writing, fault-descendant spawning and polling (L49-70), and the normal subprocess.run path (L71). main (L75-107) builds a Python trampoline by string concatenation (L92-96). - Size and SRP, run.mjs. The file is now 305 lines, up from 243. It is one top-level script. It mixes argument parsing, source binding, ancestry checks, allow-list construction, committed-diff checks, tracked-blob and untracked scans, Database HEAD verification (inline execFileSync at L160), environment scrubbing, and signal handling (L180-183). Only the two signal handlers are named functions. - DRY, run.mjs. gitRead exists (L62-68), but the Database HEAD check at L160 repeats the execFileSync("/usr/bin/git", ...) pattern inline. The "vitest.config.ts" entry appears twice in the allowedChanges literal (L73 and L81). - DRY, repeated constants. Port 55473 appears in qualification.test.ts (L28) and in socket-guard.mjs (L83, as .s.PGSQL.55473). The count query SELECT count(*)::int AS n FROM application_registration_proposal.applications repeats at L225, L262 and L286. - Length, test file. The main describe block spans roughly L158-L332, about 175 lines. - Magic numbers. Timeouts and deadlines stay inline, for example time.monotonic() + 10, timeout=90, timeout=.3, testTimeout: 15000 and hookTimeout: 15000. None are named constants. The current code does contain some good practice. The dependency-injected storage contract and the explicit error paths are clear. These strengths do not offset the explicit function-length, file-name, and duplication violations above. Because the file-function name rule and the function-length rule are both explicit in the check, the failure is not a matter of style. The check fails on the current code.

Resolution

Split the orchestration into named, single-purpose units, and make file names match their primary export. 1. socket-guard.mjs: split installNativeOwnedSocketGuard into validateOwnedSocket, assertOwnedLineage, logOwnedLineage, and guardSocketConnect. Rename the file to installOwnedSocketGuard.mjs, or rename the export so it matches socket-guard.mjs. Update vitest.config.ts and supervise.py references. 2. supervise.py: split run_worker into start_fault_descendant and run_composition_tests. Move the trampoline text into a template string or a build_trampoline function. 3. run.mjs: extract verifySourceBindings, verifyApiSourceScope, verifyDatabaseHead, buildLaunchEnv, and superviseChild. Keep the top level to a short sequence of calls. Replace the inline Database HEAD execFileSync with gitRead or a parameterized variant. Remove the duplicate "vitest.config.ts" entry. 4. qualification.test.ts: extract a storedApplicationCount() helper. Split the 175-line describe block into smaller describe or helper groups where practical. 5. Define OWNED_PG_PORT = 55473 once in a shared module, and import it in the test file and the socket guard. 6. Name the timeouts and the supervisor deadline as constants, for example WORKER_DEADLINE_MS, FAULT_WAIT_SECONDS, COMPOSITION_TIMEOUT_MS, and VITEST_TEST_TIMEOUT_MS.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T04:20:13.908602Z eb7590b PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eb7590ba2c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 8 files

Architecture diagram
sequenceDiagram
    participant Dev as Developer
    participant Run as run.mjs
    participant Verify as Source Verification
    participant Sup as supervise.py
    participant Life as Database Lifecycle Supervisor
    participant PG as PostgreSQL Cluster
    participant Node as Node/Vitest Worker
    participant Guard as socket-guard.mjs
    participant Domain as Registration Domain
    participant SQL as SQL Function Calls

    Note over Dev,SQL: Disposable SQL Composition Qualification Flow

    Dev->>Run: Execute with absolute paths (env -i)
    Run->>Verify: Validate source bindings (SHA-256)
    Verify-->>Run: All 19 API + 13 DB files match
    Run->>Run: Verify Database git HEAD matches pin
    Run->>Sup: Spawn Python supervisor (detached, clean env)
    
    Sup->>Sup: Scrub env (no credentials, no NODE_OPTIONS)
    Sup->>Life: Import reviewed Database lifecycle module
    Life->>PG: Create disposable UTF8 cluster (no TCP listener)
    Life-->>Sup: Owned Unix socket + worker lease
    
    Sup->>Node: Spawn guarded Node with --import socket-guard.mjs
    
    Node->>Guard: Initialize network denial (pre-auth)
    Guard->>Guard: Block DNS/TCP/UDP/TLS/HTTP
    Guard->>Guard: Allow only synthetic localhost answer for Vitest
    
    Node->>Domain: Load actual create/read domain code
    Domain->>SQL: Register application (single parameterized call)
    SQL-->>Domain: SQL receipt
    Domain->>Node: Return validated receipt
    
    alt Explicit read authority granted
        Node->>Domain: Read application with authority
        Domain->>SQL: Read registration (single call)
        SQL-->>Domain: Confirmed receipt
    else No read authority
        Node->>Domain: Attempt read
        Domain->>SQL: Read denied (42501)
        SQL-->>Domain: SQL authorization error
        Domain->>Node: Map to "denied" failure
    end
    
    Node->>Guard: Validate owned socket lease (dev/ino/uid)
    Guard-->>Node: Owned socket confirmed
    
    Node->>Sup: Report receipts + fixture queries
    Sup->>Life: Release lease via supervise()
    Life->>PG: Verify worker/postmaster/socket cleanup
    Life-->>Sup: Cleanup confirmed
    Sup-->>Run: Exit code 0
    Run->>Run: Remove launch home directory
Loading

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 4 files (changes from recent commits).

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Auto-approved: Adds a disposable PostgreSQL qualification harness that runs the registration create/read domain against the pinned, unapplied Database 138 SQL proposal; all changes are test/tooling-only and ordinary test discovery excludes the suite.

View guided diff | Turn on auto-fix | Re-trigger cubic

@sidneyswift
sidneyswift merged commit 18a6785 into main Nov 18, 2026
11 checks passed

This branch was successfully deployed

1 active deployment
Preview — 988263d8 Deployed Nov 18, 2026 by vercel[bot]
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.

1 participant