Skip to content

Commit 65e4dd4

Browse files
authored
Merge branch 'main' into fix/heartbeat-visibility-schema-parity
2 parents 20b90bf + 909509a commit 65e4dd4

723 files changed

Lines changed: 21969 additions & 6455 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/GatewayProcessManagerTests.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ struct GatewayProcessManagerTests {
680680
"loaded":true,
681681
"runtime":{"status":"running","pid":4242},
682682
"command":{"programArguments":["openclaw","gateway","--port","\(port)"]},
683-
"configAudit":{"ok":false,"issues":[{"code":"gateway-service-version-mismatch"}]}
683+
"configAudit":{"ok":false,"issues":[{"code":"gateway-entrypoint-mismatch"}]}
684684
}}
685685
""",
686686
]

‎apps/shared/OpenClawKit/Sources/OpenClawKit/DeviceIdentitySQLiteStore.swift‎

Lines changed: 92 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,29 @@ enum DeviceIdentitySQLiteStore {
3434
}
3535

3636
private final class IdentityCoordinator {
37-
private var database: OpaquePointer?
37+
private var databases: [OpaquePointer]
3838

39-
init(database: OpaquePointer) {
40-
self.database = database
39+
init(databases: [OpaquePointer]) {
40+
self.databases = databases
4141
}
4242

4343
func release() throws {
44-
guard let database else { return }
45-
self.database = nil
46-
var releaseError: NSError?
47-
if sqlite3_exec(database, "ROLLBACK", nil, nil, nil) != SQLITE_OK {
48-
releaseError = DeviceIdentityStore.storageError(
49-
"Could not release device identity coordinator: \(String(cString: sqlite3_errmsg(database)))")
44+
let databases = self.databases
45+
self.databases = []
46+
var releaseErrors: [String] = []
47+
for database in databases.reversed() {
48+
if sqlite3_exec(database, "ROLLBACK", nil, nil, nil) != SQLITE_OK {
49+
releaseErrors.append(String(cString: sqlite3_errmsg(database)))
50+
}
51+
if sqlite3_close(database) != SQLITE_OK {
52+
releaseErrors.append("could not close coordinator database")
53+
}
5054
}
51-
if sqlite3_close(database) != SQLITE_OK, releaseError == nil {
52-
releaseError = DeviceIdentityStore.storageError("Could not close device identity coordinator")
55+
if !releaseErrors.isEmpty {
56+
throw DeviceIdentityStore.storageError(
57+
"Could not release device identity coordinator: " +
58+
releaseErrors.joined(separator: "; "))
5359
}
54-
if let releaseError { throw releaseError }
5560
}
5661
}
5762

@@ -64,7 +69,11 @@ enum DeviceIdentitySQLiteStore {
6469
afterLegacyCommit: (() throws -> Void)? = nil) throws
6570
-> DeviceIdentity
6671
{
67-
let coordinator = try self.acquireIdentityCoordinator(databaseURL: databaseURL)
72+
try self.secureDirectory(destinationStateDirURL)
73+
try self.secureDirectory(databaseURL.deletingLastPathComponent())
74+
let coordinator = try self.acquireIdentityCoordinator(
75+
databaseURL: databaseURL,
76+
destinationStateDirURL: destinationStateDirURL)
6877
do {
6978
let identity = try self.loadOrCreateOwned(
7079
databaseURL: databaseURL,
@@ -128,8 +137,6 @@ enum DeviceIdentitySQLiteStore {
128137
beforeLegacyClaim: ((DeviceIdentityPaths.LegacyIdentitySource) throws -> Void)?,
129138
afterLegacyCommit: (() throws -> Void)?) throws -> DeviceIdentity
130139
{
131-
try self.secureDirectory(destinationStateDirURL)
132-
try self.secureDirectory(databaseURL.deletingLastPathComponent())
133140
// SQLite owns an existing profile; leave any downgrade-recreated legacy source for Doctor.
134141
if self.pathMayExist(databaseURL),
135142
let existing = try self.loadExisting(databaseURL: databaseURL, profile: profile)
@@ -229,17 +236,67 @@ enum DeviceIdentitySQLiteStore {
229236
return authoritative.identity
230237
}
231238

232-
private static func acquireIdentityCoordinator(databaseURL: URL) throws -> IdentityCoordinator {
233-
let canonicalPath = self.canonicalDatabasePath(databaseURL)
234-
let digest = SHA256.hash(data: Data(canonicalPath.utf8))
239+
static func resolveDeviceIdentityCoordinatorURLs(
240+
databaseURL: URL,
241+
destinationStateDirURL: URL,
242+
temporaryDirectory: URL,
243+
uid: uid_t) -> [URL]
244+
{
245+
let canonicalDatabasePath = self.canonicalExistingAncestorPath(databaseURL)
246+
let digest = SHA256.hash(data: Data(canonicalDatabasePath.utf8))
235247
let pathHash = digest.prefix(4).map { String(format: "%02x", $0) }.joined()
236-
let lockDirectoryURL = FileManager.default.temporaryDirectory
237-
.appendingPathComponent("openclaw-\(getuid())", isDirectory: true)
238-
try self.secureCoordinatorDirectory(lockDirectoryURL)
239-
let coordinatorURL = lockDirectoryURL.appendingPathComponent(
240-
"device-identity.\(pathHash).lock.sqlite",
241-
isDirectory: false)
248+
let filename = "device-identity.\(pathHash).lock.sqlite"
249+
let suffix = "openclaw-\(uid)"
250+
let canonicalStateDirURL = URL(
251+
fileURLWithPath: self.canonicalExistingAncestorPath(destinationStateDirURL),
252+
isDirectory: true)
253+
let orderedURLs = [
254+
temporaryDirectory.standardizedFileURL
255+
.appendingPathComponent(suffix, isDirectory: true)
256+
.appendingPathComponent(filename, isDirectory: false),
257+
canonicalStateDirURL
258+
.appendingPathComponent("tmp", isDirectory: true)
259+
.appendingPathComponent(suffix, isDirectory: true)
260+
.appendingPathComponent(filename, isDirectory: false),
261+
]
262+
var seen: Set<String> = []
263+
return orderedURLs.filter { seen.insert(self.canonicalExistingAncestorPath($0)).inserted }
264+
}
242265

266+
private static func acquireIdentityCoordinator(
267+
databaseURL: URL,
268+
destinationStateDirURL: URL) throws -> IdentityCoordinator
269+
{
270+
let coordinatorURLs = self.resolveDeviceIdentityCoordinatorURLs(
271+
databaseURL: databaseURL,
272+
destinationStateDirURL: destinationStateDirURL,
273+
temporaryDirectory: FileManager.default.temporaryDirectory,
274+
uid: getuid())
275+
for coordinatorURL in coordinatorURLs {
276+
try self.secureCoordinatorDirectory(coordinatorURL.deletingLastPathComponent())
277+
}
278+
var databases: [OpaquePointer] = []
279+
do {
280+
// v2026.7.2-beta.4 through beta.7 use process temp. Keep it first until
281+
// those builds are no longer rolling-upgrade peers.
282+
for coordinatorURL in coordinatorURLs {
283+
try databases.append(self.acquireIdentityCoordinator(at: coordinatorURL))
284+
}
285+
return IdentityCoordinator(databases: databases)
286+
} catch let acquisitionError {
287+
do {
288+
try IdentityCoordinator(databases: databases).release()
289+
} catch let cleanupError {
290+
throw DeviceIdentityStore.storageError(
291+
"Could not acquire every device identity coordinator: " +
292+
"\(acquisitionError.localizedDescription); cleanup failed: " +
293+
cleanupError.localizedDescription)
294+
}
295+
throw acquisitionError
296+
}
297+
}
298+
299+
private static func acquireIdentityCoordinator(at coordinatorURL: URL) throws -> OpaquePointer {
243300
var database: OpaquePointer?
244301
let flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FULLMUTEX
245302
let openResult = sqlite3_open_v2(coordinatorURL.path, &database, flags, nil)
@@ -254,16 +311,17 @@ enum DeviceIdentitySQLiteStore {
254311
"Could not configure device identity coordinator timeout: " +
255312
String(cString: sqlite3_errmsg(database)))
256313
}
314+
try self.secureFile(coordinatorURL)
257315
var errorMessage: UnsafeMutablePointer<CChar>?
258316
guard sqlite3_exec(database, "BEGIN EXCLUSIVE", nil, nil, &errorMessage) == SQLITE_OK else {
259317
let detail = errorMessage.map { String(cString: $0) }
260318
?? String(cString: sqlite3_errmsg(database))
261319
sqlite3_free(errorMessage)
262320
throw DeviceIdentityStore.storageError("Could not acquire device identity coordinator: \(detail)")
263321
}
264-
try self.secureFile(coordinatorURL)
265-
return IdentityCoordinator(database: database)
322+
return database
266323
} catch {
324+
sqlite3_exec(database, "ROLLBACK", nil, nil, nil)
267325
sqlite3_close(database)
268326
throw error
269327
}
@@ -276,9 +334,10 @@ enum DeviceIdentitySQLiteStore {
276334
guard inspectError == ENOENT else {
277335
throw POSIXError(POSIXErrorCode(rawValue: inspectError) ?? .EIO)
278336
}
279-
if mkdir(url.path, mode_t(0o700)) != 0, errno != EEXIST {
280-
throw POSIXError(POSIXErrorCode(rawValue: errno) ?? .EIO)
281-
}
337+
try FileManager.default.createDirectory(
338+
at: url,
339+
withIntermediateDirectories: true,
340+
attributes: [.posixPermissions: 0o700])
282341
guard lstat(url.path, &info) == 0 else {
283342
throw POSIXError(POSIXErrorCode(rawValue: errno) ?? .EIO)
284343
}
@@ -302,19 +361,19 @@ enum DeviceIdentitySQLiteStore {
302361
}
303362
}
304363

305-
private static func canonicalDatabasePath(_ databaseURL: URL) -> String {
364+
private static func canonicalExistingAncestorPath(_ url: URL) -> String {
306365
let fileManager = FileManager.default
307-
let resolved = databaseURL.standardizedFileURL
366+
let resolved = url.standardizedFileURL
308367
var current = resolved
309368
var missingSegments: [String] = []
310369
while !fileManager.fileExists(atPath: current.path) {
311370
let parent = current.deletingLastPathComponent()
312371
guard parent.path != current.path else { return resolved.path }
313-
missingSegments.insert(current.lastPathComponent, at: 0)
372+
missingSegments.append(current.lastPathComponent)
314373
current = parent
315374
}
316375
var canonical = current.resolvingSymlinksInPath().standardizedFileURL
317-
for segment in missingSegments {
376+
for segment in missingSegments.reversed() {
318377
canonical.appendPathComponent(segment)
319378
}
320379
return canonical.standardizedFileURL.path

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4690,6 +4690,8 @@ public struct SessionsResolveParams: Codable, Sendable {
46904690
public let key: String?
46914691
public let sessionid: String?
46924692
public let label: String?
4693+
public let shortid: String?
4694+
public let slughint: String?
46934695
public let agentid: String?
46944696
public let spawnedby: String?
46954697
public let includeglobal: Bool?
@@ -4700,6 +4702,8 @@ public struct SessionsResolveParams: Codable, Sendable {
47004702
key: String? = nil,
47014703
sessionid: String? = nil,
47024704
label: String? = nil,
4705+
shortid: String? = nil,
4706+
slughint: String? = nil,
47034707
agentid: String? = nil,
47044708
spawnedby: String? = nil,
47054709
includeglobal: Bool? = nil,
@@ -4709,6 +4713,8 @@ public struct SessionsResolveParams: Codable, Sendable {
47094713
self.key = key
47104714
self.sessionid = sessionid
47114715
self.label = label
4716+
self.shortid = shortid
4717+
self.slughint = slughint
47124718
self.agentid = agentid
47134719
self.spawnedby = spawnedby
47144720
self.includeglobal = includeglobal
@@ -4720,6 +4726,8 @@ public struct SessionsResolveParams: Codable, Sendable {
47204726
case key
47214727
case sessionid = "sessionId"
47224728
case label
4729+
case shortid = "shortId"
4730+
case slughint = "slugHint"
47234731
case agentid = "agentId"
47244732
case spawnedby = "spawnedBy"
47254733
case includeglobal = "includeGlobal"
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import Darwin
2+
import Foundation
3+
import Testing
4+
@testable import OpenClawKit
5+
6+
private struct DeviceIdentityCoordinatorContractFixture: Decodable {
7+
let databasePath: String
8+
let stateDirectory: String
9+
let temporaryDirectory: String
10+
let uid: UInt32
11+
let orderedExpectedPaths: [String]
12+
}
13+
14+
private enum DeviceIdentityCoordinatorContractFixtureLoader {
15+
static func load() throws -> DeviceIdentityCoordinatorContractFixture {
16+
let fixtureURL = try self.findFixtureURL(startingAt: URL(fileURLWithPath: #filePath))
17+
return try JSONDecoder().decode(
18+
DeviceIdentityCoordinatorContractFixture.self,
19+
from: Data(contentsOf: fixtureURL))
20+
}
21+
22+
private static func findFixtureURL(startingAt fileURL: URL) throws -> URL {
23+
var directory = fileURL.deletingLastPathComponent()
24+
while directory.path != "/" {
25+
let candidate = directory.appendingPathComponent(
26+
"test/fixtures/device-identity-coordinator-contract.json")
27+
if FileManager.default.fileExists(atPath: candidate.path) {
28+
return candidate
29+
}
30+
directory.deleteLastPathComponent()
31+
}
32+
throw NSError(domain: "DeviceIdentityCoordinatorContractFixtureLoader", code: 1)
33+
}
34+
}
35+
36+
struct DeviceIdentityCoordinatorContractTests {
37+
@Test func `matches shared ordered path vector`() throws {
38+
let fixture = try DeviceIdentityCoordinatorContractFixtureLoader.load()
39+
let resolved = DeviceIdentitySQLiteStore.resolveDeviceIdentityCoordinatorURLs(
40+
databaseURL: URL(fileURLWithPath: fixture.databasePath),
41+
destinationStateDirURL: URL(fileURLWithPath: fixture.stateDirectory, isDirectory: true),
42+
temporaryDirectory: URL(fileURLWithPath: fixture.temporaryDirectory, isDirectory: true),
43+
uid: uid_t(fixture.uid))
44+
45+
#expect(resolved.map(\.path) == fixture.orderedExpectedPaths)
46+
}
47+
}

‎apps/shared/OpenClawKit/Tests/OpenClawKitTests/DeviceIdentityStoreTests.swift‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import CryptoKit
2+
import Darwin
23
import Foundation
34
import SQLite3
45
import Testing
@@ -442,6 +443,22 @@ struct DeviceIdentityStoreTests {
442443
FileManager.default.attributesOfItem(atPath: fixture.databaseURL.path)[.posixPermissions] as? NSNumber)
443444
#expect(directoryMode.intValue & 0o777 == 0o700)
444445
#expect(databaseMode.intValue & 0o777 == 0o600)
446+
447+
let coordinatorURLs = DeviceIdentitySQLiteStore.resolveDeviceIdentityCoordinatorURLs(
448+
databaseURL: fixture.databaseURL,
449+
destinationStateDirURL: fixture.destination,
450+
temporaryDirectory: FileManager.default.temporaryDirectory,
451+
uid: getuid())
452+
#expect(coordinatorURLs.count == 2)
453+
for coordinatorURL in coordinatorURLs {
454+
let coordinatorDirectoryMode = try #require(
455+
FileManager.default.attributesOfItem(
456+
atPath: coordinatorURL.deletingLastPathComponent().path)[.posixPermissions] as? NSNumber)
457+
let coordinatorFileMode = try #require(
458+
FileManager.default.attributesOfItem(atPath: coordinatorURL.path)[.posixPermissions] as? NSNumber)
459+
#expect(coordinatorDirectoryMode.intValue & 0o777 == 0o700)
460+
#expect(coordinatorFileMode.intValue & 0o777 == 0o600)
461+
}
445462
}
446463

447464
@Test

‎config/knip.all-exports.config.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ const ROOT_TEST_ENTRY_GLOBS = [
5656
// Invoked directly by the Docker image-auth scenario.
5757
"test/e2e/qa-lab/runtime/openai-image-auth-docker-client.ts!",
5858
"test/e2e/qa-lab/runtime/system-agent-first-run-docker-client.ts!",
59+
// Loaded through NODE_OPTIONS by the Doctor SecretRef E2E; no static import edge exists.
60+
"test/fixtures/windows-acl-tools-unavailable.mjs!",
5961
// QA scenario YAML dispatches these scripts/tests by path rather than import.
6062
...QA_SCENARIO_EXECUTION_ENTRIES,
6163
// Invoked directly by the sandbox bind-conflict E2E verification script.

‎docs/.generated/plugin-sdk-api-baseline.sha256‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ e5e67ddf3cab38fcbf9220bc3160715897e2709d9a9ff6ff36f1ecc9453c2367 module/agent-c
77
50893fb8eac4090735ecb677c96180690804fb7354fd4e88147f3f956cefab88 module/agent-harness-runtime
88
5168648cd946abad8a92822889f13ceacc87ed502314a66190d0b1eb8ebe76ea module/agent-media-payload
99
e82bf122ca0787ec0bcdd12b669cfe24f07da16be1f4090e84c7d645b07ac79f module/agent-runtime
10+
770bcb35221a019c70eace0200233a3a7985b24a6df48625f3e67b478d071ed1 module/agent-scope-runtime
1011
56b6d5fb6af3d95af1200065aca2e7d4f59e5fa59740505fe6ff433077ef6646 module/allow-from
1112
55cea5390d68839ca7768b4a0cc570b17b65fa0fa3bc4d76130ef0f16cb79ede module/allowlist-config-edit
1213
7ddd81bd5f55de9adf64bf4d92d012f24b37b6da0a72805a3a220d8feff24ca3 module/approval-auth-runtime

‎docs/.i18n/zh-Hans-navigation.json‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,8 +508,28 @@
508508
"tab": "发布与 CI",
509509
"groups": [
510510
{
511-
"group": "发布策略",
512-
"pages": ["zh-CN/reference/RELEASING", "zh-CN/reference/test"]
511+
"group": "发布说明",
512+
"pages": [
513+
"zh-CN/releases/index",
514+
"zh-CN/releases/2026.7.1",
515+
"zh-CN/releases/2026.6.11"
516+
]
517+
},
518+
{
519+
"group": "成熟度",
520+
"pages": ["zh-CN/maturity/scorecard", "zh-CN/maturity/taxonomy"]
521+
},
522+
{
523+
"group": "发布流程",
524+
"pages": [
525+
"zh-CN/reference/RELEASING",
526+
"zh-CN/reference/full-release-validation",
527+
"zh-CN/reference/release-performance-sweep"
528+
]
529+
},
530+
{
531+
"group": "测试与 CI",
532+
"pages": ["zh-CN/reference/test", "zh-CN/ci", "zh-CN/help/scripts"]
513533
}
514534
]
515535
},

‎docs/automation/cron-jobs.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ Model-selection precedence for isolated jobs, highest first:
228228
3. User-selected stored automation-session model override
229229
4. Agent/default model selection
230230

231-
Fast mode follows the resolved live selection. If the selected model config has `params.fastMode`, isolated automation runs use it by default; a stored session `fastMode` override (then an agent `fastModeDefault`) still wins over model config either direction. Auto mode uses the model's `params.fastAutoOnSeconds` cutoff, defaulting to 60 seconds.
231+
Fast mode follows the resolved live selection. Isolated automation resolves it in this order: stored session `fastMode`, per-agent `agents.entries.*.fastModeDefault`, global `agents.defaults.fastModeDefault`, then selected-model `params.fastMode`. Auto mode uses the model's `params.fastAutoOnSeconds` cutoff, defaulting to 60 seconds.
232232

233233
If a run hits a live model-switch handoff, the scheduler retries with the switched provider/model and persists that selection (and any new auth profile) for the active run. Retries are bounded: after the initial attempt plus 2 switch retries, the scheduler aborts instead of looping.
234234

0 commit comments

Comments
 (0)