Repository navigation
Add unwired exact-selected Sites publication orchestration - #1265
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Pre-merge checks:
|
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Solid & Clean Code | The check FAILS on SRP, DRY and Clean Code thresholds. I re-verified each claim in the standing failure against current code at HEAD 97b5d6a. All of these files are new in this PR. `git diff --stat 7… | Refactor before merge: 1. Split publishSelectedSiteEvidence into small single-purpose functions. Examples: resolve-and-authorize, obtain the evidence ID (review or override), assess the selected evidence, and publish. Keep the orchestrato… |
Full details: Solid & Clean Code
-
Explanation
The check FAILS on SRP, DRY and Clean Code thresholds. I re-verified each claim in the standing failure against current code at HEAD 97b5d6a. All of these files are new in this PR.
git diff --stat 72b628ac HEAD -- lib/siteslists each as added, so causality is direct. 1.publishSelectedSiteEvidence.tslines 16–92 (77 lines). The check sets a limit of 20 lines per function. This function is about four times that limit. It validates input, resolves candidates, authorizes, inserts overrides, validates receipts, defines an inlineassessclosure, publishes, and validates the publication receipt. That is several responsibilities in one function. It also reassignsresolvedandevidenceIdwithlet. 2. Repeated resolve-and-authorize pair. Lines 25–26 and 78–79 callresolveSelectedSiteCandidatethenauthorizeSelectedSitePublicationwith the same arguments. The pair is not extracted into a helper. This is a DRY violation. 3. RepeatedvalidateSiteOverrideReceiptcall. Lines 37–42 and 58–63 use the same call with the same arguments. This is a DRY violation. 4.resolveSelectedSiteCandidate.tslines 9–43 (about 35 lines). It combines site lookup, workspace authorization, pointer compare-and-set, candidate selection and identity hashing. Line 20 uses an unsafe cast,(site as unknown as Record<string, unknown>).published_evidence_id. 5.authorizeSelectedSitePublication.tslines 12–41 (about 30 lines). It combines brief, artist, organization, entitlement, fan configuration and artist-name checks. Line 35 is a baregetFanOAuthConfig();call. Its result is discarded, so its side effect is implicit. 6.validateSitePublicationReceipt.tslines 34–61 (about 28 lines). It combines schema parsing, identity recomputation and field comparison. Passing checks: - Each new file name matches its exported function name. - The paid-subscription and return-URL logic is extracted and reused. - Nesting stays within three levels. These passing items do not offset the violations above. The standing failure is not addressed. Commit1f2b819fchanges error handling and the artist fence. It does not split the flagged functions, remove the duplicate pair or the duplicate receipt call, remove the discarded call, or replace the unsafe cast.Resolution
Refactor before merge: 1. Split
publishSelectedSiteEvidenceinto small single-purpose functions. Examples: resolve-and-authorize, obtain the evidence ID (review or override), assess the selected evidence, and publish. Keep the orchestrator under 20 lines. 2. Extract the repeatedresolveSelectedSiteCandidate→authorizeSelectedSitePublicationpair into one helper. Call it at both points that need a fresh check. 3. Extract the repeatedvalidateSiteOverrideReceiptcall into one local helper, or keep a single call site. 4. ShortenresolveSelectedSiteCandidate,authorizeSelectedSitePublicationandvalidateSitePublicationReceiptto under 20 lines each. Move the pointer compare-and-set check, candidate selection and field comparisons into named helpers. 5. Replace the discardedgetFanOAuthConfig();call inauthorizeSelectedSitePublication.tswith an explicit, named validation step. Remove it if it is not needed. 6. Replaceas unknown as Record<string, unknown>inresolveSelectedSiteCandidate.tswith a typed or schema-based read ofpublished_evidence_id.
- 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 19 files
Architecture diagram
sequenceDiagram
participant Server as Server (unwired caller)
participant Pub as publishSelectedSiteEvidence
participant Resolve as resolveSelectedSiteCandidate
participant Auth as authorizeSelectedSitePublication
participant Assess as assessSitePublishEvidence
participant SQL as SQL RPC layer
participant DB as Database (proposal #136)
participant Stripe as Stripe Provider
participant Context as Context Provider
participant Fan as Fan Config Store
Note over Server,DB: Unwired exact-selected publication orchestration
Server->>Pub: publishSelectedSiteEvidence(accountId, operationKey, input)
Pub->>Resolve: First resolution pass
Resolve->>DB: selectSite(siteId)
DB-->>Resolve: Site row
Resolve->>Resolve: authorizeSiteWorkspace(accountId, ownerId)
Resolve->>Resolve: Validate pointer/CAS metadata match
alt Has generationToken
Resolve->>Resolve: readPublishableBuild(signed generation)
else Draft preview
Resolve->>Resolve: Use site.draft
end
Resolve->>Resolve: Compute candidate digest, verify against selection
Resolve-->>Pub: Resolved site + candidate + identity
Pub->>Auth: First authority pass
Auth->>Context: readSiteContextBrief(briefId)
Auth->>Auth: Check artist exists and belongs to workspace
Auth->>Stripe: readPaidSiteSubscription(ownerId) [fresh read]
Stripe-->>Auth: Paid entitlement status
Auth->>Fan: getFanOAuthConfig + selectFanConfig(siteId)
Fan-->>Auth: Existing config
Auth->>Auth: resolveSiteFanReturnUrl (validate destination)
Auth-->>Pub: Authority confirmed
alt Override intent
Pub->>SQL: insertSiteOverrideEvidence (create-once capture)
SQL->>DB: record_evidence RPC
DB-->>SQL: Captured override record
SQL-->>Pub: Override receipt
Pub->>Pub: validateSiteOverrideReceipt
else Stored review
Pub->>SQL: selectSitePublishEvidence (later in assess)
end
Pub->>Assess: First assessment pass
Assess->>SQL: selectSitePublishEvidence
SQL-->>Assess: Stored evidence record
Assess->>Assess: Run full predicate (review/override eligibility)
Assess-->>Pub: Assessment satisfied
Pub->>Resolve: Second resolution pass (fresh recheck)
Resolve-->>Pub: Re-resolved site + candidate
Pub->>Auth: Second authority pass (recheck all gates)
Auth-->>Pub: Authority confirmed again
Pub->>Assess: Second assessment pass (repeat)
Assess-->>Pub: Evidence still valid
Pub->>SQL: publishSiteEvidenceCandidate (fixed CAS args)
SQL->>DB: publish_candidate RPC
DB-->>SQL: Publication receipt
SQL-->>Pub: Receipt with immutable stored candidate
Pub->>Pub: validateSitePublicationReceipt
alt Receipt valid
Pub-->>Server: Success with published site + evidence
else Receipt mismatch or SQL conflict
Pub-->>Server: Error propagates (no retry/fallback/rekey)
end
Note over Server,DB: Failure modes fail closed - no implicit overrides
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.
All reported issues were addressed across 19 files (changes from recent commits).
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 4 files (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Requires human review: The orchestration appears deliberately unwired, but omitted diffs prevent verifying that no runtime caller activates it. The proposed SQL artist fence is also outside the diff, so its key publication safeguard cannot be checked.
View guided diff | Turn on auto-fix | Re-trigger cubic
Sites has evidence capture/read adapters but needs publication orchestration bound to the exact selected preview and explicit intent. This adds an unwired orchestrator against Database proposal #136, exact successor
afd214aa73dfd70b0f2b860fce90c12ceb23f28b.The server independently resolves the selected draft or signed working build and requires matching digest/revision/owner/artist plus explicitly nullable publication-pointer metadata. Workspace, Context, artist, paid entitlement and prepared fan configuration are checked before evidence capture and rechecked before publication. A stored review or explicitly requested override runs through the complete existing predicate. SQL receives the immutable record identity, selected digest, expected pointer and expected artist ID; its site-row lock now fences artist changes before publication writes. It publishes the stored candidate, never request-supplied replacement bytes.
Existing advisory publishing remains unchanged. Shared paid, return-URL and capture-envelope transforms are reused. Only the new path opts into Stripe read-error propagation (503 versus a real unpaid402). Missing/malformed pointer or evidence metadata fails closed; errors never become implicit overrides, replacement keys or automatic retries. There is no public route, UI/MCP/workflow caller, new mandatory artist approval, schema exposure, runtime grant, migration or activation. Database #136 stays draft and unmerged.
Remaining gates: external artist access/name, paid entitlement, Context, fan configuration and Workflow reads are not atomic with SQL. Latest-preview races, pointer ABA, explicit selection/override interaction, artist/fan preparation transitions, SQL release/admission and retention remain separate. The expected-artist fence closes the identified site-artist-ID race, not these other policies. Receipt/transport errors can follow a committed publication and must not trigger blind retries. See
docs/site-selected-publication.md.Validation:181 focused/regression tests across16files, actual-import TypeScript check, repository lint, changed-file formatting and diff check. Database proposal:30disposable tests on each PostgreSQL15.10/17.7 (29proposal+1inherited), including artist mismatch/no-write, null semantics and observed lock contention. API boundaries are mocked; actual identity/predicate/golden serialization are exercised. Independent spec/standards reviews cleared exact API
1f2b819f1e01d3e158829a678cd84799f81274b5paired with SQLafd214a. All8initial automated findings are addressed and resolved. Final cleanup head97b5d6a800ad2e77091d388911a1d2381b65a932is fully green: Unit workflow44201131099checked synthetic merge39ec4968with an identical tree, passed9,975tests/53skipped and every later offline/type step. Both independent reviewers cleared the cleanup; all10review threads are resolved. Final Cubic review found zero new issues in its four-file delta scope. Cross-repository authority remains bounded by the paired reviews and documented activation gates.