Repository navigation
Qualify Sites evidence API against pinned SQL and fix JSONB journey capture - #1266
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Pre-merge checks:
|
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Solid & Clean Code | Summary: The check fails. The PR adds new bridge tooling under scripts/sites-evidence-sql-bridge/ (all files new in commits 54beb4e, 4dcdc4f, ddd614c). That code breaks the explicit file-func… |
1. Fix the file-function name rule: - Rename quoteFixtureLiteral.ts to literal.ts, or rename the export to quoteFixtureLiteral. - Move _worker and main out of run.py. Keep run.py as a thin entry point, or name the module after… |
Full details: Solid & Clean Code
-
Explanation
Summary: The check fails. The PR adds new bridge tooling under
scripts/sites-evidence-sql-bridge/(all files new in commits 54beb4e, 4dcdc4f, ddd614c). That code breaks the explicit file-function name rule, the 20-line function rule, and the constants rule. The production change is small, but it sits inside an already long function. Scope of the change (verified): - Production:lib/sites/production/captureSavedSiteReview.tsalready existed before this PR. Commit 54beb4e adds 7 lines. It adds an inlineexperienceContractSchema.safeParsejourney check and error branch. The function body is still about 65 lines. - Bridge tooling: all bridge files are new in this PR. The directory is test and verification tooling, but the check text does not exclude tooling. Violations still present at HEADddd614c9: 1. File-function name rule (explicit). -quoteFixtureLiteral.ts(added in 4dcdc4f, untouched in ddd614c) exportsliteral. The file name does not match. -run.pydefines two top-level functions,_workerandmain. Neither matches the file namerun. 2. Functions over 20 lines (explicit). Measured with Pythonastfor the Python files and by reading the TypeScript file: -run.pymain(): 92 lines. It mixes argument parsing, self-test, fault dispatch, source pinning, lifecycle, reporting, and cleanup. It neststry/finallyblocks several levels deep. -run.py_worker(): 33 lines. -install_lifecycle.pyinstall_lifecycle(): 52 lines. -stop_owned_cluster.pystop_owned_cluster(): 48 lines. -fixtureSql.tsfixtureSql(): about 50 lines. It validates the socket and marker and runspsql. 3. Repeated values (explicit "use constants"). - Port55473appears infixtureSql.tsline 25. -.s.PGSQL.55473appears instop_owned_cluster.pyline 82 andinstall_lifecycle.pyline 46. - The twointerruptedsignal handlers are near duplicates. They sit inrun.pylines 98-99 andinstall_lifecycle.pylines 73-74. Prior failure disposition: The prior FAIL remains valid for the current state. Some items are resolved: -verify_sources.pywas split intoverify_api.pyandverify_database.py. -lifecycle.pywas split intoinstall_lifecycle.py,quiesce_worker.py, andstop_owned_cluster.py. These items remain open: -quoteFixtureLiteral.tsname mismatch. -run.pymain()length and its two top-level functions. - ThefixtureSql()length. - The duplicated port and socket literals. - The duplicated signal handlers. - The journey-check helper incaptureSavedSiteReview.ts. Positive evidence: The production diff is minimal and reusesexperienceContractSchema. The original report is preserved. The lifecycle split reduced the responsibility count of the largest file.Resolution
- Fix the file-function name rule: - Rename
quoteFixtureLiteral.tstoliteral.ts, or rename the export toquoteFixtureLiteral. - Move_workerandmainout ofrun.py. Keeprun.pyas a thin entry point, or name the module after its single primary function. 2. Reduce long functions to 20 lines or fewer: - Splitrun.pymain()into named steps: pin verification, source load, worker launch, cleanup, and fault assertion. - SplitfixtureSql()into a socket and marker validator and apsqlrunner. - Splitinstall_lifecycle()into one helper per fault mode. - Splitstop_owned_cluster()into smaller steps. 3. Remove duplication: - Define the port55473and the socket file name.s.PGSQL.55473once. Source them fromsources.jsonor a shared constants module, and import them in TypeScript and Python. - Share one signal-handler factory for bothinterruptedhandlers, or keep one handler at the process entry point. 4. Inlib/sites/production/captureSavedSiteReview.ts, extract the journey-artifact check (thesafeParseplus theprepareSiteRenderArtifactscomparison) into a named helper. This keeps the function on one responsibility.
- Fix the file-function name rule: - Rename
- 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.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
1 issue found across 12 files
Confidence score: 4/5
network-deny.tsleaves outbound connections available throughWebSocketandnode:http2, so the offline guarantee is incomplete. Add denials for those entry points.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="scripts/sites-evidence-sql-bridge/network-deny.ts">
<violation number="1" location="scripts/sites-evidence-sql-bridge/network-deny.ts:25">
P3: The deny shim leaves outbound paths open: global `WebSocket` (present on Node 22) and `node:http2` `connect`/`request` are not replaced. Add denials for them so the offline guarantee holds for every network entry point.</violation>
</file>
Architecture diagram
sequenceDiagram
participant CI as CI Workflow
participant Runner as run.py
participant Worker as Isolated Worker
participant PG as PostgreSQL (15/17)
participant Test as Vitest Bridge Suite
participant API as Real API Modules
participant DB as Database Repo
Note over CI,DB: NEW: Offline cross-layer qualification bridge
CI->>Runner: Execute with pinned DB commit
Runner->>Runner: Verify API source SHA-256 hashes
Runner->>DB: git show pinned DB files
DB-->>Runner: Verified source bytes
Runner->>Worker: Spawn with minimal env (no credentials, no dotenv)
Worker->>PG: Bootstrap via SitesEvidence fixture
PG-->>Worker: Disposable cluster + socket marker
Worker->>Test: Launch Vitest bridge suite
Test->>Test: Deny all network APIs
Test->>API: captureSavedSiteReview()
API->>API: parse journey with experienceContractSchema
API->>API: recompute artifacts (NEW: normalize JSONB key order)
API->>Test: Return captured evidence record
Test->>API: assessStoredSitePublishEvidence()
API->>API: validate stored assessment
Test->>API: publishSelectedSiteEvidence()
API->>API: run authority/receipt validators
API->>Test: rpc() envelope stub
Test->>PG: psql (Unix socket, fixed local, no shell)
PG-->>Test: SQL result or SQLSTATE
Test-->>API: Typed RPC response
alt Postcommit response lost/tampered/null
Test->>API: Simulate failure after SQL commit
API->>API: Propagate error, no retry
end
alt Stale revision/pointer/artist injected
Test->>PG: Inject actual competing SQL change
API->>API: CAS fails → 409 (40001)
end
Test->>Runner: All 13 cases pass or fail
Runner->>Runner: Collect evidence + logs
Runner-->>CI: Loader attribution + results
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
1 issue found across 16 files (changes from recent commits).
Confidence score: 5/5
scripts/sites-evidence-sql-bridge/bridge.integration.test.tsis about 298 lines, well over the repo’s 100-line style limit, and the new test adds to it. Split the tests into smaller focused files.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="scripts/sites-evidence-sql-bridge/bridge.integration.test.ts">
<violation number="1" location="scripts/sites-evidence-sql-bridge/bridge.integration.test.ts:227">
P3: Custom agent: **Enforce Clear Code Style and Maintainability Practices**
This file is 298 lines — nearly 3x the 100-line limit required by the repo style rule, and the new test case grows it further. The bulk of the length is the ~90 lines of vi.mock scaffolding plus shared helpers (uid/seed/snapshot/row/vector). Extract those into a fixtures/helpers module (or split the suite by concern) so each file stays near the 100-line limit.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
0 issues found across 8 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 API-to-SQL qualification bridge and fixes JSONB key-order handling during review capture. The runtime fix is narrowly scoped to artifact comparison, preserves the original report and digests, and does not activate publication.
View guided diff | Turn on auto-fix | Re-trigger cubic
Review capture rejected unchanged reports after PostgreSQL JSONB reordered journey keys. Capture now uses the existing journey schema for artifact comparison, matching assessment, while preserving the original report and digests.
The offline bridge executes actual capture, stored assessment, selected publication and typed RPC wrappers against unchanged Database #136 at
afd214aa73dfd70b0f2b860fce90c12ceb23f28b. It verifies/freeze-loads 31 API modules and verifies 16 Database/bootstrap sources. External authority/provider reads are explicit synthetic seams; no PostgREST exposure, hosted authentication, provider acceptance or publication activation is claimed.The parent owns disposable directory leases, quiesces its dedicated worker group, independently identifies/stops PostgreSQL by the exact registered data directory, and verifies process/socket absence before deleting files. Uncertain cleanup preserves evidence. Lifecycle responsibilities and source verifiers are separate modules.
Validation at
ddd614c998ffdbc837f8bfde58333350c36d648c:The stale-marker negative covers old output reuse, not foreign root/worker marker injection at the current-root read path. Those identity comparisons are source-reviewed guards. Database #136 remains draft and unapplied; no SQL proposal, route/factory wiring or activation changes. Root retains merge/release approval.