Repository navigation
Add unwired Sites evidence capture and assessment adapters - #1263
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Pre-merge checks:
|
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Solid & Clean Code | 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.tslines 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.tslines 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 plusauthorizeSiteWorkspaceappears incaptureSavedSiteReview.tslines 25-27 and in thereadCandidateclosure ofassessStoredSitePublishEvidence.tslines 21-23. - The render-artifact comparison appears incaptureSavedSiteReview.tslines 43-48 andassessSitePublishEvidence.tslines 107-112. - The record-identity comparison appears incaptureSavedSiteReview.tslines 72-74 andassessSitePublishEvidence.tslines 80-81. Both use the sameObject.entries(...).some(...)pattern. 3. KISS and clean code -lib/supabase/site_publish_evidence/callSiteEvidenceRpc.tslines 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 listedassessSitePublishEvidence.tsas 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
captureSavedSiteReviewinto focused single-function files. Examples:assertSavedMatchesCurrentDraft,assertFinalReviewExecution, andverifyStoredSiteEvidence. Keep the orchestrator near 20 lines. 2. SplitassessSitePublishEvidenceinto 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 plusauthorizeSiteWorkspacepattern into one shared helper. Use it inassessStoredSitePublishEvidenceandcaptureSavedSiteReview. 5. Replace the nested ternaries incallSiteEvidenceRpc.tswith 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.
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.
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.
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.
💡 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".
…tes-evidence-adapters
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_evidenceand 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.mdfor 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 andgit diff --check. Independent spec and standards reviews found no actionable findings at exact head91c2b246801522a6fb3867b44987c20f57b6ea50. Mocked boundaries do not prove live SQL admission, locking or provider/browser execution.Dependency composition: merged current
maincommit5602338c6195152f31a22803fc6b9827778f512cnormally, producing753843b02fe6199f45229cf63e5f41aeaa02423b. All 15 Sites contribution files remain byte-identical to reviewed91c2b246; 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
753843b0is green. Unit workflow44196104176checked PR merge8a469cfc(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.