Skip to content

Add unwired Sites evidence capture and assessment adapters - #1263

Merged
sidneyswift merged 2 commits into
mainfrom
codex/sites-evidence-adapters
Nov 17, 2026
Merged

sidneyswift merged 2 commits into
mainfrom
codex/sites-evidence-adapters

Conversation

@sidneyswift

@sidneyswift sidneyswift commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Sites has an exact-candidate evidence predicate but no storage adapters. This adds unwired final-save review capture and scoped read/assessment helpers against Database proposal #136, exact commit 4caac3cc8a15a47b348109b2fa4f571423d8beb0.

Capture uses the returned save revision, reauthorizes the current workspace, checks the complete saved draft, preserves original report/execution hashes, and validates SQL-owned receipt identity. Read assessment independently resolves the authorized current draft or signed working build and calls the existing predicate. Canonical serialization and candidate projection are extracted without changing their bytes; SQL calls remain under lib/supabase/site_publish_evidence and errors never trigger replacement keys or implicit overrides.

No route, workflow, UI, publisher, grant, schema exposure or migration is activated. Working-preview publishing remains advisory. Database #136 stays draft/proposal-only. Artist transitions, full publish/context/paid authorization and explicit override interaction remain separately gated; this is not end-to-end persistence or publication proof. See docs/site-evidence-adapters.md for all 26 SQL proposal seams and their API-test limits.

Validation: 100 focused tests across 7 files, including actual predicate/render-artifact checks, original API canonical golden vectors, mocked RPC failures and existing publish regressions; actual-import focused TypeScript check; repository pnpm lint; changed-file formatting and git diff --check. Independent spec and standards reviews found no actionable findings at exact head 91c2b246801522a6fb3867b44987c20f57b6ea50. Mocked boundaries do not prove live SQL admission, locking or provider/browser execution.

Dependency composition: merged current main commit 5602338c6195152f31a22803fc6b9827778f512c normally, producing 753843b02fe6199f45229cf63e5f41aeaa02423b. All 15 Sites contribution files remain byte-identical to reviewed 91c2b246; all eight Packs fixture/docs/test paths from #1262 and all other main files are preserved. Fresh CI runs against this combined head. The first old-head CI attempt passed 9,905 unit tests but failed the earlier Packs settlement replay timeout; its failure is preserved, not treated as an adapter pass.

Final qualification: combined head 753843b0 is green. Unit workflow 44196104176 checked PR merge 8a469cfc (identical tree to the feature head): 9,907 tests passed / 53 skipped, followed by all offline workflow and type checks. Both independent composition reviews found no findings. The duplicate timestamp findings were dispositioned against the pinned SQL producer, which explicitly formats six fractional digits plus literal Z; both threads are resolved. No activation or merge performed.

@vercel

vercel Bot commented Nov 17, 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 17, 2026 11:05pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Pre-merge checks: Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Solid & Clean Code Warning PR #1263 (recoupable/api, head 753843b, author sidneyswift) adds new Sites evidence code that violates the SOLID & Clean Code criteria. The prior FAIL is confirmed on the current head. No code change… Refactor before merge: 1. Split captureSavedSiteReview into focused single-function files. Examples: assertSavedMatchesCurrentDraft, assertFinalReviewExecution, and verifyStoredSiteEvidence. Keep the orchestrator near 20 lines. 2. S…
Full details: Solid & Clean Code

Explanation

PR #1263 (recoupable/api, head 753843b, author sidneyswift) adds new Sites evidence code that violates the SOLID & Clean Code criteria. The prior FAIL is confirmed on the current head. No code change addresses it. Evidence from the current tree (all files are status A in origin/main...HEAD): 1. SRP and function length - lib/sites/production/captureSavedSiteReview.ts lines 16-82: one exported function of about 67 lines. It validates input, looks up the site, authorizes the workspace, compares saved and current drafts, selects the final review, verifies render artifacts, computes identity, persists, and validates the response. The check flags functions over 20 lines with multiple responsibilities. - lib/sites/production/assessSitePublishEvidence.ts lines 40-123: one exported function of about 84 lines. It handles revision checks, candidate reads, record lookup, time checks, override handling, report verification, viewport checks, and artifact checks. 2. DRY - Site lookup plus authorizeSiteWorkspace appears in captureSavedSiteReview.ts lines 25-27 and in the readCandidate closure of assessStoredSitePublishEvidence.ts lines 21-23. - The render-artifact comparison appears in captureSavedSiteReview.ts lines 43-48 and assessSitePublishEvidence.ts lines 107-112. - The record-identity comparison appears in captureSavedSiteReview.ts lines 72-74 and assessSitePublishEvidence.ts lines 80-81. Both use the same Object.entries(...).some(...) pattern. 3. KISS and clean code - lib/supabase/site_publish_evidence/callSiteEvidenceRpc.ts lines 31-43 use nested ternaries to map error codes and messages. - SQL error codes ("40001", "23505", "42501") and messages are inline literals. Positive points: each new file exports one function whose name matches the file name. The small helpers (serializeSiteEvidence, hashSiteEvidence, getSitePublishIdentity) are focused. The file-name rule passes. Prior claim check: the prior run listed assessSitePublishEvidence.ts as pre-existing. The diff shows it as new, so causality holds for all cited violations. The PR's "unwired" status does not exempt these files from the check.

Resolution

Refactor before merge: 1. Split captureSavedSiteReview into focused single-function files. Examples: assertSavedMatchesCurrentDraft, assertFinalReviewExecution, and verifyStoredSiteEvidence. Keep the orchestrator near 20 lines. 2. Split assessSitePublishEvidence into focused steps. Examples: a revision check, a report verification, and an artifact check. Keep the orchestrator short. 3. Move the record-identity comparison into one shared helper. Move the render-artifact comparison into one shared helper. Call each helper from both the capture path and the assess path. 4. Move the site lookup plus authorizeSiteWorkspace pattern into one shared helper. Use it in assessStoredSitePublishEvidence and captureSavedSiteReview. 5. Replace the nested ternaries in callSiteEvidenceRpc.ts with a named lookup map. Name the SQL error code constants and the error message constants. 6. Put each new function in its own file named after its exported function.

  • 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 17, 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-17T22:52:40.596301Z 91c2b24 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.

@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 15 files

Architecture diagram
sequenceDiagram
    participant Client as Client (final-save caller)
    participant Cap as captureSavedSiteReview
    participant Site as selectSite
    participant Auth as authorizeSiteWorkspace
    participant Pred as assessSitePublishEvidence
    participant Asm as assessStoredSitePublishEvidence
    participant Build as readPublishableBuild
    participant RPC as site_publish_evidence (SQL RPC)
    participant Serial as Serialize/Hash helpers

    Note over Client,Serial: Unwired capture flow (final-save review)
    Client->>Cap: captureSavedSiteReview({accountId, savedSite, operationKey})
    Cap->>Site: selectSite(savedSite.id)
    Site-->>Cap: current site (or null -> 404)
    Cap->>Auth: authorizeSiteWorkspace(accountId, current.owner_id)
    Auth-->>Cap: ownerId (or error -> denied)
    
    alt CHANGED: saved site stale or draft differs
        Cap-->>Client: 409 (no persistence)
    else saved site matches current
        Cap->>Cap: Validate operationKey format & length
        Cap->>Cap: Extract final review from saved draft
        alt Pass without execution evidence
            Cap-->>Client: 409 (reject)
        else Review with evidence
            Cap->>Serial: prepareSiteRenderArtifacts(candidate, journey)
            Serial-->>Cap: actual evidence hashes
            alt Execution hashes mismatch
                Cap-->>Client: 409 (reject, no laundering)
            else Hashes match
                Cap->>Serial: getSitePublishIdentity() / serialize / hash
                Serial-->>Cap: identity (candidateSha256)
                Cap->>RPC: record_evidence(p_actor, p_owner, p_site, p_revision, p_key, p_candidate, p_candidate_canonical, p_candidate_sha, p_decision, p_review_canonical)
                RPC-->>Cap: stored record (SQL-owned ID/time)
                Cap->>Cap: Validate returned record (schema, identity match)
                Cap-->>Client: stored evidence record
            end
        end
    end

    Note over Client,Serial: Assess flow (scoped read)
    Client->>Asm: assessStoredSitePublishEvidence(accountId, request)
    alt No accountId
        Asm-->>Client: unsatisfied(authentication-required)
    else Authenticated
        Asm->>Site: selectSite(siteId)
        Site-->>Asm: site (or error)
        Asm->>Auth: authorizeSiteWorkspace(accountId, site.owner_id)
        Auth-->>Asm: ownerId
        opt generationToken provided
            Asm->>Build: readPublishableBuild(token, site, accountId)
            Build-->>Asm: signed working-build candidate
        end
        Asm->>Pred: assessSitePublishEvidence(request, {readCandidate, readEvidence})
        Pred->>Site: current revision check
        alt Revision mismatch
            Pred-->>Asm: unsatisfied(revision-mismatch)
        else Revision matches
            Pred->>RPC: read_evidence(p_actor, p_owner, p_site, p_record)
            RPC-->>Pred: stored evidence record
            Pred->>Pred: Validate record, compare candidate/report/artifact hashes
            Pred-->>Asm: assessment result (satisfied/unsatisfied)
        end
        Asm-->>Client: assessment result
    end

    Note over RPC: CallSiteEvidenceRpc maps SQL errors:<br/>40001/23505 -> 409,<br/>42501 -> 403,<br/>other/PGRST106/P0001 -> 503.<br/>No retries, no rekey, no fallback.
Loading

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

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

@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: 91c2b24680

ℹ️ 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.

Auto-approved.

@sidneyswift
sidneyswift merged commit 72b628a into main Nov 17, 2026
8 checks passed

This branch was successfully deployed

1 active deployment
Preview — 753843b0 Deployed Nov 17, 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