Skip to content

feat: add generate-chunks + invoke-function Knative handlers#1228

Closed
pyramation wants to merge 2 commits into
mainfrom
feat/generate-chunks-fn
Closed

feat: add generate-chunks + invoke-function Knative handlers#1228
pyramation wants to merge 2 commits into
mainfrom
feat/generate-chunks-fn

Conversation

@pyramation
Copy link
Copy Markdown
Contributor

@pyramation pyramation commented May 26, 2026

Summary

Two new Knative function handlers:

1. generate-chunks — Knowledge auto-chunking

Processes chunk:generate_chunks jobs. When a row is inserted into a knowledge table (e.g. agent_knowledge), this handler:

  • Reads the source text from the knowledge row
  • Splits it into chunks based on configurable strategy (paragraph/sentence/fixed), chunk_size, and chunk_overlap
  • Writes chunk rows back to the _chunks table with chunk_index, chunk_text, and source FK

Uses include_meta: true in the job payload for schema/table resolution.

2. invoke-function — Schema-aware function invocation

Processes function:invoke jobs. When a row is INSERTed into a function_invocations table, this handler:

  • Resolves the correct schema (public or private) from metaschema_modules_public.function_module config
  • Reads the invocation row and validates function definitions (is_invocable = true)
  • Dispatches execution to the underlying Knative function endpoint via INTERNAL_GATEWAY_DEVELOPMENT_MAP
  • Updates invocation row with status, result, duration_ms, and timestamps

Key design: Schema resolution is dynamic — queries function_module + schema tables at runtime to find the PostgreSQL schema name. Supports both public and private schema configurations, as well as entity-scoped invocation tables.

docker-compose.jobs.yml

  • Added invoke-function service with dev routing
  • Added function:invoke to knative-job-service INTERNAL_GATEWAY_DEVELOPMENT_MAP and JOBS_SUPPORTED

SQL-side companion: constructive-io/constructive-db#1348 adds the data_job_trigger on function_invocations INSERT.

Review & Testing Checklist for Human

  • Review invoke-function/src/schema-resolver.ts — verify the metaschema query correctly joins function_moduleschema to resolve the PostgreSQL schema name
  • Review invoke-function/src/index.ts — verify the invocation lifecycle (pending → running → completed/failed) and that status/result/duration updates use the correct column names
  • Verify docker-compose.jobs.yml routing — ensure function:invoke appears in both INTERNAL_GATEWAY_DEVELOPMENT_MAP and JOBS_SUPPORTED
  • Run the schema-resolver unit tests: cd functions/invoke-function && pnpm test (5 tests)

Notes

The invoke-function handler pairs with constructive-db PR #1348 which adds the SQL job trigger. The generate-chunks handler pairs with constructive-db PR #1347 which documents the task identifier.

Link to Devin session: https://app.devin.ai/sessions/8820b639fbd94ac8bfae86cfb01cf827
Requested by: @pyramation

…e tables

Implements the generate_chunks job handler that processes auto-chunking
jobs enqueued by the embedding_chunks trigger. When content is inserted
into an agent knowledge table (or any table with ProcessChunks), the
trigger enqueues a job which this function picks up and processes:

1. Read content from the parent table row
2. Split into chunks (paragraph/sentence/fixed/semantic strategies)
3. Generate per-chunk embeddings via configurable provider (Ollama default)
4. Insert chunks into the child chunks table

Also updates docker-compose.jobs.yml to include the generate-chunks
service and adds it to the INTERNAL_GATEWAY_DEVELOPMENT_MAP routing.
@devin-ai-integration
Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@socket-security
Copy link
Copy Markdown

socket-security Bot commented May 26, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​agentic-kit/​ollama@​1.2.17410010091100

View full report

@socket-security
Copy link
Copy Markdown

socket-security Bot commented May 26, 2026

All alerts resolved. Learn more about Socket for GitHub.

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report

Schema-aware function invocation handler that:
- Resolves the correct schema (public or private) from function_module config
- Reads the invocation row and validates function definitions (is_invocable)
- Dispatches execution to the underlying Knative function endpoint
- Updates invocation row with status, result, duration_ms, and timestamps

Also adds invoke-function service to docker-compose.jobs.yml with dev
routing (function:invoke -> http://invoke-function:8080).

The handler queries metaschema_modules_public.function_module to resolve
the PostgreSQL schema name at runtime, supporting both public and private
schema configurations as well as entity-scoped invocation tables.
@devin-ai-integration devin-ai-integration Bot changed the title feat: add generate-chunks Knative function for auto-chunking knowledge tables feat: add generate-chunks + invoke-function Knative handlers May 26, 2026
@devin-ai-integration
Copy link
Copy Markdown
Contributor

Closing — the invoke-function handler was premature. The generate-chunks function will be re-submitted separately.

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