Skip to content

Commit 55ce95f

Browse files
authored
feat(sessions): three-layer session ownership — agent attribution, assignable owner, participants (#125057)
* feat(sessions): stamp agent identity on spawned sessions and return spawn receipts Agent-spawned sessions recorded the requesting session key as createdActor.id, so the Control UI creator chip rendered an opaque key. Spawn producers now stamp the canonical requester agent id; parent-authority validation moves to a new trusted requesterSessionKey field. projectSessionActor enriches agent actors with configured identity name/avatar at read time, and visible sessions_spawn returns a sessionUrl + owner receipt with URL-first acknowledgement guidance. * feat(sessions): assignable session ownership with owner facet and menus GitHub-assignee-style ownership: sessions get a mutable owner (defaulting to the immutable createdActor) stored in additive bare-nullable SQLite columns with first-use lazy ensure. New operator.write sessions.assignOwner validates targets, requires an identified caller, authorizes by session visibility, and records assignedBy/assignedAt inside the write transaction. The sessions agent tool gains assign_owner; the Control UI adds Assign-to-me/Assign-to menus in sidebar rows and chat headers, renders the effective owner chip, and the creator facet/filter now keys on effective owner. Sharing authority stays anchored on createdActor. * feat(sessions): record session participants and stack them in the owner chip Records every distinct external prompter (human profile/channel sender, or a requesting agent) per session in an additive session_participants table at the turn-admission boundary — best-effort, deferred, never blocking the turn; the session's own agent and viewers are never recorded, capped at 32 per session. The session row projects a bounded participants list (owner excluded) plus a total count with the same actor enrichment as owner/createdActor. The sidebar chip becomes a pair-stack when others have prompted (owner front, one peeking participant or +N behind), the chat header shows the full facepile, and an authenticated involvingMe list filter adds an Involving-me sidebar predicate. Participant projection is excluded from logical-session CAS equality so display history never invalidates session writes. * fix(sessions): identify built-in agent tool callers for owner assignment The sessions tool's assign_owner dispatched through the in-process synthetic client, which carries neither a signed agent-runtime identity nor a human profile, so agent-initiated reassignment always failed with FORBIDDEN. The tool now captures its trusted requester agent identity and carries it across in-process dispatch as internal client state (never wire params); the handler derives assignedBy as signed runtime identity, then trusted agent-tool caller, then authenticated human. Live-verified end-to-end on a dev gateway. * fix(ci): split oversized session modules and refresh prompt snapshots Split the max-lines offenders at concept boundaries for session equality, tool overrides, and protocol owner schemas. Remove the redundant Number conversion from the node:sqlite participant count. Refresh prompt snapshots after drift from the sessions and sessions_spawn tool description updates. * fix(ci): restore solo-mode chip suppression and conform new method descriptors Solo-mode root cause: owner-assignment submenu options reused the permanent owner-chip custom element, so hidden menu avatars were counted as attribution chrome. Menus now use viewer avatars while gateway-gated owner chips remain exclusive to collaborative sessions. Conform sessions.assignOwner to the 2026.8 descriptor and append-only advertised-method inventories, and regenerate the Swift and Kotlin protocol surfaces. Keep historical v15/v14 fixtures frozen by stripping the new owner columns; the existing range already excludes the participant table. Replace the new raw SQLite schema probes with synchronous Kysely queries. Clear max-lines by splitting the organizer host contract, pure agent-navigation projections, and ownership/filtering sidebar cases at their concept boundaries. * fix(ci): integrate ownership series with latest main surfaces Wire the sessions-page assign-owner action, merge capability imports, narrow the navigation export scope, and apply sessions-create formatting. The owner-presence regression came from hidden assign-owner menu avatars emitting data-viewer-id, so owner and menu chrome now opt out of presence markers while real facepiles retain them. * fix(sessions): scope the involving-me filter to profile-backed participants Session participant history mixed channel-native sender ids with authenticated Gateway profile ids, so involving-me missed real sessions and could accept numeric collisions. Record the actor_source namespace at each producer, carry it through the internal SQLite projection, and match authenticated viewers only against profile-backed human participants. Legacy NULL sources fail closed for filtering, while channel ids remain available for display. * build(ui): raise startup budget baseline for session ownership surfaces Ownership chips, assignment menus, and the participant stack add ~0.7 KiB gzip to the startup path; CI compression landed just over the previous baseline+tolerance. Hard cap (350 KiB) unchanged. * refactor(sessions): drop raw NULL projection for the lazy actor_source column The Kysely guardrail rejects typed raw sql snippets outside allowlisted boundaries; select the lazily-ensured column only when present and let the row projection treat its absence as unknown/legacy. * build(ui): refresh combined startup baseline
1 parent fbd910d commit 55ce95f

127 files changed

Lines changed: 3999 additions & 641 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.

‎apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewayProtocol.kt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,7 @@ enum class GatewayMethod(
585585
PortalOpen("portal.open"),
586586
PortalClose("portal.close"),
587587
SessionsMove("sessions.move"),
588+
SessionsAssignOwner("sessions.assignOwner"),
588589
}
589590

590591
enum class GatewayEvent(

‎apps/shared/OpenClawKit/Sources/OpenClawProtocol/GatewayModels.swift‎

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5058,6 +5058,7 @@ public struct SessionsListParams: Codable, Sendable {
50585058
public let label: String?
50595059
public let boardface: AnyCodable?
50605060
public let creatorid: String?
5061+
public let involvingme: Bool?
50615062
public let spawnedby: String?
50625063
public let agentid: String?
50635064
public let search: String?
@@ -5077,6 +5078,7 @@ public struct SessionsListParams: Codable, Sendable {
50775078
label: String? = nil,
50785079
boardface: AnyCodable? = nil,
50795080
creatorid: String? = nil,
5081+
involvingme: Bool? = nil,
50805082
spawnedby: String? = nil,
50815083
agentid: String? = nil,
50825084
search: String? = nil,
@@ -5095,6 +5097,7 @@ public struct SessionsListParams: Codable, Sendable {
50955097
self.label = label
50965098
self.boardface = boardface
50975099
self.creatorid = creatorid
5100+
self.involvingme = involvingme
50985101
self.spawnedby = spawnedby
50995102
self.agentid = agentid
51005103
self.search = search
@@ -5115,6 +5118,7 @@ public struct SessionsListParams: Codable, Sendable {
51155118
case label
51165119
case boardface = "boardFace"
51175120
case creatorid = "creatorId"
5121+
case involvingme = "involvingMe"
51185122
case spawnedby = "spawnedBy"
51195123
case agentid = "agentId"
51205124
case search
@@ -6004,6 +6008,28 @@ public struct SessionCreatedActor: Codable, Sendable {
60046008
}
60056009
}
60066010

6011+
public struct SessionOwner: Codable, Sendable {
6012+
public let actor: SessionCreatedActor
6013+
public let assignedby: SessionCreatedActor?
6014+
public let assignedat: Double?
6015+
6016+
public init(
6017+
actor: SessionCreatedActor,
6018+
assignedby: SessionCreatedActor? = nil,
6019+
assignedat: Double? = nil)
6020+
{
6021+
self.actor = actor
6022+
self.assignedby = assignedby
6023+
self.assignedat = assignedat
6024+
}
6025+
6026+
private enum CodingKeys: String, CodingKey {
6027+
case actor
6028+
case assignedby = "assignedBy"
6029+
case assignedat = "assignedAt"
6030+
}
6031+
}
6032+
60076033
public struct SessionObserverPlanProgress: Codable, Sendable {
60086034
public let completed: Int
60096035
public let total: Int
@@ -6139,6 +6165,9 @@ public struct SessionRow: Codable, Sendable {
61396165
public let spawnedcwd: String?
61406166
public let createdvia: AnyCodable?
61416167
public let createdactor: SessionCreatedActor?
6168+
public let owner: SessionOwner?
6169+
public let participants: [SessionCreatedActor]?
6170+
public let participantcount: Int?
61426171
public let visibility: SessionVisibility?
61436172
public let sharingrole: SessionSharingRole?
61446173
public let createdat: Double?
@@ -6203,6 +6232,9 @@ public struct SessionRow: Codable, Sendable {
62036232
spawnedcwd: String? = nil,
62046233
createdvia: AnyCodable? = nil,
62056234
createdactor: SessionCreatedActor? = nil,
6235+
owner: SessionOwner? = nil,
6236+
participants: [SessionCreatedActor]? = nil,
6237+
participantcount: Int? = nil,
62066238
visibility: SessionVisibility? = nil,
62076239
sharingrole: SessionSharingRole? = nil,
62086240
createdat: Double? = nil,
@@ -6266,6 +6298,9 @@ public struct SessionRow: Codable, Sendable {
62666298
self.spawnedcwd = spawnedcwd
62676299
self.createdvia = createdvia
62686300
self.createdactor = createdactor
6301+
self.owner = owner
6302+
self.participants = participants
6303+
self.participantcount = participantcount
62696304
self.visibility = visibility
62706305
self.sharingrole = sharingrole
62716306
self.createdat = createdat
@@ -6331,6 +6366,9 @@ public struct SessionRow: Codable, Sendable {
63316366
case spawnedcwd = "spawnedCwd"
63326367
case createdvia = "createdVia"
63336368
case createdactor = "createdActor"
6369+
case owner
6370+
case participants
6371+
case participantcount = "participantCount"
63346372
case visibility
63356373
case sharingrole = "sharingRole"
63366374
case createdat = "createdAt"
@@ -9559,6 +9597,50 @@ public struct SessionsDeleteParams: Codable, Sendable {
95599597
}
95609598
}
95619599

9600+
public struct SessionsAssignOwnerParams: Codable, Sendable {
9601+
public let key: String
9602+
public let agentid: String?
9603+
public let owner: [String: AnyCodable]
9604+
9605+
public init(
9606+
key: String,
9607+
agentid: String? = nil,
9608+
owner: [String: AnyCodable])
9609+
{
9610+
self.key = key
9611+
self.agentid = agentid
9612+
self.owner = owner
9613+
}
9614+
9615+
private enum CodingKeys: String, CodingKey {
9616+
case key
9617+
case agentid = "agentId"
9618+
case owner
9619+
}
9620+
}
9621+
9622+
public struct SessionsAssignOwnerResult: Codable, Sendable {
9623+
public let ok: Bool
9624+
public let key: String
9625+
public let owner: SessionOwner
9626+
9627+
public init(
9628+
ok: Bool,
9629+
key: String,
9630+
owner: SessionOwner)
9631+
{
9632+
self.ok = ok
9633+
self.key = key
9634+
self.owner = owner
9635+
}
9636+
9637+
private enum CodingKeys: String, CodingKey {
9638+
case ok
9639+
case key
9640+
case owner
9641+
}
9642+
}
9643+
95629644
public struct SessionGroup: Codable, Sendable {
95639645
public let name: String
95649646
public let position: Int
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"startupJsGzipBytes": 338704,
3-
"reason": "session placement move controls",
2+
"startupJsGzipBytes": 338241,
3+
"reason": "session placement move controls, ownership chips, assignment menus, and participant stack",
44
"updatedAt": "2026-08-17"
55
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
371735fe46e20b33bc5e942083c56040233cf5c9676b4f738f5beaf4c194f872 sqlite-session-transcript-schema-baseline.sql
1+
73cfbac3e2ef8a75d561165d9798c805e0a8c726c1bcd1c814c7cae777194b2b sqlite-session-transcript-schema-baseline.sql

‎packages/gateway-protocol/src/index.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,9 @@ describe("lazy protocol validators", () => {
166166
{ archived: false },
167167
{ archived: true },
168168
{ archived: "all" },
169+
{ involvingMe: true },
169170
]);
170-
expectRejected(validateSessionsListParams, [{ archived: "archived" }]);
171+
expectRejected(validateSessionsListParams, [{ archived: "archived" }, { involvingMe: "yes" }]);
171172
});
172173

173174
it("validates session board face list and patch values", () => {

‎packages/gateway-protocol/src/index.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ export * from "./schema/ui-command.js";
1414
export * from "./schema/board.js";
1515
export {
1616
SessionCreatedActorSchema,
17+
SessionOwnerSchema,
1718
SessionToolOverridesSchema,
1819
type SessionCreatedActor,
20+
type SessionOwner,
1921
type SessionRow,
2022
type SessionRunStatus,
2123
type SessionToolOverrides,
@@ -308,6 +310,10 @@ export {
308310
SessionsPluginPatchParamsSchema,
309311
SessionsResetParamsSchema,
310312
SessionsDeleteParamsSchema,
313+
SessionsAssignOwnerParamsSchema,
314+
SessionsAssignOwnerResultSchema,
315+
type SessionsAssignOwnerParams,
316+
type SessionsAssignOwnerResult,
311317
SessionGroupSchema,
312318
SessionGroupDefaultsSchema,
313319
SessionsGroupsListParamsSchema,

‎packages/gateway-protocol/src/schema/protocol-schema-fragment-sessions-core.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export const SessionCoreProtocolSchemas = {
3030
SessionCompactionCheckpoint: sessions.SessionCompactionCheckpointSchema,
3131
SessionOperationEvent: sessions.SessionOperationEventSchema,
3232
SessionCreatedActor: sessions.SessionCreatedActorSchema,
33+
SessionOwner: sessions.SessionOwnerSchema,
3334
SessionObserverHealth: sessions.SessionObserverHealthSchema,
3435
SessionObserverPlanProgress: sessions.SessionObserverPlanProgressSchema,
3536
SessionObserverDigest: sessions.SessionObserverDigestSchema,

‎packages/gateway-protocol/src/schema/protocol-schema-fragment-sessions-lifecycle.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ export const SessionLifecycleProtocolSchemas = {
5757
SessionsPluginPatchResult: sessions.SessionsPluginPatchResultSchema,
5858
SessionsResetParams: sessions.SessionsResetParamsSchema,
5959
SessionsDeleteParams: sessions.SessionsDeleteParamsSchema,
60+
SessionsAssignOwnerParams: sessions.SessionsAssignOwnerParamsSchema,
61+
SessionsAssignOwnerResult: sessions.SessionsAssignOwnerResultSchema,
6062
SessionGroup: sessions.SessionGroupSchema,
6163
SessionGroupDefaults: sessions.SessionGroupDefaultsSchema,
6264
SessionsGroupsListParams: sessions.SessionsGroupsListParamsSchema,

‎packages/gateway-protocol/src/schema/sessions-row.test.ts‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Value } from "typebox/value";
22
import { describe, expect, it } from "vitest";
3+
import { validateSessionsAssignOwnerParams } from "../index.js";
34
import { SessionRowSchema } from "./sessions-row.js";
45

56
describe("SessionRowSchema", () => {
@@ -14,6 +15,16 @@ describe("SessionRowSchema", () => {
1415
label: "Ada",
1516
avatarUrl: "/api/users/profile-ada/avatar?v=7",
1617
},
18+
owner: {
19+
actor: { type: "agent", id: "research", label: "Research" },
20+
assignedBy: { type: "human", id: "profile-ada", label: "Ada" },
21+
assignedAt: 42,
22+
},
23+
participants: [
24+
{ type: "human", id: "profile-bob", label: "Bob" },
25+
{ type: "agent", id: "research", label: "Research" },
26+
],
27+
participantCount: 2,
1728
archivedBy: { type: "human", id: "profile-bob", label: "Bob" },
1829
icon: "🦞",
1930
visibility: "suggest",
@@ -25,13 +36,38 @@ describe("SessionRowSchema", () => {
2536
expect(SessionRowSchema.properties.activeLeafEntryId).toBeDefined();
2637
expect(Value.Check(SessionRowSchema, roundTripped)).toBe(true);
2738
expect(Value.Check(SessionRowSchema, { ...roundTripped, activeLeafEntryId: null })).toBe(true);
39+
expect(
40+
Value.Check(SessionRowSchema, {
41+
...roundTripped,
42+
participants: Array.from({ length: 5 }, (_, index) => ({
43+
type: "human",
44+
id: `profile-${index}`,
45+
})),
46+
}),
47+
).toBe(false);
2848
expect(roundTripped).toMatchObject({
2949
activeLeafEntryId: "leaf-rendered",
3050
createdActor: { avatarUrl: "/api/users/profile-ada/avatar?v=7" },
51+
participantCount: 2,
3152
archivedBy: { type: "human", id: "profile-bob", label: "Bob" },
3253
visibility: "suggest",
3354
sharingRole: "owner",
3455
restartRecoveryStatus: "tombstoned",
3556
});
3657
});
58+
59+
it("keeps sessions.assignOwner target actors closed and non-empty", () => {
60+
const accepted = [
61+
{ key: "agent:main:handoff", owner: { type: "human", id: "profile-ada" } },
62+
{ key: "agent:main:handoff", owner: { type: "agent", id: "research" }, agentId: "main" },
63+
];
64+
const rejected = [
65+
{ key: "agent:main:handoff", owner: { type: "system", id: "system" } },
66+
{ key: "agent:main:handoff", owner: { type: "human", id: "" } },
67+
{ key: "agent:main:handoff", owner: { type: "human", id: "ada", label: "Ada" } },
68+
];
69+
70+
expect(accepted.every(validateSessionsAssignOwnerParams)).toBe(true);
71+
expect(rejected.every((value) => !validateSessionsAssignOwnerParams(value))).toBe(true);
72+
});
3773
});

‎packages/gateway-protocol/src/schema/sessions-row.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ export const SessionCreatedActorSchema = closedObject({
2323
avatarUrl: Type.Optional(NonEmptyString),
2424
});
2525

26+
/** Mutable responsibility for one session; actor display data is projected at read time. */
27+
export const SessionOwnerSchema = closedObject({
28+
actor: SessionCreatedActorSchema,
29+
assignedBy: Type.Optional(SessionCreatedActorSchema),
30+
assignedAt: Type.Optional(Type.Number({ minimum: 0 })),
31+
});
32+
2633
/** Stable Gateway session row fields; mutation envelopes may add null tombstones. */
2734
export const SessionRowSchema = Type.Object(
2835
{
@@ -109,6 +116,9 @@ export const SessionRowSchema = Type.Object(
109116
]),
110117
),
111118
createdActor: Type.Optional(SessionCreatedActorSchema),
119+
owner: Type.Optional(SessionOwnerSchema),
120+
participants: Type.Optional(Type.Array(SessionCreatedActorSchema, { maxItems: 4 })),
121+
participantCount: Type.Optional(Type.Integer({ minimum: 0 })),
112122
visibility: Type.Optional(SessionVisibilitySchema),
113123
sharingRole: Type.Optional(SessionSharingRoleSchema),
114124
createdAt: Type.Optional(Type.Number()),
@@ -134,6 +144,7 @@ export const SessionRowSchema = Type.Object(
134144
);
135145

136146
export type SessionCreatedActor = Static<typeof SessionCreatedActorSchema>;
147+
export type SessionOwner = Static<typeof SessionOwnerSchema>;
137148
export type SessionToolOverrides = Static<typeof SessionToolOverridesSchema>;
138149
export type SessionRow = Static<typeof SessionRowSchema>;
139150
export type SessionRunStatus = NonNullable<SessionRow["status"]>;

0 commit comments

Comments
 (0)