Skip to content

feat(plugins): Add SQL-backed plugin runtime APIs#604

Merged
dcramer merged 20 commits into
mainfrom
codex/plugin-memory-specs
Jun 15, 2026
Merged

feat(plugins): Add SQL-backed plugin runtime APIs#604
dcramer merged 20 commits into
mainfrom
codex/plugin-memory-specs

Conversation

@dcramer

@dcramer dcramer commented Jun 13, 2026

Copy link
Copy Markdown
Member

Adds the runtime plugin API surface for trusted plugins: split plugin API contracts, prompt/tool/heartbeat/dispatch hooks, packaged SQL migrations through junior upgrade, plugin-scoped state, and ctx.db access for plugins that declare database usage. Database-backed plugins now require SQL instead of supporting an optional no-DB mode.

The scheduler is the first concrete consumer of that API. Its runtime plugin path now uses scheduler-owned SQL tables for tools, heartbeat, and operational reporting, with state-backed storage kept only for tests and the one-time storage migration. Memory implementation remains deferred; the memory work in this PR is limited to specs that describe the future plugin policy, storage, retrieval, and admin shape.

Validated with pnpm --filter @sentry/junior-plugin-api run typecheck, pnpm --filter @sentry/junior-scheduler run typecheck, pnpm --filter @sentry/junior-scheduler run build, pnpm --filter @sentry/junior run typecheck, pnpm --filter @sentry/junior run lint, and the focused scheduler/plugin Vitest suite.

dcramer and others added 2 commits June 12, 2026 16:45
Define plugin prompt contribution, observation, session state, and database migration contracts for the upcoming memory plugin work.

Co-Authored-By: Codex <codex@openai.com>
Define the V1 memory plugin contract, including policy, storage, retrieval, tools, security, and verification.

Document the generic plugin surfaces needed for memory background tasks, database access, and future CLI administration.

Co-Authored-By: GPT-5 Codex <codex@openai.com>
@vercel

vercel Bot commented Jun 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
junior-docs Ready Ready Preview, Comment Jun 15, 2026 8:50pm

Request Review

Comment thread specs/plugin-prompt-hooks.md
Comment thread specs/plugin-prompt-hooks.md
dcramer and others added 2 commits June 13, 2026 10:51
Move the public plugin API out of one large module and cut over exported contracts from AgentPlugin-prefixed names to Plugin-prefixed names.

Add initial prompt, task, and database hook shapes so memory-style plugins can build against the intended V1 surface.

Co-Authored-By: GPT-5 Codex <codex@openai.com>
Add a narrow plugin database surface, plugin-owned SQL migration discovery, and storage migration hooks for upgrade-time backfills.

Move scheduler onto plugin SQL as the first consumer while keeping the state-backed store path available for tests and existing flows. Document the storage migration contract and cover plugin migration discovery, upgrade wiring, and scheduler SQL behavior with targeted tests.

Co-Authored-By: GPT-5 Codex <codex@openai.com>
Comment thread packages/junior/src/chat/agent-dispatch/context.ts
Share plugin package env parsing between app startup and upgrade so plugin SQL migration discovery follows the same configured catalog surface.

Make missing virtual config handling stricter, clarify plugin schema migration errors, and add guardrail tests for required database plugins and migration filenames.

Co-Authored-By: GPT-5 Codex <codex@openai.com>
Wire database-backed plugin registrations through heartbeat contexts so scheduler hooks can read from the same SQL store that tools and upgrade migrations write to.

Keep plugin storage migrations on the upgrade command boundaries by using the migration context database and state adapter. Update the scheduler and plugin database specs to reflect that migration application and checksum checks happen only in junior upgrade.

Co-Authored-By: GPT-5 Codex <codex@openai.com>
Comment thread packages/junior-scheduler/src/store.ts
Treat plugin database declarations as required SQL access instead of an optional runtime mode. Storage migration hooks now receive a required ctx.db and fail before running when a plugin has not declared database access.

Keep the scheduler plugin on the SQL-backed runtime path for tools, heartbeat, and operational reporting while leaving state-backed storage only for tests and migration support.

Co-Authored-By: GPT-5 Codex <codex@openai.com>
@dcramer dcramer changed the title docs(memory): Add memory plugin architecture specs feat(plugins): Add SQL-backed plugin runtime APIs Jun 14, 2026
Comment thread packages/junior-scheduler/src/store.ts
@dcramer dcramer marked this pull request as ready for review June 14, 2026 19:46
Allow the SQL scheduler store to claim a later due occurrence when an older pending run for the same task is stale. Fresh pending and running runs still block new claims.

Add a SQL scheduler component regression test for stale pending claims so the SQL store matches the state-backed scheduler behavior.

Co-Authored-By: GPT-5 Codex <codex@openai.com>
Comment thread packages/junior/src/cli/upgrade/migrations/plugin-storage.ts
Load the trusted scheduler plugin registration during storage upgrade when package-only plugin config enabled its SQL migrations. This keeps scheduler state backfill from being skipped when the virtual plugin module is unavailable.

Co-Authored-By: GPT-5 Codex <codex@openai.com>
Comment thread packages/junior/src/cli/upgrade/migrations/plugin-sql.ts
Comment thread packages/junior-scheduler/src/store.ts
Resolve upgrade plugin package names and registrations into one effective plugin set and catalog before running plugin migrations. This keeps trusted package-enabled hooks and SQL schema discovery on the same path.

Harden scheduler SQL scans so malformed record payloads fail point reads but do not block valid due claims.

Co-Authored-By: GPT-5 Codex <codex@openai.com>
Keep scheduler SQL task rows claimable when only the prompt text is malformed so heartbeat can mark the run and task blocked. Corrupt records missing scheduler-critical fields still fail zod parsing and are skipped in scan paths.

Co-Authored-By: GPT-5 Codex <codex@openai.com>
Use manifest.name as the only plugin registration identity and keep packageName as a package locator for bundled plugin content. Tie package migrations to JavaScript registrations so declarative manifests stay manifest-only.

Move plugin database migration coverage into component tests and tighten scheduler retained-state parsing with schemas.

Co-Authored-By: GPT-5 Codex <codex@openai.com>
Apply plugin SQL namespace validation during central migration discovery and reject duplicate or destructive migration inputs before execution.

Keep scheduler runtime registration out of core upgrade wiring and add a package-boundary check so @sentry/junior cannot import plugin packages other than @sentry/junior-plugin-api.

Co-Authored-By: GPT-5 Codex <codex@openai.com>
Comment thread packages/junior-scheduler/src/plugin.ts
Give scheduler eval registration a migrated plugin database from the eval package, without importing scheduler into core Junior code.

Add a regression test for malformed JSONB string scheduler records so invalid stored rows are skipped or rejected instead of crashing scan paths.

Co-Authored-By: GPT-5 Codex <codex@openai.com>
Prevent the SQL scheduler store from creating a fresh pending run over an existing terminal occurrence. This keeps SQL claiming aligned with the state-backed store.

Add a component regression test that leaves a completed task occurrence due and verifies it is not reclaimed.

Co-Authored-By: GPT-5 Codex <codex@openai.com>
Comment thread packages/junior-scheduler/src/store.ts Outdated
Keep the scheduler Drizzle config and generation command, but invoke drizzle-kit with pnpm dlx so the repository lockfile does not add vulnerable transitive esbuild versions.

This keeps dependency review green while preserving the Drizzle migration workflow.

Co-Authored-By: GPT-5 Codex <codex@openai.com>
Return undefined for invalid scheduler SQL task and run records during point lookups, matching scan paths and the state-backed store behavior.

Update the scheduler SQL component regression to cover malformed object and string records without throwing.

Co-Authored-By: GPT-5 Codex <codex@openai.com>
Remove SQL content inspection from plugin migration loading while keeping central ordering, checksums, and filename validation. Plugins are trusted code, so Junior should not maintain a partial SQL validator.

Keep future prompt and task hooks out of the exported plugin API until core invokes them, and fail fast when migration-only packages are configured without an owning code registration.

Co-Authored-By: GPT-5 Codex <codex@openai.com>
Remove the scheduler tool fallback to legacy plugin state so runtime tool construction always receives an explicit scheduler store. Keep legacy scheduler state access limited to the upgrade migration path.

Drop the migration-only package ownership guardrail and update specs to distinguish future prompt hook designs from currently implemented plugin APIs.

Co-Authored-By: GPT-5 Codex <codex@openai.com>

@cursor cursor 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 06262cf. Configure here.

Comment thread packages/junior-scheduler/src/store.ts
Allow SQL-backed scheduler tasks that are reactivated from a blocked state to dispatch the same scheduled occurrence again. Preserve completed run history by clearing only blocked run rows for the reactivated slot.

Co-Authored-By: GPT-5 Codex <codex@openai.com>
@dcramer dcramer merged commit d62ff55 into main Jun 15, 2026
16 checks passed
@dcramer dcramer deleted the codex/plugin-memory-specs branch June 15, 2026 20:59
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