Row-event functions created with `functions create` never fire, because nothing installs the capture trigger

オープン
#600 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
75/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
postgresql, typescript

調査の方向性

Read lib/ai/minimal-executor.ts around executeCreateAiFunction and the capture sync flow in lib/webhooks/capture.ts; compare with the deploy_code path in lib/services/ai-functions/agent-actions.ts. Add a regression test in tests/integration/function-row-events-data-plane.spec.ts that creates a row-event function through CREATE_AI_FUNCTION and verifies it fires. Done when the create path re-syncs capture after saving and the test passes.

索引モデルが issue の本文から書いたものです。

説明

Row-event functions (on_insert, on_update, on_delete) fire from the database-level capture: a trigger writes each change to an outbox, and the drain calls fireAiFunctions. The trigger is only installed for the events some subscriber wants, and it is re-synced when a subscriber changes:

https://github.com/backenly/backenly/blob/364c901eee7a1aaf46e3a0a4e5f16217b1b20591/lib/webhooks/capture.ts#L382-L420

deploy_code and the console's create route re-sync after saving:

https://github.com/backenly/backenly/blob/364c901eee7a1aaf46e3a0a4e5f16217b1b20591/lib/services/ai-functions/agent-actions.ts#L467-L471

The path behind the agent's functions create (generate_function to CREATE_AI_FUNCTION to executeCreateAiFunction) does not. It saves the row and returns:

https://github.com/backenly/backenly/blob/364c901eee7a1aaf46e3a0a4e5f16217b1b20591/lib/ai/minimal-executor.ts#L11138-L11150

The governed-change hook doesn't cover it either, because it only re-syncs capture when the change touched tables:

https://github.com/backenly/backenly/blob/364c901eee7a1aaf46e3a0a4e5f16217b1b20591/lib/changes/freshness.ts#L78-L85

So the common agent flow, create_table orders followed by functions create { trigger: "on_insert", table: "orders" }, produces a function the console shows as active that never runs, with no error and no log. The same goes for the first on_update or on_delete function in a project that so far only captures inserts, and for the row-event functions that blueprints and integration auto-wiring create (the Resend password-reset email is on_db_insert). It starts working only when something unrelated re-syncs capture: a new table, a webhook change, or deploying, toggling or deleting another row-event function.

The docs say a row event is "captured inside the database, so it fires no matter which door wrote the row, within about a minute".

Done when executeCreateAiFunction re-syncs capture after saving, with a test that creates a row-event function through CREATE_AI_FUNCTION and sees it fire. The existing test, tests/integration/function-row-events-data-plane.spec.ts, only covers deploy_code.

主要言語
TypeScript
スター
56
フォーク
19
平均マージ
14時間 4分
マージ済み PR(30日)
366

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

backenly/backenly のほかの issue

backenly/backenly の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。