Skip to content

Commit aec8993

Browse files
authored
refactor(plugin-sdk): complete awaited GitHub publication migration (#168954)
* refactor(plugin-sdk): share legacy persistence warning budgets * refactor(github): move personal connection authority to workers * fix(github): publish connection and receipt revocation facts * refactor(github): share transaction-local publication transitions * refactor(github): prepare typed publication source authority Include the reviewed requester context and conservative source revocation repairs. * refactor(github): execute publication commands in state workers Install canonical worker authority receipts before observers and ordinary replies. * refactor(plugin-sdk): complete awaited GitHub publication migration Finish bundled V2/async routing, released SDK deprecations, migration documentation, and compatibility proof. Keep absent receipt and execution-owner reads free of schema writes. * refactor(github): await personal and repository publication lifecycle Consume the corrected worker receipt and source contracts. * test(github): exercise publication reads without optional state * fix(github): admit worker reads and avoid empty connection writes * fix(github): propagate reviewed connection authority repairs Preserve existing branch history while carrying reviewed S7 repairs. * docs(sqlite): refresh GitHub authority inventory locations * fix(github): preserve released personal OAuth completion contracts Keep synchronous cancellation and disconnection through explicit compatibility adapters while bundled RPCs await named worker-owned replacements. Share transition kernels and canonical postcommit facts. Split publication owners within existing boundaries and keep connection types acyclic. Update released-SDK coverage, migration guidance, and generated worker inventory. * fix(github): propagate reviewed connections compatibility and gate repairs Preserve existing branch history and stage-specific ownership contracts. * refactor(github): keep publication worker contracts acyclic * refactor(github): propagate reviewed worker type-cycle repair Preserve existing runtime bodies and branch history. * fix(github): repair publication source binding and compatibility fixtures * fix(github): propagate reviewed connections gate repairs Preserve branch history and carry reviewed API, fixture, and static-gate repairs at their owning slice. * fix(github): preserve session mutation rights during publication Treat publication as a non-run mutation while preserving default agent-run authorization for other prepared callers. Align real Git fixtures with canonical registry and session rows, retain lifecycle identity in status reads, and verify exact cancellation settlement. Validation: all 50 personal publication tests pass (166.83s Vitest, 175.20s wrapper); core types, canonical worker inventory, and scoped P1 review pass. * fix(github): preserve publication policy in source slice Keep agent-run admission separate from publication mutation authority and preserve the reviewed fixture repairs at their owning boundary. * fix(github): preserve publication admission and committed source facts Normalize placement projections across worker cloning, keep stable-account receipt admission separate from login-bound execution, and omit empty connection authority publications. Repair bundled workflow fixtures for the versioned requester surface. Existing regression probes pass: four in-turn checkpoints, three merge-retirement cases, and accepted pre-claim login drift. Scoped P1 review has no actionable findings; cumulative remote validation remains pending. * docs(sqlite): refresh GitHub profile writer evidence * fix(github): propagate reviewed facts focused repairs Preserve existing history and carry the reviewed repair at its owning slice. * refactor(github): simplify publication bookkeeping settlement Reuse native settlement and retain only consumed connection notifications. * refactor(github): simplify failed publication bookkeeping Carry reviewed S7 source and inventory through the existing stack. * perf(github): reuse the state worker for role authority * refactor(github): simplify execution bookkeeping authority * perf(github): reuse state worker for connection reads * refactor(github): reuse publication worker for lifecycle reads * perf(github): avoid redundant checkpoint and orphan preparation * perf(github): reuse resident profile role authority * perf(github): reuse resident role authority * refactor(github): check custody after publication preparation * refactor(github): check custody after repository preparation Remove the redundant intermediate custody check; retain the check after the awaited receipt read and the existing effect authority checks. * fix(github): preserve retryable publication authority failures * fix(github): normalize publication requester revocation Carry the reviewed publication runtime repair through its owning slice. Preserve existing authority checks and pending recovery outcomes. * test(github): inspect persisted failure after profile merge * refactor(github): reuse matching prepared publication requester * refactor(github): reuse matching prepared publication requester * perf(github): simplify publication bookkeeping admission * test(github): simplify personal publication cleanup * test(github): keep durable publication reads synchronous * fix(github): defer source authority exports to their consumer slice * fix(github): defer worker exports until operation registration * refactor(github): stage source authority with its consumers * fix(github): preserve bounded deferral authority projection * fix(github): settle deferrals through authority receipts * test(github): expect host-minted publication requester * fix(github): align SDK forwarders and async transcript fixture * fix(sqlite): classify GitHub worker-only publication operations * fix(github): preserve migrated publication read dispatch
1 parent 3414fa0 commit aec8993

55 files changed

Lines changed: 2718 additions & 944 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎docs/plugins/sdk-entrypoints.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ All plugin APIs are [experimental](/plugins/sdk-overview#api-stability),
1616
including these entry helpers. Pin and test the OpenClaw host versions your
1717
plugin supports.
1818

19+
Gateway adapters use the existing `core` or `gateway-runtime`
20+
`GatewayRequestHandlerOptions.context.githubPublicationService` contract for
21+
GitHub publication. Prepare its required capabilities with
22+
`prepareGitHubPublicationRequesterV2` or `preparePersonalGitHubSessionActionV2`
23+
from `gateway-runtime`, using admitted handler options, and release them after
24+
the operation settles. The host's worker and source-fence modules remain private.
25+
Migrate wrappers and lifecycle calls using the
26+
[GitHub publication method mapping](/plugins/sdk-migration/how-to-migrate#await-github-publication-operations),
27+
without adding imports from Gateway internals.
28+
1929
<Tip>
2030
**Looking for a walkthrough?** See [Tool Plugins](/plugins/tool-plugins),
2131
[Channel Plugins](/plugins/sdk-channel-plugins), or

‎docs/plugins/sdk-migration/compatibility-policy.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,15 @@ TypeScript marks those adapters deprecated. They retain their result shapes and
150150
completion timing until the next Plugin SDK major and an explicitly approved
151151
breaking release. No schema, retained data, or update migration changes.
152152

153+
GitHub publication's opaque requester and synchronous lifecycle methods, plus
154+
personal OAuth `cancelAuthorization` and `disconnect`, share the
155+
`github-publication` runtime warning budget. The personal OAuth methods retain
156+
their synchronous results until the same removal gate; migrate to
157+
`cancelAuthorizationAsync` and `disconnectAsync`. Follow the
158+
[V2 request and lifecycle migration](/plugins/sdk-migration/how-to-migrate#await-github-publication-operations)
159+
for required host capabilities and callback ordering. This does not change the
160+
warning policy of the placement reader family.
161+
153162
### Channel pairing allowlists
154163

155164
`readChannelAllowFromStoreSync` from `openclaw/plugin-sdk/channel-pairing` is

‎docs/plugins/sdk-migration/how-to-migrate.md‎

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,123 @@ sidebarTitle: "How to migrate"
99

1010
The ordered migration steps. Work through them in order; each step is self-contained. Part of the [Plugin SDK migration](/plugins/sdk-migration) guide.
1111

12+
## Await GitHub publication operations
13+
14+
The Gateway context's `githubPublicationService` provides versioned requests and
15+
awaited lifecycle operations for shared, personal, and repository publication.
16+
Use the same service from `GatewayRequestHandlerOptions` in `core` or
17+
`gateway-runtime`, or from the current `plugin-runtime` request scope. There is
18+
no new GitHub-specific SDK subpath.
19+
20+
| Deprecated method | Replacement |
21+
| --------------------------- | ---------------------------------- |
22+
| `requestForSession` | `requestForSessionV2` |
23+
| `requestForClaim` | `requestForClaimV2` |
24+
| `requestPersonalForSession` | `requestPersonalForSessionV2` |
25+
| `confirmPersonal` | `confirmPersonalV2` |
26+
| `deferClaimPreparation` | `await deferClaimPreparationAsync` |
27+
| `deferOrphanedRequests` | `await deferOrphanedRequestsAsync` |
28+
| `listUnreportedResults` | `await listUnreportedResultsAsync` |
29+
| `markReported` | `await markReportedAsync` |
30+
31+
The same Gateway context exposes personal connection operations through
32+
`githubOAuthService.personal`. Replace
33+
`personal.cancelAuthorization(action, requestId)` with
34+
`await personal.cancelAuthorizationAsync(action, requestId)`, and
35+
`personal.disconnect(action)` with `await personal.disconnectAsync(action)`.
36+
The arguments are unchanged. The legacy methods retain their synchronous
37+
`boolean` and `void` results and commit before returning; the async methods
38+
resolve after the worker commits and installs the connection facts. They share
39+
the publication family's deprecation warning and removal window below.
40+
41+
The V2 request methods require the host's `GitHubPublicationRequesterV2`;
42+
personal methods require `PersonalGitHubSessionActionV2`. Prepare them through
43+
`prepareGitHubPublicationRequesterV2` or `preparePersonalGitHubSessionActionV2`
44+
from `openclaw/plugin-sdk/gateway-runtime`, passing the admitted Gateway handler
45+
options and selected session. Forward the original object through adapters.
46+
These capabilities include `version: 2`,
47+
a lifetime `signal`, and `prepareSource`, in addition to their existing caller
48+
assertions. Do not synthesize them from request parameters, a saved requester
49+
snapshot, or a legacy callback. Their source capability is bound to the admitted
50+
session and physical database lifetime and cannot be reconstructed from JSON.
51+
52+
Replace the legacy call `await service.requestForSession({ ...input, requester })`
53+
and its opaque requester assertions with a retained host preparation:
54+
55+
```ts
56+
import {
57+
prepareGitHubPublicationRequesterV2,
58+
type GatewayRequestHandlerOptions,
59+
} from "openclaw/plugin-sdk/gateway-runtime";
60+
61+
type Publications = NonNullable<
62+
GatewayRequestHandlerOptions["context"]["githubPublicationService"]
63+
>;
64+
type PublicationInput = Omit<
65+
Parameters<Publications["requestForSessionV2"]>[0],
66+
"requester" | "sessionKey"
67+
> & { sessionKey: string };
68+
69+
async function publish(options: GatewayRequestHandlerOptions, input: PublicationInput) {
70+
const service = options.context.githubPublicationService;
71+
if (!service) throw new Error("GitHub publication is unavailable.");
72+
const prepared = await prepareGitHubPublicationRequesterV2(options, {
73+
agentId: input.agentId,
74+
sessionKey: input.sessionKey,
75+
});
76+
try {
77+
return await service.requestForSessionV2({ ...input, requester: prepared.requester });
78+
} finally {
79+
prepared.release();
80+
}
81+
}
82+
```
83+
84+
For personal publication, call
85+
`await preparePersonalGitHubSessionActionV2(options, { sessionKey, agentId })`,
86+
pass its `action` to `requestPersonalForSessionV2` or `confirmPersonalV2`, and
87+
release it in the same `try`/`finally` pattern. The factory derives personal and
88+
session authority from the admitted handler context; a claimed profile ID does
89+
not grant access.
90+
91+
V2 prepares host policy before acquiring database reservations. The worker
92+
compares the selected session lifecycle, requester, connection, and workspace
93+
facts under source exclusion, then commits the request and lifecycle binding in
94+
one destination transaction. The source remains reserved until that transaction
95+
settles. Async completion includes installation of its committed facts. Keep the
96+
requester's owner alive until the operation and its cleanup settle.
97+
98+
Legacy requester assertions may read or mutate SQLite. The service selects their
99+
native compatibility route before invoking them; it does not serialize closures
100+
or invoke arbitrary host policy from inside a reserved worker transaction.
101+
Migrating to V2 changes that callback ordering: preparation precedes reservation,
102+
and typed predicates authorize commit. It does not preserve arbitrary
103+
transaction-local callback visibility. A failed or uncertain worker operation
104+
never retries through the legacy route or replays an accepted external effect.
105+
106+
Await deferral and reporting before dependent reads or shutdown. Reporting and
107+
claim deferral each update the relevant publication kinds in one worker transaction. Accepted
108+
bookkeeping, including execution claims, head updates, dispatch markers, observed effects, and completion, can settle
109+
after action cancellation while the execution owner retains custody. The worker
110+
applies its request and execution predicates inside its transaction; it does not
111+
request another host grant for each bookkeeping commit. This grants no authority
112+
for another push or pull request. New external effects always require current
113+
caller and source authority at the point of effect.
114+
An attempted-dispatch marker can remain when that final guard refuses the action;
115+
only an observed response records the effect as observed.
116+
117+
Checkpoint-preparation failure and stale-request retirement also record outcomes
118+
without source reservations. A checkpoint becoming available or a session being
119+
restored after the check may require a new publication request; the original
120+
content and recorded GitHub effects remain intact.
121+
122+
The deprecated methods retain their released signatures and completion timing;
123+
synchronous mutations still commit before returning. Actual legacy use emits one
124+
warning per plugin and the `github-publication` family per Gateway process,
125+
through the shared SDK warning helper. Unknown direct SDK consumers share one
126+
bounded family warning. These methods will be **removed in the next Plugin SDK
127+
major**. No schema, stored-data, retention, or update migration is required.
128+
12129
## Replace native SQLite runtime writes
13130

14131
Plugins using the internal `sqlite-runtime` facade should send data-only commands

‎docs/plugins/sdk-runtime.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,15 @@ adds no public capability or deprecation. Plugins must still use the owning
9191
runtime operation and its live authority checks: a prior receipt or cached row
9292
does not certify raw-handle writers, foreign changes, or a later effect.
9393

94+
The Gateway context's GitHub publication service has V2 request methods with
95+
required host-owned requester capabilities, plus awaited deferral and reporting
96+
methods. Forward those capabilities intact and await committed results before
97+
releasing request resources. Released opaque-requester and synchronous lifecycle
98+
methods remain deprecated compatibility routes; actual use shares one warning
99+
budget per plugin and publication family. See
100+
[GitHub publication migration](/plugins/sdk-migration/how-to-migrate#await-github-publication-operations)
101+
for the method mapping, callback ordering, and next-major removal contract.
102+
94103
Use `createPluginRuntimeStore` to store the runtime reference for use outside the `register` callback:
95104

96105
<Steps>

0 commit comments

Comments
 (0)