Skip to content

Commit 036e0d9

Browse files
authored
fix(sessions): keep creator rights tied to qualified profiles (#132300)
* fix(sessions): preserve qualified creator authority Record source-qualified creator provenance at trusted producers and preserve creator recognition through verified profile merges. Keep responsibility and participant history separate from authority, migrate approved agent19/state14 records, and isolate required non-profile sandboxes by canonical session. Prepare verified aliases within synchronous authorization passes and recheck catalog visibility against the current canonical session instance. AI-assisted maintainer repair. Fixes #132243 * fix(sessions): align creator migration owners and contract tests Keep the approved agent19/state14 migration SQL in the existing database migration owners without changing its behavior. Update source-qualified creator fixtures and schema assertions, and remove superseded sandbox and same-version predecessor expectations. Preserve current lifecycle and container-journal reopen coverage. AI-assisted maintainer repair. Follow-up verification for #132243. * fix(doctor): migrate supported post-media agent schemas Let the canonical agent schema owner admit and migrate supported post-media revisions instead of enumerating them again in media repair. Keep metadata, ownership, integrity, and stopped-writer checks in their existing owners. Cover v17/v18 Doctor routing, qualified creator attribution, retained goals and participants, idempotence, and future/mismatched schema refusal. Align the fork profile fixture and include the accepted native schema and presence promise-ownership test corrections for #132300.
1 parent 1318641 commit 036e0d9

153 files changed

Lines changed: 2800 additions & 895 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/macos/Tests/OpenClawIPCTests/PortGuardianRecordStoreTests.swift‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ struct PortGuardianRecordStoreTests {
568568
let fixture = try Self.fixture()
569569
defer { fixture.cleanup() }
570570

571-
for version in [4, 5, 6, 7, 8, 9, 10, 11, 12, 13] {
571+
for version in [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] {
572572
let databaseURL = fixture.root.appendingPathComponent("supported-v\(version).sqlite")
573573
try Self.seedVersionedPortGuardianDatabase(databaseURL, schemaVersion: version)
574574
let store = try PortGuardianRecordStore(databaseURL: databaseURL)
@@ -580,7 +580,7 @@ struct PortGuardianRecordStoreTests {
580580
#expect(try store.records() == [record])
581581
}
582582

583-
for version in [14, 99] {
583+
for version in [15, 99] {
584584
let databaseURL = fixture.root.appendingPathComponent("newer-v\(version).sqlite")
585585
try Self.seedVersionedPortGuardianDatabase(databaseURL, schemaVersion: version)
586586
#expect(throws: PortGuardianStoreError.self) {

‎apps/shared/OpenClawKit/Sources/OpenClawNativeState/OpenClawNativeStateSQLite.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public enum OpenClawNativeStateSQLiteValueType: Equatable, Sendable {
3737
/// One recursive connection lock serializes transactions and statement access.
3838
public final class OpenClawNativeStateSQLite: @unchecked Sendable {
3939
// Keep aligned with OPENCLAW_STATE_SCHEMA_VERSION. Native clients never upgrade this database.
40-
private static let maximumSupportedSchemaVersion: Int64 = 13
40+
private static let maximumSupportedSchemaVersion: Int64 = 14
4141
private static let defaultBusyTimeoutMilliseconds: Int32 = 5000
4242

4343
private struct SchemaObject: Hashable {

‎config/assertion-safety-baseline.txt‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2703,7 +2703,6 @@ src/config/sessions/session-accessor.sqlite-parent-fork.ts 1
27032703
src/config/sessions/session-accessor.sqlite-read.ts 12
27042704
src/config/sessions/session-accessor.sqlite-recovery.ts 1
27052705
src/config/sessions/session-accessor.sqlite-reset-window.ts 3
2706-
src/config/sessions/session-accessor.sqlite-session-row.ts 1
27072706
src/config/sessions/session-accessor.sqlite-title-probes.ts 2
27082707
src/config/sessions/session-accessor.sqlite-transcript-message-append.ts 1
27092708
src/config/sessions/session-accessor.sqlite-transcript-mirror.ts 1

‎docs/concepts/multi-user.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ If people must not access each other's sessions, tools, credentials, or files, g
1919

2020
Every session carries up to three layers of attribution:
2121

22-
- **Creator** (immutable): new sessions record a write-once `createdActor` when the creation path can prove who caused it. Authenticated people use their durable Gateway profile id; sessions spawned by an agent record that agent's id. Sessions created without a proven actor remain unattributed. Sharing and visibility authority stays anchored on the creator, even after the owner changes.
22+
- **Creator** (immutable): new sessions record a write-once `createdActor` when the creation path can prove who caused it. Human creators retain their source: a verified Gateway profile, a channel sender, or unknown historical attribution. Only a profile creator can receive implicit creator access, including through a verified profile merge. Matching channel, agent, or system IDs do not identify that person. Sharing and visibility authority stays anchored on the creator, even after the owner changes.
2323
- **Owner** (assignable): the person or agent currently responsible for the session, in the style of a GitHub issue assignee. It defaults to the creator and can be reassigned at any time; the assignment records who reassigned it and when. The sidebar avatar, the owner filter, and People sorting all follow the current owner.
2424
- **Participants** (history): authenticated people, channel senders, and requesting agents whose accepted input targets the session. The session's own agent and passive viewers are never recorded. New-identity admission is bounded at 32 records per session; repair can preserve larger existing histories. Participation is recorded best-effort in the background, so it never delays a turn.
2525

@@ -38,6 +38,8 @@ Both paths call the Gateway method `sessions.assignOwner` (`operator.write`). As
3838

3939
Reassigning the owner changes responsibility and display only. It does not transfer sharing authority (which stays with the creator) and does not grant or remove any access.
4040

41+
Creator source follows scheduled jobs and inherited creation policies; a required sandbox is a restriction, not evidence of profile identity. Historical automations that lost their creator source retain their attribution and content, but do not receive a guessed profile grant. An administrator can manage their sharing or create a new, explicitly attributed session. Assigning an owner does not repair creator authority. See [Creator namespace migration](/reference/database-schemas#creator-namespace-migration) before upgrading.
42+
4143
## Finding sessions by owner
4244

4345
The sidebar's session filter menu gains an **Owners** section when ownership is visible:
@@ -88,6 +90,8 @@ This state improves continuity; it is not an authorization or isolation boundary
8890

8991
Start a session as a draft to keep work in progress out of teammates' sidebars until you publish it. Drafts are never hidden from admins, who see other people's drafts with a faded ghost marker. This is a coordination feature, not a security boundary.
9092

93+
Catalog listings and progress updates recheck current session visibility for each recipient. Cached provider results do not preserve access to a session that has become draft or incognito. An adopted thread remains bound to its original session instance and plugin ownership; deleting and recreating a session key does not transfer the old thread to the new creator. Catalog reads and mutations also recheck the stored session after provider enumeration.
94+
9195
## Turn attribution
9296

9397
Turn sender attribution is best-effort. Steering can merge input into an active turn, so the transcript cannot always represent each person's contribution as a separate turn. Participant history records that an actor prompted the session, not which words were theirs.

‎docs/gateway/sandboxing.md‎

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,24 @@ execution or Gateway/node host overrides cannot bypass it. The default
5151
- `session`: one container per session.
5252
- `shared`: one container shared by all sandboxed sessions (per-agent `docker`/`ssh`/`browser` overrides are ignored under this scope).
5353

54-
Sessions whose creator role requires sandboxing use the creator's authenticated
55-
principal as their isolation boundary instead. Different guests on the same
56-
agent receive separate sandbox environments and workspaces, regardless of the
57-
configured scope. Sessions created by the same guest reuse that guest's
58-
environment and workspace, including when the configured scope is `session`.
54+
Required sandboxes with proven Gateway-profile creators use that profile as
55+
their isolation boundary. Different guests on the same agent receive separate
56+
environments and workspaces, regardless of configured scope. Sessions created
57+
by the same profile reuse its existing environment and workspace, including
58+
when the configured scope is `session`; this upgrade does not rekey those paths.
59+
Channel, unknown, and other non-profile creators instead receive a separate
60+
required sandbox per canonical session. A matching raw ID cannot reuse a
61+
profile's resources. Required sandboxing and the read-only workspace cap remain
62+
in force; backend failure never falls back to host execution.
5963
Sessions without a role-required sandbox keep the configured scope behavior.
6064

65+
The [creator namespace migration](/reference/database-schemas#creator-namespace-migration)
66+
does not delete or adopt old ambiguous workspaces or containers. Such sessions
67+
start with separate resources after upgrade. Preserve any needed old data
68+
before normal sandbox retention or manual cleanup, then recover selected files
69+
explicitly as an operator; do not copy an entire ambiguous environment into a
70+
trusted profile workspace automatically.
71+
6172
Non-shared runtime identity also includes the resolved agent workspace path. This prevents co-hosted workspaces that reuse the same agent or session keys from sharing Docker, browser, SSH, OpenShell, or plugin-provided sandbox state. `shared` scope intentionally remains workspace-independent.
6273

6374
The first use after upgrading from an older release creates non-shared runtimes and sandbox workspaces under the workspace-qualified identity. Existing non-shared runtimes are not adopted; this is an intentional one-time reset. They can age out through configured prune settings or be removed with `openclaw sandbox recreate`; the next use provisions the current identity.

‎docs/reference/database-schemas.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,22 @@ Use a SQLite online backup or another WAL-aware snapshot produced while the sour
141141
| 16 | Legacy top-level transcript media fields retired | Unreleased |
142142
| 17 | Tenant-free per-agent lease table retired after the last writer and routing arm were removed ([#121113](https://github.com/openclaw/openclaw/pull/121113), [#121615](https://github.com/openclaw/openclaw/pull/121615)) | Unreleased |
143143
| 18 | Canonical participant identity namespaces and explicit unknown historical input times in the existing session-owned aggregate ([#130661](https://github.com/openclaw/openclaw/issues/130661)) | Unreleased |
144+
| 19 | Source-qualified immutable session creators; historical ambiguity remains unknown | Unreleased |
144145

145146
Version 3 was an unshipped development step folded into version 4.
146147

148+
### Creator namespace migration
149+
150+
Agent schema **19** and shared-state schema **14** add a source discriminator to human creator actors in the existing session and cron JSON records. No table, sidecar, or separate identity ledger is added. The session node remains the immutable creator owner; mutable owner assignments and explicit sharing grants are unchanged.
151+
152+
Historical human creators stamped directly by `operator` or `run` creation become `profile`; channel creation becomes `channel`. Origin-losing cron, inherited spawn or Talk, legacy `createdBy`, and missing-source history remain `unknown`. The migration preserves IDs, attribution, creation times, content, and existing sandbox restrictions. A UUID, profile lookup, participant, current route, or required sandbox never supplies missing creator authority. Recovery from incomplete physical projections also produces unknown human attribution.
153+
154+
Before upgrading, stop the Gateway and all other writers, then [create and verify a WAL-aware backup](/cli/backup). Run `openclaw doctor --fix` with the new build. The agent migration retains the stopped-writer maintenance gate and runs after the schema-18 participant migration, without rebuilding already migrated participant rows. Canonical data and both schema markers commit in the owning database transaction. Shared-state and agent databases are separate transactions; if one fails, keep writers stopped and rerun Doctor before starting the Gateway.
155+
156+
Older builds refuse the new versions. For rollback, stop all writers and restore the verified pre-upgrade backups with their matching older build. Do not decrement either schema marker: an older writer cannot maintain the creator-source contract. Unknown historical provenance is irrecoverable from the stored ID alone. Administrators retain sharing management access; assigning responsibility does not restore an implicit creator grant.
157+
158+
Required sandbox resources keep their existing keys for proven profile creators. Channel and unknown creators instead use canonical-session isolation, with no new persisted principal field. Their old ambiguous resources are left untouched by migration, not automatically adopted or copied; operators must recover needed files explicitly before ordinary retention or cleanup. See [sandbox scope and recovery](/gateway/sandboxing#modes-scope-and-backend).
159+
147160
### Participant identity migration
148161

149162
Agent schema 18 rebuilds `session_participants` with the unique key `(session_key, identity_namespace, actor_id)`. The raw actor ID remains separate from its namespace. This replaces the old `(session_key, actor_type, actor_id)` key; it is not a same-version additive change. Both schema markers advance together. No companion table or per-input ledger is added.
@@ -173,6 +186,7 @@ Normal admission remains bounded at 32 identities. Same-store alias repair sums
173186
| 11 | Legacy skill curator lifecycle table and never-read proposal origin-run projection retired | Unreleased |
174187
| 12 | Thirteen singleton/cache tables retired; durable state folded into config_machine_state | Unreleased |
175188
| 13 | State consolidation: cron jobs and subagent runs become JSON-canonical (113 projection columns, five unused indexes removed); installed_plugin_index and shared auth-profile singletons fold into config_machine_state; workspace_attestations merges into workspace_setup_state; gateway origin device tokens become canonical | Unreleased |
189+
| 14 | Source-qualified cron creator capture; historical human job creators remain unknown | Unreleased |
176190

177191
### State schema 13
178192

‎extensions/voice-call/doctor-contract-api.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ function describeVoiceCallSchemaMigration(migration: OpenClawStateDatabaseSchema
152152
return "singleton state tables -> shared configuration state";
153153
case "state-consolidation-v13":
154154
return "cron jobs and subagent runs -> canonical JSON storage";
155+
case "creator-namespace-v14":
156+
return "cron creators -> explicit principal namespaces";
155157
case "worker-placement-execution-mode-v8":
156158
return "cloud worker placements -> execution-mode claims";
157159
case "operator-approvals-system-agent":

‎package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"version": "2026.8.1",
44
"openclaw": {
55
"schemaVersions": {
6-
"state": 13,
7-
"agent": 18
6+
"state": 14,
7+
"agent": 19
88
}
99
},
1010
"description": "Multi-channel AI gateway with extensible messaging integrations",

‎src/agents/sandbox.resolveSandboxContext.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ describe("resolveSandboxContext", () => {
184184
sessionId: "guest-session",
185185
updatedAt: 1,
186186
sandbox: "required" as const,
187-
createdActor: { type: "human" as const, id: "guest-principal" },
187+
createdActor: { type: "human" as const, source: "unknown" as const, id: "guest-principal" },
188188
};
189189
await replaceSessionEntry({ sessionKey, storePath }, entry);
190190
const backendFactory = vi.fn(async () => ({
@@ -480,7 +480,7 @@ describe("resolveSandboxContext", () => {
480480
sessionId: "guest-session",
481481
updatedAt: 1,
482482
sandbox: "required" as const,
483-
createdActor: { type: "human" as const, id: "guest-principal" },
483+
createdActor: { type: "human" as const, source: "unknown" as const, id: "guest-principal" },
484484
};
485485
await replaceSessionEntry({ sessionKey, storePath }, entry);
486486
const backendFailure = new Error("Required sandbox backend unavailable");

‎src/agents/sandbox/context.ts‎

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { readRegisteredSandboxRuntimeIds, updateRegistry } from "./registry.js";
2828
import { resolveSandboxRuntimeStatus } from "./runtime-status.js";
2929
import { assertSshSandboxSecretOwnerAvailable } from "./secret-owner.js";
3030
import { resolveSandboxWorkspaceLayoutPaths } from "./shared.js";
31-
import type { SandboxContext, SandboxWorkspaceInfo } from "./types.js";
31+
import type { SandboxContext, SandboxIsolationSubject, SandboxWorkspaceInfo } from "./types.js";
3232
import { ensureSandboxWorkspace } from "./workspace.js";
3333

3434
const sandboxLog = createSubsystemLogger("agent/sandbox");
@@ -86,7 +86,7 @@ async function ensureSandboxWorkspaceLayout(params: {
8686
cfg: ReturnType<typeof resolveSandboxConfigForAgent>;
8787
agentId: string;
8888
rawSessionKey: string;
89-
sandboxPrincipalId?: string;
89+
isolationSubject?: SandboxIsolationSubject;
9090
config?: OpenClawConfig;
9191
execOverrides?: ExecPolicyOverrides;
9292
skillsSnapshot?: SkillSnapshot;
@@ -106,7 +106,7 @@ async function ensureSandboxWorkspaceLayout(params: {
106106
cfg,
107107
rawSessionKey,
108108
agentId: params.agentId,
109-
sandboxPrincipalId: params.sandboxPrincipalId,
109+
isolationSubject: params.isolationSubject,
110110
workspaceDir: params.workspaceDir,
111111
});
112112

@@ -174,18 +174,13 @@ function resolveSandboxSession(params: {
174174
if (!runtime.sandboxRequired) {
175175
return { rawSessionKey, runtime, cfg: configuredSandbox };
176176
}
177-
if (!runtime.sandboxPrincipalId) {
178-
throw new Error(
179-
"A required sandbox cannot be provisioned without its session creator principal.",
180-
);
181-
}
182177
if (configuredSandbox.workspaceAccess === "rw") {
183178
sandboxLog.warn(
184179
'Configured sandbox workspaceAccess "rw" is capped to "ro" for a role-required session; guests cannot share the writable agent workspace.',
185180
);
186181
}
187182
// Docker and browser backends replace shared scope keys with a literal name;
188-
// agent scope lets the creator-qualified key own every sandbox resource.
183+
// agent scope lets the prepared isolation subject own every sandbox resource.
189184
const cfg = {
190185
...configuredSandbox,
191186
scope: "agent" as const,
@@ -261,7 +256,7 @@ async function resolveProvisionedSandboxContext(
261256
cfg,
262257
agentId: runtime.agentId,
263258
rawSessionKey,
264-
sandboxPrincipalId: runtime.sandboxPrincipalId,
259+
isolationSubject: runtime.isolationSubject,
265260
config: params.config,
266261
execOverrides: params.execOverrides,
267262
skillsSnapshot: params.skillsSnapshot,
@@ -419,7 +414,7 @@ export async function ensureSandboxWorkspaceForSession(params: {
419414
cfg,
420415
agentId: runtime.agentId,
421416
rawSessionKey,
422-
sandboxPrincipalId: runtime.sandboxPrincipalId,
417+
isolationSubject: runtime.isolationSubject,
423418
config: params.config,
424419
workspaceDir: params.workspaceDir,
425420
});

0 commit comments

Comments
 (0)