Skip to content

Comments

feat: implement worker deprecation with graceful shutdown#188

Merged
jumski merged 13 commits intomainfrom
worker-deprecation
Aug 4, 2025
Merged

feat: implement worker deprecation with graceful shutdown#188
jumski merged 13 commits intomainfrom
worker-deprecation

Conversation

@jumski
Copy link
Contributor

@jumski jumski commented Jul 21, 2025

Summary

  • Implemented worker deprecation feature to enable graceful shutdown and zero-downtime deployments
  • Workers now check for deprecation status via heartbeat and stop processing new messages when marked as deprecated
  • Refactored heartbeat functionality by inlining it into lifecycle classes for better type safety

Key Changes

Database Schema

  • Renamed stopped_at column to deprecated_at in the workers table to better reflect the worker state

Core Implementation

  • Removed separate Heartbeat class: Inlined heartbeat logic directly into WorkerLifecycle and FlowWorkerLifecycle classes to improve type safety and eliminate need for type casting
  • Added deprecated state: Workers now have a "deprecated" state that allows them to finish current work but stop accepting new messages
  • Heartbeat improvements: Made heartbeat interval configurable and added deprecation detection in heartbeat responses

Testing

  • Added comprehensive unit tests for deprecation behavior in both WorkerLifecycle and FlowWorkerLifecycle
  • Added integration tests covering:
    • Basic deprecation flow
    • Multiple worker coordination during deprecation
    • In-flight message completion after deprecation
    • Post-deprecation message routing to new workers
  • Fixed database connection issues in tests (standardized on port 5432 for integration tests)
  • Improved type safety in test mocks by eliminating any casts

Other Improvements

  • Fixed SQL connection management in e2e tests to prevent connection leaks
  • Updated example cron worker to use new lifecycle pattern
  • Fixed linting issues across the codebase

Test Plan

  • Unit tests pass for WorkerLifecycle deprecation
  • Unit tests pass for FlowWorkerLifecycle deprecation
  • Integration tests pass for worker deprecation scenarios
  • Integration tests pass for flow worker deprecation
  • All linting checks pass
  • Manual testing of deprecation flow

Breaking Changes

None - the deprecation feature is backward compatible. Existing workers will continue to function normally.

Summary by CodeRabbit

  • New Features

    • Added worker deprecation functionality, allowing workers to gracefully stop accepting new tasks while completing ongoing work before shutdown.
    • Workers now periodically check for deprecation status and transition states accordingly, supporting zero-downtime deployments.
    • Heartbeat interval is now configurable.
  • Bug Fixes

    • Improved resource management in tests by ensuring SQL clients are properly created and closed.
  • Tests

    • Introduced comprehensive integration and unit tests to verify worker deprecation, heartbeat handling, and lifecycle state transitions.
  • Refactor

    • Internalized heartbeat logic within lifecycle management, removing external dependencies and improving type safety.
    • Updated database schema and type definitions to use deprecated_at instead of stopped_at for worker records.

@changeset-bot
Copy link

changeset-bot bot commented Jul 21, 2025

🦋 Changeset detected

Latest commit: 09ea1f9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@pgflow/edge-worker Patch
@pgflow/core Patch
pgflow Patch
@pgflow/client Patch
@pgflow/example-flows Patch
@pgflow/dsl Patch
@pgflow/website Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 21, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This change introduces a comprehensive worker deprecation mechanism for zero-downtime deployments. Workers now check their deprecation status via heartbeat signals and stop accepting new tasks when deprecated, completing in-flight work before shutdown. The database schema and related type definitions are updated to track deprecation, and extensive tests are added for deprecation scenarios.

Changes

Files/Paths Change Summary
pkgs/edge-worker/src/core/Heartbeat.ts Removed the Heartbeat class and its logic.
pkgs/edge-worker/src/core/WorkerLifecycle.ts,
pkgs/edge-worker/src/flow/FlowWorkerLifecycle.ts
Refactored to internalize heartbeat logic, add deprecation state handling, new config for heartbeat interval, and state transition methods.
pkgs/edge-worker/src/core/WorkerState.ts Added Deprecated state, updated transitions, and new isDeprecated getter.
pkgs/edge-worker/src/core/Queries.ts Changed heartbeat to return deprecation status; updated deprecation column usage.
pkgs/edge-worker/src/core/types.ts,
pkgs/core/src/database-types.ts
Renamed stopped_at to deprecated_at in types and interfaces.
pkgs/core/schemas/0055_tables_workers.sql,
pkgs/core/supabase/migrations/20250719205006_pgflow_worker_deprecation.sql
Renamed stopped_at column to deprecated_at in the database schema and added migration.
examples/playground/supabase/functions/pgflow-cron-worker/index.ts Replaced use of Heartbeat class with manual heartbeat timing and deprecation checks.
pkgs/edge-worker/src/core/Worker.ts Added check to exit loop if worker is deprecated after heartbeat.
pkgs/edge-worker/tests/integration/deprecation.test.ts,
pkgs/edge-worker/tests/integration/deprecation_simple.test.ts,
pkgs/edge-worker/tests/integration/flow_deprecation.test.ts
Added new integration tests for worker and flow deprecation scenarios.
pkgs/edge-worker/tests/unit/WorkerLifecycle.deprecation.test.ts,
pkgs/edge-worker/tests/unit/FlowWorkerLifecycle.deprecation.test.ts,
pkgs/edge-worker/tests/unit/WorkerState.test.ts
Added/updated unit tests for deprecation state transitions and heartbeat logic.
pkgs/edge-worker/tests/integration/creating_queue.test.ts Updated test to check deprecated_at instead of stopped_at.
pkgs/edge-worker/tests/sql.ts,
pkgs/edge-worker/tests/db.ts,
pkgs/edge-worker/tests/e2e/_helpers.ts,
pkgs/edge-worker/tests/e2e/performance.test.ts,
pkgs/edge-worker/tests/e2e/restarts.test.ts,
pkgs/edge-worker/tests/integration/_helpers.ts
Refactored SQL connection handling and updated connection details.
.claude/settings.json Allowed new Bash command pattern for Deno tests.

Sequence Diagram(s)

sequenceDiagram
    participant Worker
    participant DB
    participant Heartbeat (internal)
    participant TaskQueue

    loop Every heartbeatInterval
        Worker->>Heartbeat (internal): sendHeartbeat()
        Heartbeat (internal)->>DB: Update last_heartbeat_at, get deprecated_at
        DB-->>Heartbeat (internal): { is_deprecated }
        alt is_deprecated == true
            Heartbeat (internal)->>Worker: transitionToDeprecated()
            Worker->>TaskQueue: Stop polling for new tasks
            Worker->>TaskQueue: Complete in-flight tasks
            Worker->>DB: Mark worker as deprecated
            Worker->>Worker: Shutdown after in-flight tasks complete
        else is_deprecated == false
            Heartbeat (internal)->>Worker: Continue normal operation
        end
    end
Loading

Possibly related PRs

Poem

🐇
A heartbeat thumps, a worker sighs,
Deprecation comes, it waves goodbye.
No new tasks—just finish the rest,
For zero downtime, we do our best.
With careful checks and gentle pace,
The code now leaves without a trace!
🌱

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch worker-deprecation

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@nx-cloud
Copy link

nx-cloud bot commented Jul 21, 2025

View your CI Pipeline Execution ↗ for commit 09ea1f9

Command Status Duration Result
nx run-many -t build --projects client,dsl --co... ✅ Succeeded 4s View ↗
nx affected -t build --configuration=production... ✅ Succeeded 4s View ↗
nx affected -t lint typecheck test --parallel -... ✅ Succeeded 6m 1s View ↗

☁️ Nx Cloud last updated this comment at 2025-08-04 17:24:33 UTC

@jumski
Copy link
Contributor Author

jumski commented Jul 21, 2025

@CodeRabbit full review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 21, 2025

✅ Actions performed

Full review triggered.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (11)
examples/playground/supabase/functions/pgflow-cron-worker/index.ts (1)

112-127: Consider the deprecation strategy for cron workers.

The current approach logs deprecation but continues processing. For cron workers with scheduled invocations, you might want to:

  1. Complete the current batch and exit gracefully
  2. Skip new batch processing if deprecated

Consider implementing a more definitive deprecation response based on your deployment strategy.

pkgs/edge-worker/src/core/WorkerLifecycle.ts (1)

53-58: Track this technical debt for future resolution.

The commented-out onWorkerStopped query indicates a timing issue with worker termination. While the heartbeat-based approach works, consider:

  1. Creating an issue to track this technical debt
  2. Investigating graceful shutdown mechanisms that allow cleanup queries to complete

Would you like me to create an issue to track this technical debt?

pkgs/edge-worker/src/flow/FlowWorkerLifecycle.ts (1)

7-10: Add JSDoc documentation for the configuration interface.

Document the purpose and units (milliseconds) for better developer experience.

+/**
+ * Configuration options for FlowWorkerLifecycle
+ */
 export interface FlowLifecycleConfig {
+  /**
+   * Interval in milliseconds between heartbeat signals. Default: 5000ms
+   */
   heartbeatInterval?: number;
 }
pkgs/edge-worker/tests/integration/flow_deprecation.test.ts (2)

95-97: Remove console.log or use proper test logging.

Console output in tests can clutter test results.

     // Wait for heartbeat to detect deprecation
-    console.log('Waiting for deprecation detection...');
+    // Waiting for deprecation detection (heartbeat interval + buffer)
     await delay(6000);

198-199: Remove debug console.log statements.

Debug output should be removed from committed test code.

-    console.log('Worker 1 executed:', worker1Executions);
-    console.log('Worker 2 executed:', worker2Executions);
     
     // Deprecate all workers for this flow (simulating deployment)
     await sql`
       UPDATE pgflow.workers 
       SET deprecated_at = NOW() 
       WHERE queue_name = ${queueName}
         AND deprecated_at IS NULL
     `;

     // Wait for heartbeat detection
-    console.log('Waiting for all workers to detect deprecation...');
+    // Wait for all workers to detect deprecation (heartbeat interval + buffer)
     await delay(6000);

Also applies to: 210-211

pkgs/edge-worker/tests/integration/deprecation_simple.test.ts (3)

77-79: Remove console.log and document the delay reason.

     // Wait for heartbeat to detect deprecation (heartbeat interval is 5 seconds)
-    console.log('Waiting for heartbeat to detect deprecation...');
+    // Adding 1s buffer to 5s heartbeat interval
     await delay(6000);

102-102: Remove debug console.log statement.

-    console.log(`Queue count: ${queueMessages[0].count}, Archive count: ${archiveMessages[0].count}`);

201-202: Remove all debug console.log statements.

-    console.log('Worker1 processed:', worker1Messages);
-    console.log('Worker2 processed:', worker2Messages);

     // Check initial archive count
     const archiveCountBefore = await sql`
       SELECT COUNT(*) as count FROM ${sql(`pgmq.a_${queueName}`)}
     `;
     assertEquals(Number(archiveCountBefore[0].count), firstBatch.length, 'First batch should be archived');

     // Deprecate all workers for this function (simulating deployment)
     await sql`
       UPDATE pgflow.workers 
       SET deprecated_at = NOW() 
       WHERE function_name = ${functionName}
         AND deprecated_at IS NULL
     `;

     // Wait for heartbeat detection (5s interval + buffer)
-    console.log('Waiting for all workers to detect deprecation...');
     await delay(6000);
     
     // Add more messages after deprecation
     const secondBatch = ['multi5', 'multi6', 'multi7', 'multi8'];
     for (const msgId of secondBatch) {
       await sql`SELECT pgmq.send(${queueName}::text, ${JSON.stringify({ id: msgId })}::jsonb)`;
     }
     
     // Wait longer to ensure workers would have polled if they were still active
     await delay(3000);
     
     // Verify no new messages were processed by either worker
     const totalProcessedAfter = worker1Messages.length + worker2Messages.length;
     assertEquals(
       totalProcessedAfter,
       totalProcessedBefore,
       'No new messages should be processed after deprecation'
     );
     
     // Check queue and archive counts
     const queueCount = await sql`
       SELECT COUNT(*) as count FROM ${sql(`pgmq.q_${queueName}`)}
     `;
     
     const archiveCountAfter = await sql`
       SELECT COUNT(*) as count FROM ${sql(`pgmq.a_${queueName}`)}
     `;
     
-    console.log(`Queue count: ${queueCount[0].count}, Archive count: ${archiveCountAfter[0].count}`);

Also applies to: 219-219, 248-248

pkgs/edge-worker/tests/integration/deprecation.test.ts (3)

26-26: Remove all debug console.log statements for cleaner test output.

Remove the following console.log statements:

  • Line 26: Processing message log
  • Line 31: Processed message log
  • Line 64: Processed messages log
  • Lines 76-77: Deprecation detection log
  • Line 83: Worker deprecated_at log
  • Line 90: Added second batch log
  • Line 96: Final processed messages log
  • Lines 112-113: Queue and archive messages logs

These debug statements clutter test output and should be removed from committed code.

Also applies to: 31-31, 64-64, 76-77, 83-83, 90-90, 96-96, 112-113


142-280: Excellent test for in-flight message handling!

This test effectively validates that messages already being processed complete even after deprecation. Consider removing the console.log statements on lines 217-218, 249-250, and 268-269 for cleaner output.


365-366: Remove debug console.log statements from multi-worker test.

Remove console.log statements on:

  • Lines 365-366: Worker processed messages
  • Lines 389-392: Final message counts
  • Lines 413-414: Queue and archive messages
  • Lines 431-432: Second batch location logs

Also applies to: 389-392, 413-414, 431-432

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 342f50a and 2c1b606.

⛔ Files ignored due to path filters (1)
  • pkgs/core/supabase/migrations/atlas.sum is excluded by !**/*.sum
📒 Files selected for processing (26)
  • .changeset/calm-ties-give.md (1 hunks)
  • .claude/settings.json (1 hunks)
  • examples/playground/supabase/functions/pgflow-cron-worker/index.ts (3 hunks)
  • pkgs/core/schemas/0055_tables_workers.sql (1 hunks)
  • pkgs/core/src/database-types.ts (1 hunks)
  • pkgs/core/supabase/migrations/20250719205006_pgflow_worker_deprecation.sql (1 hunks)
  • pkgs/edge-worker/src/core/Heartbeat.ts (0 hunks)
  • pkgs/edge-worker/src/core/Queries.ts (1 hunks)
  • pkgs/edge-worker/src/core/Worker.ts (1 hunks)
  • pkgs/edge-worker/src/core/WorkerLifecycle.ts (3 hunks)
  • pkgs/edge-worker/src/core/WorkerState.ts (3 hunks)
  • pkgs/edge-worker/src/core/types.ts (1 hunks)
  • pkgs/edge-worker/src/flow/FlowWorkerLifecycle.ts (3 hunks)
  • pkgs/edge-worker/tests/db.ts (2 hunks)
  • pkgs/edge-worker/tests/e2e/_helpers.ts (4 hunks)
  • pkgs/edge-worker/tests/e2e/performance.test.ts (3 hunks)
  • pkgs/edge-worker/tests/e2e/restarts.test.ts (3 hunks)
  • pkgs/edge-worker/tests/integration/_helpers.ts (1 hunks)
  • pkgs/edge-worker/tests/integration/creating_queue.test.ts (1 hunks)
  • pkgs/edge-worker/tests/integration/deprecation.test.ts (1 hunks)
  • pkgs/edge-worker/tests/integration/deprecation_simple.test.ts (1 hunks)
  • pkgs/edge-worker/tests/integration/flow_deprecation.test.ts (1 hunks)
  • pkgs/edge-worker/tests/sql.ts (2 hunks)
  • pkgs/edge-worker/tests/unit/FlowWorkerLifecycle.deprecation.test.ts (1 hunks)
  • pkgs/edge-worker/tests/unit/WorkerLifecycle.deprecation.test.ts (1 hunks)
  • pkgs/edge-worker/tests/unit/WorkerState.test.ts (2 hunks)
💤 Files with no reviewable changes (1)
  • pkgs/edge-worker/src/core/Heartbeat.ts
🧰 Additional context used
🧠 Learnings (24)
pkgs/edge-worker/tests/integration/_helpers.ts (7)
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : When adding configuration options, provide sensible defaults.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/src/**/*.{ts,tsx} : Make changes to TypeScript files in the 'src/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/integration/**/*.{ts,tsx} : Integration tests should be placed in 'tests/integration/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/e2e/**/*.{ts,tsx} : E2E tests should be placed in 'tests/e2e/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/unit/**/*.{ts,tsx} : Unit tests should be placed in 'tests/unit/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : Follow TypeScript strict mode with proper type annotations.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: examples/playground/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:53:04.790Z
Learning: Use Supabase for backend with Edge Functions.
pkgs/core/supabase/migrations/20250719205006_pgflow_worker_deprecation.sql (3)
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/client/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:53:40.127Z
Learning: Applies to pkgs/client/pkgs/core/schemas/**/*.sql : Use SECURITY DEFINER for pgflow functions that need to access internal tables
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/client/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:53:40.127Z
Learning: Applies to pkgs/client/pkgs/core/schemas/**/*.sql : Grant only minimal required permissions to the API user (anon role) for pgflow schema, functions, and tables
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/client/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:53:40.127Z
Learning: Applies to pkgs/client/supabase/config.toml : The supabase/config.toml file must include '[api] schemas = ["public", "graphql_public", "pgflow"]' to allow integration tests to access the pgflow schema
pkgs/core/schemas/0055_tables_workers.sql (2)
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/client/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:53:40.127Z
Learning: Applies to pkgs/client/pkgs/core/schemas/**/*.sql : Use SECURITY DEFINER for pgflow functions that need to access internal tables
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/client/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:53:40.127Z
Learning: Applies to pkgs/client/pkgs/core/schemas/**/*.sql : Grant only minimal required permissions to the API user (anon role) for pgflow schema, functions, and tables
pkgs/edge-worker/src/core/types.ts (6)
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/src/**/*.{ts,tsx} : Make changes to TypeScript files in the 'src/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : Follow TypeScript strict mode with proper type annotations.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : When adding configuration options, provide sensible defaults.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/e2e/**/*.{ts,tsx} : E2E tests should be placed in 'tests/e2e/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/integration/**/*.{ts,tsx} : Integration tests should be placed in 'tests/integration/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/unit/**/*.{ts,tsx} : Unit tests should be placed in 'tests/unit/' directory.
pkgs/edge-worker/src/core/Worker.ts (5)
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : When adding configuration options, provide sensible defaults.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/src/**/*.{ts,tsx} : Make changes to TypeScript files in the 'src/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : Follow TypeScript strict mode with proper type annotations.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Keep Edge Worker lightweight - heavy logic should go in the SQL Core (Layer 2).
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Remember that Edge Worker is stateless and can restart at any time.
pkgs/edge-worker/tests/db.ts (6)
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/src/**/*.{ts,tsx} : Make changes to TypeScript files in the 'src/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/integration/**/*.{ts,tsx} : Integration tests should be placed in 'tests/integration/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/e2e/**/*.{ts,tsx} : E2E tests should be placed in 'tests/e2e/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : When adding configuration options, provide sensible defaults.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/unit/**/*.{ts,tsx} : Unit tests should be placed in 'tests/unit/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : Follow TypeScript strict mode with proper type annotations.
pkgs/edge-worker/tests/e2e/restarts.test.ts (7)
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/e2e/**/*.{ts,tsx} : E2E tests should be placed in 'tests/e2e/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/src/**/*.{ts,tsx} : Make changes to TypeScript files in the 'src/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/integration/**/*.{ts,tsx} : Integration tests should be placed in 'tests/integration/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/unit/**/*.{ts,tsx} : Unit tests should be placed in 'tests/unit/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : Follow TypeScript strict mode with proper type annotations.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : When adding configuration options, provide sensible defaults.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/client/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:53:40.127Z
Learning: Applies to pkgs/client/packages/client/**/*.{test,spec}.{ts,tsx} : Write comprehensive tests for all client functionality
pkgs/edge-worker/tests/integration/creating_queue.test.ts (6)
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/integration/**/*.{ts,tsx} : Integration tests should be placed in 'tests/integration/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/e2e/**/*.{ts,tsx} : E2E tests should be placed in 'tests/e2e/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/src/**/*.{ts,tsx} : Make changes to TypeScript files in the 'src/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/unit/**/*.{ts,tsx} : Unit tests should be placed in 'tests/unit/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : When adding configuration options, provide sensible defaults.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : Follow TypeScript strict mode with proper type annotations.
pkgs/edge-worker/tests/unit/WorkerState.test.ts (6)
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/unit/**/*.{ts,tsx} : Unit tests should be placed in 'tests/unit/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/e2e/**/*.{ts,tsx} : E2E tests should be placed in 'tests/e2e/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/integration/**/*.{ts,tsx} : Integration tests should be placed in 'tests/integration/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/src/**/*.{ts,tsx} : Make changes to TypeScript files in the 'src/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : Follow TypeScript strict mode with proper type annotations.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : When adding configuration options, provide sensible defaults.
pkgs/edge-worker/tests/sql.ts (6)
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/src/**/*.{ts,tsx} : Make changes to TypeScript files in the 'src/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : Follow TypeScript strict mode with proper type annotations.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/e2e/**/*.{ts,tsx} : E2E tests should be placed in 'tests/e2e/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : When adding configuration options, provide sensible defaults.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/unit/**/*.{ts,tsx} : Unit tests should be placed in 'tests/unit/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/integration/**/*.{ts,tsx} : Integration tests should be placed in 'tests/integration/' directory.
.changeset/calm-ties-give.md (2)
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : When adding configuration options, provide sensible defaults.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Keep Edge Worker lightweight - heavy logic should go in the SQL Core (Layer 2).
pkgs/edge-worker/tests/e2e/performance.test.ts (8)
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/e2e/**/*.{ts,tsx} : E2E tests should be placed in 'tests/e2e/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/src/**/*.{ts,tsx} : Make changes to TypeScript files in the 'src/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Keep Edge Worker lightweight - heavy logic should go in the SQL Core (Layer 2).
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : Follow TypeScript strict mode with proper type annotations.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/unit/**/*.{ts,tsx} : Unit tests should be placed in 'tests/unit/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/integration/**/*.{ts,tsx} : Integration tests should be placed in 'tests/integration/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : When adding configuration options, provide sensible defaults.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/client/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:53:40.127Z
Learning: Applies to pkgs/client/packages/client/**/*.{test,spec}.{ts,tsx} : Write comprehensive tests for all client functionality
pkgs/core/src/database-types.ts (4)
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : Follow TypeScript strict mode with proper type annotations.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/src/**/*.{ts,tsx} : Make changes to TypeScript files in the 'src/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/client/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:53:40.127Z
Learning: Applies to pkgs/client/pkgs/core/schemas/**/*.sql : Use SECURITY DEFINER for pgflow functions that need to access internal tables
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/client/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:53:40.127Z
Learning: Applies to pkgs/client/pkgs/core/schemas/**/*.sql : Grant only minimal required permissions to the API user (anon role) for pgflow schema, functions, and tables
pkgs/edge-worker/tests/e2e/_helpers.ts (10)
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/src/**/*.{ts,tsx} : Make changes to TypeScript files in the 'src/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/e2e/**/*.{ts,tsx} : E2E tests should be placed in 'tests/e2e/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : Follow TypeScript strict mode with proper type annotations.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : When adding configuration options, provide sensible defaults.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Keep Edge Worker lightweight - heavy logic should go in the SQL Core (Layer 2).
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/unit/**/*.{ts,tsx} : Unit tests should be placed in 'tests/unit/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/integration/**/*.{ts,tsx} : Integration tests should be placed in 'tests/integration/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/client/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:53:40.127Z
Learning: Applies to pkgs/client/packages/client/**/*.{test,spec}.{ts,tsx} : Write comprehensive tests for all client functionality
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/client/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:53:40.127Z
Learning: Applies to pkgs/client/pkgs/core/schemas/**/*.sql : Use SECURITY DEFINER for pgflow functions that need to access internal tables
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : The name of the project should only ever be used as lowercase: pgflow. Never use: pgFlow, PgFlow, Pgflow, PGFlow. The only exception is in class names, where 'Pgflow' can be used (PascalCase).
pkgs/edge-worker/src/core/WorkerState.ts (4)
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : Follow TypeScript strict mode with proper type annotations.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/src/**/*.{ts,tsx} : Make changes to TypeScript files in the 'src/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : When adding configuration options, provide sensible defaults.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Remember that Edge Worker is stateless and can restart at any time.
pkgs/edge-worker/tests/unit/WorkerLifecycle.deprecation.test.ts (7)
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/integration/**/*.{ts,tsx} : Integration tests should be placed in 'tests/integration/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/unit/**/*.{ts,tsx} : Unit tests should be placed in 'tests/unit/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/e2e/**/*.{ts,tsx} : E2E tests should be placed in 'tests/e2e/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/src/**/*.{ts,tsx} : Make changes to TypeScript files in the 'src/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : Follow TypeScript strict mode with proper type annotations.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : When adding configuration options, provide sensible defaults.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/client/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:53:40.127Z
Learning: Applies to pkgs/client/packages/client/**/*.{test,spec}.{ts,tsx} : Write comprehensive tests for all client functionality
examples/playground/supabase/functions/pgflow-cron-worker/index.ts (1)
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : The name of the project should only ever be used as lowercase: pgflow. Never use: pgFlow, PgFlow, Pgflow, PGFlow. The only exception is in class names, where 'Pgflow' can be used (PascalCase).
pkgs/edge-worker/src/core/Queries.ts (4)
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/src/**/*.{ts,tsx} : Make changes to TypeScript files in the 'src/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : When adding configuration options, provide sensible defaults.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : Follow TypeScript strict mode with proper type annotations.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Keep Edge Worker lightweight - heavy logic should go in the SQL Core (Layer 2).
pkgs/edge-worker/src/core/WorkerLifecycle.ts (3)
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : When adding configuration options, provide sensible defaults.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/src/**/*.{ts,tsx} : Make changes to TypeScript files in the 'src/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Keep Edge Worker lightweight - heavy logic should go in the SQL Core (Layer 2).
pkgs/edge-worker/tests/unit/FlowWorkerLifecycle.deprecation.test.ts (8)
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/integration/**/*.{ts,tsx} : Integration tests should be placed in 'tests/integration/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/unit/**/*.{ts,tsx} : Unit tests should be placed in 'tests/unit/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/e2e/**/*.{ts,tsx} : E2E tests should be placed in 'tests/e2e/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/src/**/*.{ts,tsx} : Make changes to TypeScript files in the 'src/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : Follow TypeScript strict mode with proper type annotations.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : When adding configuration options, provide sensible defaults.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/client/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:53:40.127Z
Learning: Applies to pkgs/client/packages/client/**/*.{test,spec}.{ts,tsx} : Write comprehensive tests for all client functionality
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : The name of the project should only ever be used as lowercase: pgflow. Never use: pgFlow, PgFlow, Pgflow, PGFlow. The only exception is in class names, where 'Pgflow' can be used (PascalCase).
pkgs/edge-worker/src/flow/FlowWorkerLifecycle.ts (3)
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : When adding configuration options, provide sensible defaults.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : The name of the project should only ever be used as lowercase: pgflow. Never use: pgFlow, PgFlow, Pgflow, PGFlow. The only exception is in class names, where 'Pgflow' can be used (PascalCase).
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/src/**/*.{ts,tsx} : Make changes to TypeScript files in the 'src/' directory.
pkgs/edge-worker/tests/integration/flow_deprecation.test.ts (7)
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/integration/**/*.{ts,tsx} : Integration tests should be placed in 'tests/integration/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/e2e/**/*.{ts,tsx} : E2E tests should be placed in 'tests/e2e/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/unit/**/*.{ts,tsx} : Unit tests should be placed in 'tests/unit/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/src/**/*.{ts,tsx} : Make changes to TypeScript files in the 'src/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : Follow TypeScript strict mode with proper type annotations.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : When adding configuration options, provide sensible defaults.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/client/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:53:40.127Z
Learning: Applies to pkgs/client/packages/client/**/*.{test,spec}.{ts,tsx} : Write comprehensive tests for all client functionality
pkgs/edge-worker/tests/integration/deprecation_simple.test.ts (8)
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/integration/**/*.{ts,tsx} : Integration tests should be placed in 'tests/integration/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/e2e/**/*.{ts,tsx} : E2E tests should be placed in 'tests/e2e/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/unit/**/*.{ts,tsx} : Unit tests should be placed in 'tests/unit/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/src/**/*.{ts,tsx} : Make changes to TypeScript files in the 'src/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : Follow TypeScript strict mode with proper type annotations.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : When adding configuration options, provide sensible defaults.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/client/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:53:40.127Z
Learning: Applies to pkgs/client/packages/client/**/*.{test,spec}.{ts,tsx} : Write comprehensive tests for all client functionality
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Keep Edge Worker lightweight - heavy logic should go in the SQL Core (Layer 2).
pkgs/edge-worker/tests/integration/deprecation.test.ts (7)
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/integration/**/*.{ts,tsx} : Integration tests should be placed in 'tests/integration/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/e2e/**/*.{ts,tsx} : E2E tests should be placed in 'tests/e2e/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/tests/unit/**/*.{ts,tsx} : Unit tests should be placed in 'tests/unit/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/src/**/*.{ts,tsx} : Make changes to TypeScript files in the 'src/' directory.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : Follow TypeScript strict mode with proper type annotations.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/edge-worker/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:54:04.123Z
Learning: Applies to pkgs/edge-worker/**/*.{ts,tsx} : When adding configuration options, provide sensible defaults.
Learnt from: CR
PR: pgflow-dev/pgflow#0
File: pkgs/client/CLAUDE.md:0-0
Timestamp: 2025-07-02T15:53:40.127Z
Learning: Applies to pkgs/client/packages/client/**/*.{test,spec}.{ts,tsx} : Write comprehensive tests for all client functionality
🧬 Code Graph Analysis (6)
pkgs/edge-worker/tests/e2e/restarts.test.ts (2)
pkgs/edge-worker/tests/sql.ts (1)
  • withSql (33-42)
pkgs/edge-worker/tests/e2e/_helpers.ts (1)
  • startWorker (149-158)
pkgs/edge-worker/tests/unit/WorkerState.test.ts (1)
pkgs/edge-worker/src/core/WorkerState.ts (1)
  • WorkerState (42-97)
pkgs/edge-worker/tests/e2e/performance.test.ts (2)
pkgs/edge-worker/tests/sql.ts (2)
  • withSql (33-42)
  • createSql (5-12)
pkgs/edge-worker/tests/e2e/_helpers.ts (3)
  • startWorker (149-158)
  • waitFor (16-41)
  • log (12-14)
examples/playground/supabase/functions/pgflow-cron-worker/index.ts (3)
pkgs/edge-worker/tests/unit/FlowWorkerLifecycle.deprecation.test.ts (1)
  • sendHeartbeat (38-41)
pkgs/edge-worker/src/core/WorkerLifecycle.ts (1)
  • sendHeartbeat (76-92)
pkgs/edge-worker/src/flow/FlowWorkerLifecycle.ts (1)
  • sendHeartbeat (80-96)
pkgs/edge-worker/src/core/Queries.ts (1)
pkgs/edge-worker/src/core/types.ts (1)
  • WorkerRow (41-48)
pkgs/edge-worker/tests/integration/deprecation.test.ts (4)
pkgs/edge-worker/tests/db.ts (1)
  • withTransaction (13-57)
pkgs/edge-worker/tests/fakes.ts (1)
  • createFakeLogger (12-12)
pkgs/edge-worker/tests/integration/_helpers.ts (1)
  • createTestPlatformAdapter (30-47)
pkgs/edge-worker/src/core/types.ts (1)
  • WorkerRow (41-48)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build-and-test
🔇 Additional comments (51)
.claude/settings.json (1)

5-5: LGTM! Proper permission addition for Deno test support.

The addition of the "Bash(deno test:*)" permission correctly enables the new Deno test suites introduced for worker deprecation functionality. This follows the existing permission pattern and supports the comprehensive test coverage mentioned in the PR objectives.

pkgs/edge-worker/tests/integration/_helpers.ts (1)

13-13: LGTM! Database connection standardization improves test reliability.

Replacing localhost with 127.0.0.1 in the database URL avoids potential DNS resolution issues in test environments and aligns with the broader standardization effort mentioned in the PR.

pkgs/core/supabase/migrations/20250719205006_pgflow_worker_deprecation.sql (1)

1-2: LGTM! Clean column rename migration for deprecation semantics.

The migration correctly renames stopped_at to deprecated_at to better reflect the new worker deprecation functionality. The simple ALTER TABLE approach is appropriate for this semantic change.

Note: Since this is a column rename without data transformation, existing timestamps will be preserved, which is the expected behavior for this feature.

pkgs/core/schemas/0055_tables_workers.sql (1)

8-8: LGTM! Schema definition aligns with migration.

The column rename from stopped_at to deprecated_at correctly maintains the same type (timestamptz) and nullability while supporting the new deprecation semantics. This change is consistent with the corresponding migration file.

pkgs/edge-worker/src/core/types.ts (1)

45-45: LGTM! Type definition consistently updated for deprecation semantics.

The property rename from stopped_at to deprecated_at in the WorkerRow type correctly maintains the same type signature (string | null) while aligning with the database schema changes. This ensures type safety and consistency across the entire stack for the new worker deprecation feature.

pkgs/edge-worker/tests/db.ts (1)

16-16: LGTM: Database connection standardization

The change from localhost to 127.0.0.1 improves test reliability by avoiding potential DNS resolution issues and aligns with the standardization effort across the test suite.

Also applies to: 62-62

pkgs/edge-worker/src/core/Worker.ts (1)

49-54: Well-designed deprecation detection flow

The deprecation check is strategically placed after the heartbeat (which likely updates the deprecation status) but before batch processing. This ensures workers can detect their deprecation promptly and stop accepting new work while completing the current iteration cleanly.

pkgs/edge-worker/tests/e2e/restarts.test.ts (1)

1-1: Improved SQL connection lifecycle management

The refactoring to use withSql wrapper ensures proper connection cleanup and eliminates the risk of connection leaks. This aligns with the broader test infrastructure improvements across the codebase.

Also applies to: 18-18, 53-53

pkgs/edge-worker/tests/integration/creating_queue.test.ts (1)

65-65: Correct schema alignment with worker deprecation

The update from stopped_at IS NULL to deprecated_at IS NULL properly reflects the database schema change where the worker status column was renamed to support the new deprecation functionality.

pkgs/edge-worker/tests/sql.ts (2)

3-3: Database connection standardization

Using the standard PostgreSQL port 5432 and IP address 127.0.0.1 improves test reliability and consistency across the test suite.


44-44: Improved resource management by removing global SQL instance

Removing the global sql export encourages proper connection lifecycle management through the withSql and withRollback patterns, reducing the risk of connection leaks in tests.

pkgs/edge-worker/src/core/Queries.ts (2)

25-34: LGTM: Correctly updates deprecated_at instead of stopped_at.

The change from stopped_at to deprecated_at aligns with the database schema migration and the new worker deprecation functionality. The method continues to update both the deprecation timestamp and last heartbeat timestamp as expected.


36-45: LGTM: Properly implements heartbeat-based deprecation detection.

The method now correctly returns deprecation status by checking if deprecated_at is non-null. The fallback to { is_deprecated: false } handles cases where no worker row is returned. This enables workers to detect their deprecation status and transition to the appropriate state.

pkgs/core/src/database-types.ts (1)

314-340: LGTM: Type definitions correctly updated for deprecated_at column.

The workers table type definitions have been properly updated to replace stopped_at with deprecated_at across Row, Insert, and Update interfaces. The nullable string type string | null is appropriate for timestamp fields, and the optional markers in Insert/Update interfaces are consistent with typical database operation patterns.

.changeset/calm-ties-give.md (1)

1-14: LGTM: Comprehensive and accurate changeset documentation.

The changeset clearly describes the worker deprecation feature and its key benefits for zero-downtime deployments. It accurately captures the main changes including the database schema migration, heartbeat refactoring, and improved type safety.

pkgs/edge-worker/tests/unit/WorkerState.test.ts (2)

42-62: LGTM: Comprehensive test coverage for deprecation state transitions.

The new test case properly validates the deprecation workflow:

  • Correctly tests the Running → Deprecated → Stopping → Stopped transition sequence
  • Verifies state getters (isDeprecated, isRunning) work correctly in the Deprecated state
  • Ensures the worker can transition through all deprecation-related states as expected

This provides good coverage for the new deprecation functionality.


98-107: LGTM: Proper validation of new state getters.

The additions correctly test that isDeprecated and isStopped return false in the initial Created state, maintaining consistency with the other state getter assertions. This ensures the new state getters work correctly across all states.

pkgs/edge-worker/tests/e2e/performance.test.ts (1)

1-61: LGTM: Improved SQL client lifecycle management.

The refactoring properly implements the new SQL client management pattern:

  • Uses withSql wrapper to ensure proper cleanup of the main SQL connection
  • Creates temporary SQL clients in the polling function with proper finally block cleanup
  • Eliminates manual connection management and potential resource leaks
  • Maintains the same test logic while improving reliability

This follows the established pattern from other test files and enhances resource management.

pkgs/edge-worker/tests/e2e/_helpers.ts (5)

43-57: Good resource management pattern!

The refactoring to use local SQL client with try-finally ensures proper connection cleanup.


59-76: Consistent resource management pattern applied.

The function correctly manages SQL client lifecycle.


120-138: Well-structured async resource management.

The SQL client is properly managed even within the waitFor predicate function.


140-147: Clean implementation with proper cleanup.


149-158: Proper separation of SQL client instances.

Each function correctly manages its own SQL client lifecycle.

pkgs/edge-worker/src/core/WorkerState.ts (3)

13-15: Well-documented state addition.

The Deprecated state is clearly defined and positioned appropriately in the worker lifecycle.


27-28: Correct state transition logic for deprecation flow.

The transitions properly support both direct stopping and graceful deprecation paths.


70-73: Consistent getter implementation.

examples/playground/supabase/functions/pgflow-cron-worker/index.ts (2)

41-43: Appropriate heartbeat configuration for cron worker.

The 4-second interval is reasonable for periodic execution patterns.


131-131: Correct heartbeat placement in processing flow.

Heartbeats are sent at appropriate points to maintain worker liveness.

Also applies to: 199-199

pkgs/edge-worker/tests/unit/WorkerLifecycle.deprecation.test.ts (7)

16-53: Well-designed mock for testing heartbeat behavior.

The mock provides good control over test scenarios with call counting and configurable responses.


69-106: Thorough test of deprecation state transition.

Correctly verifies the lifecycle transitions from Running to Deprecated state.


108-138: Good edge case coverage for idempotent deprecation.


140-159: Important defensive test for uninitialized worker.


161-186: Complete lifecycle transition test.


188-208: Proper validation of state machine constraints.


250-281: Excellent test for heartbeat interval enforcement.

Ensures heartbeats are rate-limited according to configuration.

pkgs/edge-worker/src/core/WorkerLifecycle.ts (3)

7-27: Well-designed configuration with sensible defaults.

The 5-second heartbeat interval is a reasonable default that balances liveness detection with resource usage.


76-92: Robust heartbeat implementation with proper deprecation handling.

The method correctly:

  • Guards against uninitialized state
  • Enforces heartbeat intervals
  • Detects and handles deprecation with appropriate state transitions

110-116: Clean deprecation API following existing patterns.

pkgs/edge-worker/tests/unit/FlowWorkerLifecycle.deprecation.test.ts (9)

16-47: Well-designed mock implementation!

The MockQueries class provides excellent control for testing different deprecation scenarios with proper type safety and call tracking.


58-92: Comprehensive test for deprecation state transition!

The test effectively validates the heartbeat-triggered deprecation flow with proper state assertions.


94-121: Good edge case coverage!

Testing idempotency of deprecation transitions ensures robust state management.


123-135: Excellent defensive programming test!

Ensures graceful handling when heartbeat is called before worker initialization.


137-158: Thorough state transition testing!

Validates the complete lifecycle from deprecated through to stopped state.


160-173: Important state machine validation!

Ensures invalid state transitions are properly rejected with clear error messages.


175-208: Good logging verification!

Ensures proper user notification when workers are deprecated.


210-260: Excellent test coverage for lifecycle properties and heartbeat throttling!

The tests thoroughly validate getters and the heartbeat interval enforcement logic.


9-9: Import path validated for postgres type.

  • Verified that pkgs/edge-worker/tests/sql.ts exists.
  • Confirmed it exports export type { postgres };

No changes needed—the relative import '../sql.ts' is correct.

pkgs/edge-worker/src/flow/FlowWorkerLifecycle.ts (3)

25-31: Good implementation with sensible defaults!

The 5-second default heartbeat interval is reasonable and the nullish coalescing operator is used appropriately. This aligns with the retrieved learning about providing sensible defaults for configuration options.


80-96: Excellent heartbeat implementation with deprecation handling!

The method properly handles:

  • Graceful early return when worker not initialized
  • Heartbeat throttling to prevent excessive database calls
  • Deprecation detection with appropriate state transition
  • Clear logging of heartbeat status

114-121: Clean deprecation API!

The methods provide a clear interface for deprecation state management.

pkgs/edge-worker/tests/integration/flow_deprecation.test.ts (1)

8-24: Well-designed test flow helper!

The execution tracking and async simulation make it easy to verify worker behavior.

jumski added 13 commits August 4, 2025 16:31
…ate related code

- Renamed column stopped_at to deprecated_at in the workers table and migration
- Updated database schema types to include deprecated_at field
- Modified heartbeat logic to return deprecation status
- Adjusted worker heartbeat handling to mark workers as deprecated
- Enhanced worker lifecycle to transition to deprecated state upon deprecation
- Updated worker state checks for deprecated status across modules
- Refined queries to handle deprecated_at field and deprecation detection
- Ensured deprecation status triggers worker to transition to deprecated state in main loop
…havior

Includes integration tests for worker deprecation handling, in-flight message completion,
multiple worker deprecation, and heartbeat deprecation detection.
Also adds unit tests
for Heartbeat class and WorkerLifecycle deprecation state transitions to improve coverage.
…ing message processing,

in-flight message completion, multiple worker coordination, and post-deprecation message routing
…and message handling

- Changed database URLs from localhost to 127.0.0.1 for consistency in tests
- Updated message parsing to handle double-encoded JSON in multiple test files
- Improved deprecation flow tests to verify message processing and worker deprecation
- Adjusted delay timings to ensure proper detection of worker deprecation
- Refined test logic for queue and archive counts after deprecation events
- Enhanced test coverage for worker lifecycle and flow deprecation scenarios
- Overall, these changes improve test reliability and consistency across environments
- Introduced heartbeatInterval option in WorkerLifecycle and FlowWorkerLifecycle
- Replaced Heartbeat class with inline sendHeartbeat function for simplicity
- Updated tests to mock sendHeartbeat behavior and verify deprecation handling
- Ensured heartbeat respects interval, avoiding unnecessary calls
- Removed deprecated Heartbeat.ts file to streamline codebase
… exports

- Changed localhost IP from 127.0.0.1:5432 to ensure consistency across test files
- Corrected database URL port in sql.ts to 5432 for proper connection
- Removed unnecessary export of sql and postgres types in sql.ts for cleaner module
- Overall, aligned test setup configurations for reliable database connections
…across tests

- Replace direct sql import with createSql() calls for better resource management
- Wrap database interactions in try-finally blocks to guarantee sql.end() is called
- Update tests to use withSql helper for consistent SQL client handling
- Minor adjustments to test setup and assertions for clarity and reliability
…rtions in test mocks

- Renamed variables with leading underscores to improve readability
- Corrected type assertions for SQL and logger mocks to align with expected types
- Simplified Promise handling in mock methods for consistency
- Minor formatting adjustments for better code clarity
Implement deprecation mechanism allowing workers to gracefully shut down by checking deprecation
status via heartbeat, repurposing existing columns for tracking, and completing in-flight work
before shutdown.
Also, refactor heartbeat logic into lifecycle classes and add configurable heartbeat interval.
… tests

- Updated transitionToDeprecated calls to be properly awaited in tests
- Corrected mock return values to use Promise.resolve for consistency
- Enhanced mockQueue.safeCreate to return a proper RowList structure
- Ensured all test assertions handle asynchronous code correctly
Update test assertions to correctly expect exceptions when transitioning to deprecated state,
ensuring compatibility with the testing framework.
Refactor message processing to avoid double JSON parsing, replace JSON.stringify with sql.json,
and streamline message assertions across multiple test files.
@github-actions
Copy link
Contributor

github-actions bot commented Aug 4, 2025

🔍 Preview Deployment: Website

Deployment successful!

🔗 Preview URL: https://pr-188.pgflow.pages.dev

📝 Details:

  • Branch: worker-deprecation
  • Commit: c83e2abd7a999c378bb469f98cf6e6728dc402f5
  • View Logs

_Last updated: _

@github-actions
Copy link
Contributor

github-actions bot commented Aug 4, 2025

🔍 Preview Deployment: Playground

Deployment successful!

🔗 Preview URL: https://pr-188--pgflow-demo.netlify.app

📝 Details:

  • Branch: worker-deprecation
  • Commit: c83e2abd7a999c378bb469f98cf6e6728dc402f5
  • View Logs

_Last updated: _

@jumski jumski merged commit 81d552f into main Aug 4, 2025
8 of 10 checks passed
@jumski jumski deleted the worker-deprecation branch August 4, 2025 17:26
@github-actions
Copy link
Contributor

github-actions bot commented Aug 4, 2025

🚀 Production Deployment: Website

Successfully deployed to production!

🔗 Production URL: https://pgflow.dev

📝 Details:

  • Commit: 81d552f833ce8d8da0697e585a2327cf0dd733bf
  • View Logs

Deployed at: 2025-08-04T19:26:43+02:00

@github-actions
Copy link
Contributor

github-actions bot commented Aug 4, 2025

🚀 Production Deployment: Playground

Successfully deployed to production!

🔗 Production URL: https://playground.pgflow.dev

📝 Details:

  • Commit: 81d552f833ce8d8da0697e585a2327cf0dd733bf
  • View Logs

Deployed at: 2025-08-04T19:26:43+02:00

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