Skip to content

feat(plugin-sdk): add thread plugin metadata - #3508

Closed
samanthar0se wants to merge 5 commits into
get-bb:mainfrom
samanthar0se:thread-plugin-metadata
Closed

samanthar0se wants to merge 5 commits into
get-bb:mainfrom
samanthar0se:thread-plugin-metadata

Conversation

@samanthar0se

Copy link
Copy Markdown
Contributor

Summary

  • add plugin-scoped JSON object namespaces to threads
  • let plugin-bound SDK calls seed, read, and atomically patch metadata
  • pass each configure callback only its own deep-frozen namespace without adding metadata to model-facing payloads
  • keep forks free of inherited metadata while allowing an explicit seed for the new fork

This replaces the narrower launch-context design from the issue with the maintainer-proposed Thread Plugin Metadata API. Namespaces use ordinary thread access rules and are capped at 256 KiB of normalized UTF-8 JSON.

Implementation

  • add typed thread metadata GET/PATCH routes and raw SDK methods
  • default omitted plugin IDs in the plugin-bound SDK while preserving explicit cross-namespace access
  • store one object per (threadId, pluginId) with cascade deletion and immediate-transaction read/modify/write patches
  • insert spawn or explicit-fork metadata in the thread creation transaction before initial configuration
  • bulk-load namespaces for configure fan-out, fail corrupt rows closed to {}, and deep-freeze each snapshot
  • update fake SDK/host behavior, generated declarations, API map, and plugin authoring guide

Verification

  • affected package typechecks: 12/12 passed
  • focused server metadata/runtime/privacy tests: 46 passed
  • DB metadata and migration tests: 63 passed
  • Drizzle regeneration: no schema changes after generating migration 0117
  • targeted formatting and git diff --check passed
  • independent Standards and Spec reviews reported no findings
  • Plannotator review approved with no requested changes

Closes #3438

@SawyerHood

Copy link
Copy Markdown
Collaborator

Superseded by #3555, which preserves this contribution and includes the completed maintainer review fixes and verification. Thank you @samanthar0se for the implementation. Closing this PR in favor of the successor; the work continues there and has not been merged yet.

AGENT GENERATED

@SawyerHood SawyerHood closed this Sep 12, 2026
SawyerHood added a commit that referenced this pull request Sep 12, 2026
## 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

---------

Co-authored-by: samantha rose <[email protected]>
Co-authored-by: samanthar0se <[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

2 participants