Skip to content

feat(plugin-sdk): add thread plugin metadata with review fixes - #3555

Merged
SawyerHood merged 8 commits into
mainfrom
bb/review-pull-request-3508-codebase-thr_pp65mcbm5h
Sep 12, 2026
Merged

SawyerHood merged 8 commits into
mainfrom
bb/review-pull-request-3508-codebase-thr_pp65mcbm5h

Conversation

@SawyerHood

@SawyerHood SawyerHood commented Sep 12, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Plugins need persistent per-thread JSON metadata that is available during agent configuration without automatically entering model-facing payloads. This continues @samanthar0se's implementation in #3508 and includes the review fixes: migration conflicts, SDK versioning, validation and status codes, configure snapshots, and discrepancies between the published testing fakes and production.

What changed

  • Add per-plugin thread metadata namespaces, GET/PATCH routes, SDK read/update methods, and explicit spawn/fork seeds. Patches are atomic and each namespace is capped at 256 KiB.
  • Provide each configure callback its own deeply frozen, readonly namespace; forks inherit no metadata. Metadata stays out of ordinary thread responses and provider payloads.
  • Validate plugin IDs, return 400 for malformed input and 413 for an oversized merged namespace, recover corrupt rows without logging their contents, and align SDK fakes with production attribution and rejection behavior.
  • Regenerate the migration as 0118, bump the Plugin SDK to 0.4.86, and update Plugin Guide documentation and regression coverage.

Namespaces follow ordinary thread access rules and are not an authorization boundary. The unprefixed public API names and cross-namespace access were explicitly accepted during maintainer review. No server/daemon wire fields change.

Supersedes #3508, preserving the contributor's commits and adding the reviewed fixes.

How you verified

Verification recorded in the preceding review/fix thread on the unchanged final tip, 87959e5081001423da42c3cf7ec25d7a865ce9ae:

  • Turbo typechecks across all affected packages passed.
  • DB/domain/contract/SDK suites passed: 498 / 209 / 79 / 111 tests.
  • Full server suite passed: 2,594 tests; 33 plugin suites using the fake host passed.
  • Integration tests, Drizzle regeneration, both SDK version checks, and tarball smoke passed.
  • Regression coverage includes first-configure seed visibility, route status codes, atomic size-limit failures, and a freeze test demonstrated to fail with freezing removed.
  • Prior verification noted formatter drift in unchanged main code in the migration test and SDK threads area.

Commit metadata was subsequently updated to credit @samanthar0se on every PR commit; the verified source tree is unchanged.

Publication checks: git diff --check origin/main...HEAD passed. The clean-secret-models scanner reported zero hits in working-tree, tracked@HEAD, range-added-lines, and range-commit-messages for origin/main..HEAD.

Fixes #3438

Co-authored-by: samanthar0se [email protected]

AGENT GENERATED

samantha rose and others added 8 commits September 11, 2026 00:39
# Conflicts:
#	packages/db/drizzle/meta/0115_snapshot.json
#	packages/db/drizzle/meta/_journal.json
#	packages/db/test/migrate.test.ts

Co-authored-by: samanthar0se <[email protected]>
Renumber the thread_plugin_metadata migration to 0118 after main's
0117_machine_providers, and rewind it with the machine providers
migration in migrate.test.ts instead of dropping it at each rewind site.

Co-Authored-By: Claude Code <[email protected]>

Co-authored-by: samanthar0se <[email protected]>
Co-Authored-By: Claude Code <[email protected]>

Co-authored-by: samanthar0se <[email protected]>
- Return 400 for an oversized `set` or malformed plugin id and 413 when a
  merged namespace would exceed 256 KiB, instead of 500. Validate `pluginId`
  with the plugin id schema.
- Read a corrupt namespace as `{}`, let a patch replace it, and log only the
  thread and plugin ids. Store no row for an empty seed.
- Resolve the creation seed at the service boundary (no `""` namespace) and
  drop the placeholder `pluginMetadata` from the configure boundary.
- Load and parse namespaces only for plugins with a configure callback, once
  per pass, and freeze them with one shared helper.
- Make `getPluginMetadata`/`updatePluginMetadata` reject instead of throwing
  synchronously. Keep `toJSON` as ordinary data.
- Type `context.pluginMetadata` as deep-readonly JSON. Align the fake SDK and
  fake host with production attribution, rejections, and context handling.
- Trim unused db exports and duplicated validation. Fix Guide card symbols
  and document attribution, limits, and untrusted metadata.
- Replace vacuous tests with end-to-end configure, route status, fail-closed,
  and freeze tests.

Co-Authored-By: Claude Code <[email protected]>

Co-authored-by: samanthar0se <[email protected]>
@SawyerHood
SawyerHood force-pushed the bb/review-pull-request-3508-codebase-thr_pp65mcbm5h branch from 87959e5 to 18a4344 Compare September 12, 2026 01:38
@SawyerHood
SawyerHood merged commit c00476e into main Sep 12, 2026
16 checks passed
@SawyerHood
SawyerHood deleted the bb/review-pull-request-3508-codebase-thr_pp65mcbm5h branch September 12, 2026 01:43
samantha-clanker Bot pushed a commit to samanthar0se/bb that referenced this pull request Sep 19, 2026
Where upstream solved the same problem, take its version:
- thread plugin metadata base (get-bb#3555)
- provider-pi fresh session on thread start (get-bb#3677); take upstream's
  provider-pi files wholesale
- keep upstream's optional-field allowlist groups; fold
  experimental_pluginMetadataByPlugin into the plugin metadata group

Keep local composer APIs that upstream does not provide
(experimental_selectedProviderId, draft plugin metadata, provider-owned
metadata), alongside upstream's pluginSubmission, lifecycleOwnerThreadId,
setSelection, removeMention and onSubmitted. Update test fixtures for
upstream's triggers and mentionMenuPlacement props.

Co-Authored-By: Claude Opus 5 <[email protected]>
samantha-clanker Bot pushed a commit to samanthar0se/bb that referenced this pull request Sep 19, 2026
fork/main's only unique change is the pre-upstream draft of the thread
plugin metadata API and its migrations (0115_talented_kulan_gath,
0116_smooth_masked_marvel). Upstream get-bb#3555 replaced it, so keep this
tree and record the ancestry so fork/main fast-forwards.

Co-Authored-By: Claude Opus 5 <[email protected]>
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.

Support private launch context for plugin-created threads

1 participant