Skip to content

Add dormant Pack worker fences and durable receipt ordering - #1286

Open
sidneyswift wants to merge 5 commits into
mainfrom
codex/pack-worker-fence-2269
Open

sidneyswift wants to merge 5 commits into
mainfrom
codex/pack-worker-fence-2269

Conversation

@sidneyswift

@sidneyswift sidneyswift commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Delayed Pack workers can write after their execution or claim changes. This pair adds dormant protocol-2 fences, exact replay/context CAS, and independently committed bounded provider observations before active phase writes.

Successor checks are green; renewed root source acceptance is pending. The prior API0f5f/Database186 acceptance was withdrawn after post-ready findings. Root owns all merges; do not reuse that old acceptance.

Current paired heads:

Post-ready repairs check action/context/attempt/replay before expiry, prevent precharged submission IDs and premature completion, fence bound dispatch uncertainty, replay expired settlement exactly, and restrict receipt append isolation. API foundation writes retain observed and own-acknowledged versions across the complete batch, rejecting competing changes in both new and saved-foundation paths. Receipt response validation and qualification oracles are stricter. SQL remains an inactive proposal outside migration/deployment runners.

Validation:35 actual disposable PostgreSQL tests including11 legacy controls;424 scoped API tests;6 separately run actual API/SQL cases including concurrent foundation CAS; required Pack/production types and lint; actual compiled SDK failure/replay checks with25 source bindings and0runtime network attempts. Current GitHub Actions pass, including full API tests, workflow fixtures and durable-port compilation. Database automated successor review found0newissues. API successor review found one nonblocking hypothetical multi-asset fixture extension, explicitly deferred against the current single-asset contract. All42 inline threads have evidence-backed dispositions; advisory suggestions are not claimed implemented.

Independent Catalog Database successor review passed. The independent Context foundation successor re-review and renewed whole-pair root acceptance remain separate gates. Original red evidence is preserved; green checks do not replace those decisions.

No hosted SQL, migration publication/apply, provider/config/renderer activation, paid live execution or App2269 closure is authorized or claimed. Public REST/MCP and legacy execution remain protocol1 without a new stale-worker guarantee.

@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:45pm 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 Summary: The PR still breaks the check's function-length and single-responsibility rules at head ebd885f0aa895746713722e712fe58264aa0c034. The prior FAIL claims hold. I verified each one against… 1. Split preparePackFoundationBatch (lines 10–121) into single-purpose step functions. Put each function in a file named after it. Keep each function at or under 20 lines. 2. Split runBoundedPackProduction (lines 33–94). Move the worker…
Full details: Solid & Clean Code

Explanation

Summary: The PR still breaks the check's function-length and single-responsibility rules at head ebd885f0aa895746713722e712fe58264aa0c034. The prior FAIL claims hold. I verified each one against the current code. The base is 60af5644. Evidence (PR-introduced code): - lib/content/packs/foundation/preparePackFoundationBatch.ts is a new file. Its exported preparePackFoundationBatch spans lines 10–121, which is 112 lines. The check sets a 20-line limit. The function loads, validates, plans, persists, produces, re-reads, binds, and handles references. That is several responsibilities in one function. - lib/content/packs/runBoundedPackProduction.ts is a new file. Its runBoundedPackProduction spans lines 33–94, which is 62 lines. It mixes a worker pool, protocol-2 branches, failure handling, and settlement. The worker closure sits inside it (lines 58–71). - lib/content/packs/processPackOperation.ts is modified. processPackOperation spans lines 39–255, which is 217 lines. The PR adds protocol2 branching to it (line 56). - app/workflows/packs/foundation/createPackFoundationServices.ts is a new file. Its createPackFoundationServices spans lines 15–83, which is 69 lines. - app/workflows/packs/releasePackWorkflow.ts is modified. The diff against base adds actor.packProtocol === 2 branches at lines 18, 29, 40, and 47. It also adds a protocol-2 throw in the catch block. The legacy workflow therefore gained protocol-specific logic. - app/workflows/packs/producePackAssetStep.ts is modified. The diff adds protocol-2 checks, argument building, and claim logic at lines 20–43 inside the legacy step. - packProtocol === 2 checks are repeated across at least 10 files. Examples include preparePackStep.ts, createPackFoundationServices.ts, runBoundedPackProduction.ts, preparePackFoundationBatch.ts, and createPackProductionServices.ts. No single policy helper centralizes them. Assessment against the check: - SRP: new functions exceed 20 lines and combine several responsibilities. - OCP: existing legacy workflow functions were modified to add protocol-2 branches, rather than extending through new modules. - DRY and KISS: the repeated packProtocol === 2 branching is not consolidated behind a policy helper. The PR's database tests, API cases, and CI results do not address these structural criteria.

Resolution

  1. Split preparePackFoundationBatch (lines 10–121) into single-purpose step functions. Put each function in a file named after it. Keep each function at or under 20 lines. 2. Split runBoundedPackProduction (lines 33–94). Move the worker pool into its own file. Move the protocol-2 path into a separate module or strategy. Keep the legacy path unchanged. 3. In app/workflows/packs/releasePackWorkflow.ts and app/workflows/packs/producePackAssetStep.ts, restore the legacy path to match base 60af5644. Put the protocol-2 path in a separate module. Do not add packProtocol === 2 branches to legacy functions. 4. Replace the repeated packProtocol === 2 checks with one policy helper, such as getPackProtocolPolicy(actor). Use it at each site. 5. In lib/content/packs/processPackOperation.ts, move protocol-2 argument building into one helper. Split the 217-line processPackOperation by responsibility. 6. Split the other new functions over 20 lines, including createPackFoundationServices (69 lines) and the functions in lib/content/packs/composePackMedia.ts and lib/content/packs/lyrics/. 7. Re-run this check. Confirm that no function added by this PR exceeds 20 lines and that legacy workflow functions have no added protocol branches.
  • 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-18T16:30:44.076838Z 0f5f2ff Draft marked ready
ℹ️ 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.

@sidneyswift

Copy link
Copy Markdown
Contributor Author

Review disposition at API head 0f5f2ff68c6578d6c6b978409a2bcc6df76c6dce, base 30c4d442c75137fa803802091dbb3991f4646e8b:

The CodeRabbit “SOLID & Clean Code” comment is a nonblocking advisory, not a fixed finding. Its comparison against 60af5644 includes earlier accepted work. preparePackFoundationBatch.ts is byte-identical to the actual base (blob f0631911ebfeb5e1414f33d54411582830076e1f); the lyric directory has no diff; runBoundedPackProduction.ts already exists at base.

The actual added protocol branches merit review. They preserve legacy call shapes while carrying original execution/claim identity and enforcing different failure handling for protocol 2. Shared identity/payload logic is already in purpose-named fence helpers. Replacing explicit boundary checks with a strategy or universal policy object is an optional architectural refactor, not a demonstrated correctness repair.

The repository config sets this check to mode: warning, asks reviewers to “look for” functions over 20 lines, and separately recommends under 50 lines for domain functions. It does not impose the comment’s absolute 20-line limit. The AGENTS one-primary-export-per-purpose-named-file rule is preserved. Scheduler length remains a maintainability consideration; splitting its shared stop/drain state solely for a line count would broaden this safety-sensitive contribution.

An independent source reviewer checked this disposition against the actual diff/config and found no blocking structural issue. No code or test changes were made for this advisory. Functional/creation-race review closure and current-head CI remain separately recorded; this is not rollout approval.

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

Architecture diagram
sequenceDiagram
    participant Client as Client (REST/MCP)
    participant API as processPackOperation
    participant WF as releasePackWorkflow
    participant S as Pack Steps (prepare/produce/settle)
    participant PG as PostgreSQL (v2 RPC)
    participant OB as Provider Observation Journal
    participant FP as FAL/AI Provider

    Note over Client,PG: Protocol 2 dormant internal opt-in only<br/>Public/legacy remain protocol 1

    Client->>API: Pack operation request (protocol 2 admission)
    API->>API: Validate protocol 2 identity (transition)

    alt Protocol 2 flow
        API->>PG: approve/run with execution fence
        PG-->>API: Admitted job with execution identity
        
        API->>PG: run command (v2 RPC with fence)
        PG-->>API: Confirm dispatch
        
        API->>WF: Start workflow with execution fence
    else Protocol 1 flow
        API->>PG: Approve/run (original path)
        PG-->>API: Job
        API->>WF: Start workflow (original args)
    end

    WF->>S: preparePackStep(execution)
    S->>PG: run command (v2: with original identity)
    PG-->>S: Saved job
    S->>S: Verify execution identity matches original
    alt Identity mismatch
        S->>S: Throw PackFenceError
    end

    loop Each pending asset
        S->>PG: claim (v2: with fence + deterministic request_id)
        PG-->>S: Claim result (original claim ID)
        
        S->>FP: submit provider request
        FP-->>S: Request ID accepted
        
        S->>OB: append observation (accepted state)
        OB-->>S: Saved confirmation
        
        S->>PG: phase update (with fence + context version)
        PG-->>S: Phase saved
        
        S->>FP: poll/retrieve result
        FP-->>S: Result data
        
        S->>OB: append observation (completed state with SHA256)
        OB-->>S: Saved confirmation
        
        S->>PG: finish_asset (with claim fence)
        PG-->>S: Asset completed
    end

    S->>PG: settle (v2: with execution identity)
    PG-->>S: Settlement result

    alt Settlement acknowledgement lost
        S->>S: No retry (zero-retry bounded step)
    end

    Note over S,PG: Any PackFenceError stops workflow<br/>No automatic resubmission/fallback
Loading

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

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

Comment thread scripts/pack-fence-postgres/run.py Resolved
Comment thread scripts/pack-fence-postgres/run.py Resolved
Comment thread scripts/pack-fence-postgres/run.py Resolved

@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 27 files (changes from recent commits).

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

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

This branch was successfully deployed

1 active deployment
Preview — ebd885f0 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