Skip to content

[plugin sdk] Project session extension slots#75609

Merged
jalehman merged 25 commits into
openclaw:mainfrom
electricsheephq:split/plugin-sdk-session-entry-projection
May 4, 2026
Merged

[plugin sdk] Project session extension slots#75609
jalehman merged 25 commits into
openclaw:mainfrom
electricsheephq:split/plugin-sdk-session-entry-projection

Conversation

@100yenadmin

Copy link
Copy Markdown
Contributor

Summary

  • Adds sessionEntrySlotKey / sessionEntrySlotSchema to session extension registrations.
  • Mirrors projected extension values into a guarded top-level SessionEntry slot on patch, and clears the mirror on unset.
  • Adds a reserved-key guard so plugins cannot collide with existing SessionEntry fields or prototype keys.
  • Updates the plugin SDK API baseline for the intentional public type addition.

This replaces the consolidated #73384 / #74483 stack with a smaller fresh-main slice. The previous consolidated branch became extremely brittle under constant upstream churn: rebases repeatedly invalidated generated baselines, review threads, and CI assumptions, which made the PR harder to review than the underlying changes warranted. This PR files one hook/seam area at a time so maintainers can review, test, and merge each contract independently without re-opening the whole workflow stack.

Links

Non-goals

  • Does not include host-runtime namespace reads, parent-run tracking, path facts, scheduled turns, attachments, or broader Control UI/native-page RFC scope.
  • Does not make top-level SessionEntry slots directly writable by plugins; they remain mirrors of projected extension state.

Test Plan

  • pnpm test src/plugins/contracts/session-entry-projection.contract.test.ts
  • pnpm check:test-types
  • pnpm lint:core
  • pnpm plugin-sdk:api:check
  • git diff --check
  • npm run check:no-conflict-markers

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: M labels May 1, 2026
@clawsweeper

clawsweeper Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

Summary
The PR adds plugin session-extension SessionEntry slot projection, guarded slot ownership/cleanup, scoped trusted-policy session-extension reads across tool surfaces, API baseline/changelog updates, and focused contract coverage.

Reproducibility: not applicable. as a bug reproduction; this is an additive Plugin SDK feature PR. For review, source inspection and exact-head CI confirm the new slot projection and trusted-policy read paths are covered on the PR head.

Next step before merge
No repair lane is needed: this is an open feature PR with no discrete blocker found, so the remaining action is normal maintainer API review and merge gating.

Security
Cleared: No concrete security or supply-chain issue found; the diff does not add dependencies or workflow execution, and the config plumbing is kept out of public hook/tool-result contexts.

Review details

Best possible solution:

Land the additive SDK seam after maintainer API review, keeping the guarded projection/cleanup coverage and leaving the broader recipe documentation to the linked docs PR.

Do we have a high-confidence way to reproduce the issue?

Not applicable as a bug reproduction; this is an additive Plugin SDK feature PR. For review, source inspection and exact-head CI confirm the new slot projection and trusted-policy read paths are covered on the PR head.

Is this the best way to solve the issue?

Yes for this slice. The PR keeps the public API addition narrow, validates and persists slot ownership, scopes config-backed reads to trusted policy evaluation, and adds focused contract coverage; final API acceptance is still a maintainer decision.

What I checked:

  • current_main_lacks_slot_surface: Current main's PluginSessionExtensionRegistration only exposes namespace, description, project, and cleanup; it does not include sessionEntrySlotKey, sessionEntrySlotSchema, persisted slot ownership, or trusted-policy session-extension reads. (src/plugins/host-hooks.ts:37, 5fa7d3b1a4a0)
  • pr_adds_guarded_public_surface: PR head adds sessionEntrySlotKey and sessionEntrySlotSchema, validates slot keys against SessionEntry and Object prototype names, and rejects duplicate promoted slot keys during registration. (src/plugins/host-hooks.ts:52, 0f477927d1f7)
  • restart_cleanup_fix_present: PR head now treats restart stale-slot cleanup as an exact set, prunes only matching ownership entries, and includes mixed-namespace restart coverage that preserves still-declared mirrors while clearing obsolete mirrors. (src/plugins/host-hook-cleanup.ts:258, 0f477927d1f7)
  • trusted_policy_config_scope_checked: PR head passes config internally to trusted policy evaluation, exposes getSessionExtension only on the policy context, and strips config from Codex tool-result middleware/legacy extension contexts. (src/plugins/trusted-tool-policy.ts:35, 0f477927d1f7)
  • exact_head_checks_green: The GitHub check-run API for PR head 0f477927d1f7429534bd97556846ea377070aba3 shows the relevant quality, lint, type, plugin, build, and security shards completed successfully; CodeQL was neutral and several unrelated matrix entries were skipped. (0f477927d1f7)
  • feature_history: The central host-hook files were introduced on current main by merged PR [plugin sdk] Add generic plugin host-hook contracts #72287, squash commit 1adaa28dc86b, co-authored by 100yenadmin and jalehman and reviewed by jalehman. (src/plugins/host-hooks.ts:37, 1adaa28dc86b)

Likely related people:

  • 100yenadmin: The merged generic host-hook foundation that this PR extends is commit 1adaa28dc86b, and the current PR branch implements the slot-projection follow-up in the same host-hook/session-state files. (role: introduced behavior and current feature owner; confidence: high; commits: 1adaa28dc86b, 0f477927d1f7; files: src/plugins/host-hooks.ts, src/plugins/host-hook-state.ts, src/plugins/host-hook-cleanup.ts)
  • jalehman: The host-hook foundation commit records jalehman as co-author/reviewer, and the PR discussion routes the same Plugin SDK host-hook area through that review history. (role: reviewer and adjacent SDK owner; confidence: medium; commits: 1adaa28dc86b; files: src/plugins/host-hooks.ts, src/plugins/host-hook-state.ts, src/plugins/host-hook-cleanup.ts)
  • pashpashpash: Recent current-main history for src/agents/harness/native-hook-relay.ts and Codex hook plumbing includes native hook relay and Codex harness work by pashpashpash, which overlaps the PR's config threading through native/Codex tool surfaces. (role: adjacent Codex hook maintainer; confidence: medium; commits: 7a958d920c88, 34fb96622eb6, 3b5dab372ac2; files: src/agents/harness/native-hook-relay.ts, extensions/codex/src/app-server/dynamic-tools.ts, extensions/codex/src/app-server/run-attempt.ts)

Codex review notes: model gpt-5.5, reasoning high; reviewed against 5fa7d3b1a4a0.

@100yenadmin

Copy link
Copy Markdown
Contributor Author

Fixed in 34e1e302c18. The SessionEntry projection guard now reserves subagentRecovery, plugin cleanup clears promoted top-level slots, and the slice includes the changelog entry plus scoped trusted-policy reads for plugin-owned session extension state. Tests: src/plugins/contracts/session-entry-projection.contract.test.ts covers the subagentRecovery collision, promoted-slot cleanup, and scoped ctx.getSessionExtension behavior. Validation: pnpm test src/plugins/contracts/session-entry-projection.contract.test.ts src/plugins/contracts/host-hooks.contract.test.ts src/agents/pi-tools.before-tool-call.e2e.test.ts, pnpm plugin-sdk:api:check, pnpm lint:core, git diff --check, npm run check:no-conflict-markers.

@100yenadmin
100yenadmin marked this pull request as ready for review May 1, 2026 12:39
Copilot AI review requested due to automatic review settings May 1, 2026 12:39
@100yenadmin
100yenadmin force-pushed the split/plugin-sdk-session-entry-projection branch from 34e1e30 to d69cc3d Compare May 1, 2026 12:41

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 34e1e302c1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/plugins/registry.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the Plugin SDK session-extension registration surface to optionally mirror projected session-extension state into guarded top-level SessionEntry “slots”, and adds scoped session-extension reads for trusted tool policies.

Changes:

  • Add sessionEntrySlotKey / sessionEntrySlotSchema to session extension registrations and validate sessionEntrySlotKey against reserved/prototype keys.
  • Mirror projected session-extension values into SessionEntry[slotKey] on patch and clear the mirror on unset/cleanup.
  • Add trusted-tool-policy support for scoped session-extension reads via a getSessionExtension helper, plus contract coverage and SDK baseline/changelog updates.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/plugins/trusted-tool-policy.ts Adds per-policy scoped getSessionExtension helper and caching for trusted policies.
src/plugins/session-entry-slot-keys.ts Introduces reserved key set + normalizer for safe SessionEntry slot keys.
src/plugins/registry.ts Validates sessionEntrySlotKey during session extension registration.
src/plugins/host-hooks.ts Extends public session extension registration types with slot key/schema fields.
src/plugins/host-hook-state.ts Implements slot mirroring on patchPluginSessionExtension and adds sync session-extension read helper.
src/plugins/host-hook-cleanup.ts Ensures promoted slot keys are cleared during plugin/session cleanup.
src/plugins/hook-types.ts Extends tool hook context types to include optional session-extension read helper (and config).
src/plugins/contracts/session-entry-projection.contract.test.ts Adds contract tests for slot mirroring, reserved-key guard, cleanup behavior, and trusted policy reads.
src/agents/pi-tools.ts Threads config into tool wrapping so before-tool-call hooks can access it.
src/agents/pi-tools.before-tool-call.ts Passes config through tool hook context and runs trusted policies with the enriched context.
docs/.generated/plugin-sdk-api-baseline.sha256 Updates SDK API baseline hashes for the public type additions.
CHANGELOG.md Adds release note entry for SessionEntry slot projection + trusted-policy session reads.

Comment thread src/agents/pi-tools.before-tool-call.ts
Comment thread src/plugins/hook-types.ts
Comment thread src/plugins/registry.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c86678531c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/plugins/trusted-tool-policy.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Comment thread src/plugins/trusted-tool-policy.ts Outdated
Comment thread src/plugins/host-hook-state.ts
@100yenadmin
100yenadmin requested a review from Copilot May 1, 2026 13:52
@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label May 1, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Comment thread src/plugins/host-hook-cleanup.ts Outdated
Comment thread src/plugins/trusted-tool-policy.ts Outdated
Comment thread src/plugins/session-entry-slot-keys.ts Outdated
@jalehman
jalehman force-pushed the split/plugin-sdk-session-entry-projection branch from 0f47792 to d9b670a Compare May 4, 2026 14:58
@openclaw-barnacle openclaw-barnacle Bot removed the app: web-ui App: web-ui label May 4, 2026
@jalehman
jalehman merged commit cb38535 into openclaw:main May 4, 2026
109 checks passed
@jalehman

jalehman commented May 4, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

Thanks @100yenadmin!

lxe pushed a commit to lxe/openclaw that referenced this pull request May 6, 2026
Merged via squash.

Prepared head SHA: d9b670a
Co-authored-by: 100yenadmin <[email protected]>
Co-authored-by: jalehman <[email protected]>
Reviewed-by: @jalehman
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
Merged via squash.

Prepared head SHA: d9b670a
Co-authored-by: 100yenadmin <[email protected]>
Co-authored-by: jalehman <[email protected]>
Reviewed-by: @jalehman
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
Merged via squash.

Prepared head SHA: d9b670a
Co-authored-by: 100yenadmin <[email protected]>
Co-authored-by: jalehman <[email protected]>
Reviewed-by: @jalehman
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
Merged via squash.

Prepared head SHA: d9b670a
Co-authored-by: 100yenadmin <[email protected]>
Co-authored-by: jalehman <[email protected]>
Reviewed-by: @jalehman
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
Merged via squash.

Prepared head SHA: d9b670a
Co-authored-by: 100yenadmin <[email protected]>
Co-authored-by: jalehman <[email protected]>
Reviewed-by: @jalehman
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation extensions: codex gateway Gateway runtime size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants