Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
583 commits
Select commit Hold shift + click to select a range
33776a6
test: preserve canonical hibernation through corrupt sidecar
lawrencecchen Jul 18, 2026
713e126
test: wire hook store scale suite
lawrencecchen Jul 18, 2026
9ac7a88
test: reject newest Pi transcript inference
lawrencecchen Jul 18, 2026
6df76fd
fix: preserve canonical restore through corrupt sidecar
lawrencecchen Jul 18, 2026
8ab1e82
test: serialize Pi hook capture writes
lawrencecchen Jul 18, 2026
20ff0f2
test: use valid JSON for rejected registry row
lawrencecchen Jul 18, 2026
309b280
fix: preserve explicit fork restore authority
lawrencecchen Jul 18, 2026
ebdce1f
test: isolate root hook persistence
lawrencecchen Jul 18, 2026
4d2abc7
fix: skip quarantined sidecar during restore preflight
lawrencecchen Jul 18, 2026
ed6aab5
fix: expose quarantine-aware restore preflight
lawrencecchen Jul 18, 2026
fd9b95d
test: preserve restore authority across precommit teardown
lawrencecchen Jul 18, 2026
baa9f66
test: reject inherited agent authority overrides
lawrencecchen Jul 18, 2026
4fc08e4
fix: require Pi-family session identity
lawrencecchen Jul 18, 2026
f1469a6
fix: adopt restore authority from canonical binding
lawrencecchen Jul 18, 2026
95180e3
test: import ownership regression subject
lawrencecchen Jul 18, 2026
f01ab13
test: drive ownership bypass through hook process
lawrencecchen Jul 18, 2026
d2f51c1
test: reject colliding agent graph identities
lawrencecchen Jul 18, 2026
3114e68
test: reject unknown interactive subcommand flags
lawrencecchen Jul 18, 2026
d990603
fix: make agent graph identities collision free
lawrencecchen Jul 18, 2026
4b13052
fix: fail closed on interactive subcommand flags
lawrencecchen Jul 18, 2026
afabb22
test: cover bypass on session ownership entrypoint
lawrencecchen Jul 18, 2026
3f47745
fix: require proven fork ancestry
lawrencecchen Jul 18, 2026
c6320d2
test: cover nonblocking OpenCode hook delivery
lawrencecchen Jul 18, 2026
0457cee
fix: remove root ownership test bypass
lawrencecchen Jul 18, 2026
48ff1f0
test: isolate lineage authority regressions
lawrencecchen Jul 18, 2026
7a15eb7
test: cover abandoned and foreign hibernations
lawrencecchen Jul 18, 2026
0f40d0a
test: persist transcript recovery across restart
lawrencecchen Jul 18, 2026
e35ec81
test: preserve OpenCode lifecycle hook order
lawrencecchen Jul 18, 2026
345b96f
test: bind restart recovery metadata to snapshot
lawrencecchen Jul 18, 2026
e79f1e1
Fix OMP resume integration assertion
lawrencecchen Jul 18, 2026
7bb1000
Use live Codex process in ownership tests
lawrencecchen Jul 18, 2026
8e2c14b
test: preserve OpenCode hooks under queue overload
lawrencecchen Jul 18, 2026
5aae728
fix: make OpenCode lifecycle hooks nonblocking
lawrencecchen Jul 18, 2026
b490151
test: preserve abandoned hibernation releases across restart
lawrencecchen Jul 18, 2026
6c350d4
test: keep runtime metadata CLI decoding forward compatible
lawrencecchen Jul 18, 2026
5ccef3d
test: fence restart transcript recovery
lawrencecchen Jul 18, 2026
bd363e6
test: bind hibernation snapshots to authority generation
lawrencecchen Jul 18, 2026
953aff6
test: bound abandoned hibernation reconciliation
lawrencecchen Jul 18, 2026
dc829f6
test: require proof before transcript cleanup
lawrencecchen Jul 18, 2026
7dda33f
test: fence transcript recovery on live writers
lawrencecchen Jul 18, 2026
e29281e
fix: prove transcript bytes before cleanup
lawrencecchen Jul 18, 2026
b79e972
test: apply agent tree budgets after filters
lawrencecchen Jul 18, 2026
2a82129
fix: enforce agent tree budgets after filters
lawrencecchen Jul 18, 2026
92c5b59
fix: recover protected transcripts after restart
lawrencecchen Jul 18, 2026
65609d7
fix: preserve transcript recovery invariants
lawrencecchen Jul 18, 2026
3b614f3
fix: fence hibernation ownership across runtimes
lawrencecchen Jul 18, 2026
f410fc0
fix: durably release abandoned hibernations
lawrencecchen Jul 18, 2026
6282ff0
test: preserve history authority across removal crash
lawrencecchen Jul 18, 2026
5a585f2
test: preserve OpenCode terminal hooks across restart
lawrencecchen Jul 18, 2026
463b9d4
fix: drop unrelated merge resolution drift
lawrencecchen Jul 18, 2026
19c530f
test: bound agent JSON output memory
lawrencecchen Jul 18, 2026
674f23f
test: construct agent list payloads lazily
lawrencecchen Jul 18, 2026
a93d674
test: bound OpenCode shutdown reconciliation
lawrencecchen Jul 18, 2026
423b182
test: fence prepared history release transactions
lawrencecchen Jul 18, 2026
df080d4
fix: reconcile OpenCode hooks on shutdown
lawrencecchen Jul 18, 2026
1509f31
test: reinstall OpenCode hooks after reload
lawrencecchen Jul 18, 2026
4e97fc4
fix: reinstall OpenCode hooks after reload
lawrencecchen Jul 18, 2026
0aff505
test: preserve OpenCode stop reconciliation
lawrencecchen Jul 18, 2026
a5562c3
fix: preserve OpenCode final outcomes on reload
lawrencecchen Jul 18, 2026
732d110
test: fence disposed OpenCode plugin generations
lawrencecchen Jul 18, 2026
6586fa9
fix: bound agent CLI output memory
lawrencecchen Jul 18, 2026
343a92f
fix: fence OpenCode plugin disposal generations
lawrencecchen Jul 18, 2026
7b3e2fd
test: require session restore startup breadcrumbs
lawrencecchen Jul 18, 2026
1a5c0dd
refactor: own staged agent output publishing
lawrencecchen Jul 18, 2026
d8d2e35
fix: log session restore decisions at startup
lawrencecchen Jul 18, 2026
0eefdb2
test: name the invoked agent list command
lawrencecchen Jul 18, 2026
92e316f
test: reject nonregular agent session stores
lawrencecchen Jul 18, 2026
133675f
fix: refuse nonregular agent session stores
lawrencecchen Jul 18, 2026
a5a8715
perf: batch session restore breadcrumbs
lawrencecchen Jul 18, 2026
ce50805
refactor: inject CLI agent session helpers
lawrencecchen Jul 18, 2026
13c9805
fix: name the invoked agent list command
lawrencecchen Jul 18, 2026
1123fa5
test: verify OpenCode restore through app index
lawrencecchen Jul 18, 2026
e4188b8
test: pin provider lifecycle edge cases
lawrencecchen Jul 18, 2026
f76f8ca
test: require structured agent CLI failures
lawrencecchen Jul 18, 2026
0006ef1
test: reject malformed Claude stream forwarding
lawrencecchen Jul 18, 2026
cda1ab9
fix: classify current agent CLI modes
lawrencecchen Jul 18, 2026
b988de8
test: require structured agent runtime failures
lawrencecchen Jul 18, 2026
6da6b5e
test: bound agent list history materialization
lawrencecchen Jul 18, 2026
9a88724
perf: bound agent list history reads
lawrencecchen Jul 18, 2026
ebed46c
fix: structure agent CLI failures
lawrencecchen Jul 18, 2026
84bb088
test: cover bounded list fallback semantics
lawrencecchen Jul 18, 2026
2074c99
fix: preserve bounded list failure semantics
lawrencecchen Jul 18, 2026
4ccff0d
test: preserve restore authority after history removal
lawrencecchen Jul 18, 2026
78d1163
test: bound Claude workflow transcript discovery
lawrencecchen Jul 18, 2026
f1b2ae5
fix: preserve hibernation authority after history removal
lawrencecchen Jul 18, 2026
b8698f3
test: harden private launcher script stores
lawrencecchen Jul 18, 2026
c5cc13f
perf: bound Claude workflow transcript discovery
lawrencecchen Jul 18, 2026
4569d9e
fix: harden private launcher script stores
lawrencecchen Jul 18, 2026
4afa80e
test: preserve canonical slot and storage semantics
lawrencecchen Jul 18, 2026
459b2b8
test: assert exact active slot owner storage
lawrencecchen Jul 18, 2026
5293da4
fix: preserve active slot storage invariants
lawrencecchen Jul 18, 2026
ce56ebe
test: bound hibernation registry projection
lawrencecchen Jul 18, 2026
7be5323
test: scope periodic hibernation registry loads
lawrencecchen Jul 18, 2026
77e1aff
perf: project exact hibernation registry owners
lawrencecchen Jul 18, 2026
4539034
test: skip historical process inspection during hibernation
lawrencecchen Jul 18, 2026
a444d49
test: preserve hibernation authority handoffs
lawrencecchen Jul 18, 2026
ed6d172
perf: bound periodic hibernation registry reads
lawrencecchen Jul 18, 2026
989187a
test: retain closed hibernation recovery authority
lawrencecchen Jul 18, 2026
1afd35e
test: restore detached hibernation authority
lawrencecchen Jul 18, 2026
3e3058a
test: keep unknown hibernation owners inert
lawrencecchen Jul 18, 2026
df727bf
test: preserve unknown resumed owners
lawrencecchen Jul 18, 2026
b207ab9
fix: make hibernation authority handoffs durable
lawrencecchen Jul 18, 2026
ceab79c
test: reconcile startup hibernation authority
lawrencecchen Jul 18, 2026
393cd94
test: cover startup restore ownership states
lawrencecchen Jul 18, 2026
e505f3e
test: clear completed hibernation attempts
lawrencecchen Jul 18, 2026
b4b3081
fix: retire completed hibernation attempts on activation
lawrencecchen Jul 18, 2026
46dcfd2
test: reclaim rejected hibernation launchers
lawrencecchen Jul 18, 2026
6d26d69
fix: defer hibernation launcher allocation until claim
lawrencecchen Jul 18, 2026
a5aee33
test: reject noninteractive protected activation
lawrencecchen Jul 18, 2026
89205bd
fix: require interactive protected activation
lawrencecchen Jul 18, 2026
8ac5083
test: fence stale hibernation compensation
lawrencecchen Jul 18, 2026
969e0fe
test: cover startup ownership handoff edges
lawrencecchen Jul 18, 2026
895b928
test: preserve hibernated parents when forking
lawrencecchen Jul 18, 2026
883262e
test: reject nested custom restore authority
lawrencecchen Jul 18, 2026
27b48ba
fix: recognize nested custom agent lineage
lawrencecchen Jul 18, 2026
1d129ab
test: keep incomplete restore attempts inert
lawrencecchen Jul 18, 2026
d1aa53b
feat: carry hibernated resume attempt evidence
lawrencecchen Jul 18, 2026
f6424e3
test: require exact custom resume authority
lawrencecchen Jul 18, 2026
54a9a07
fix: reconcile durable agent owners before restore
lawrencecchen Jul 18, 2026
ce689b0
fix: prove custom hibernated resumes exactly
lawrencecchen Jul 18, 2026
1fcf44c
test: require frozen shell through hibernation free
lawrencecchen Jul 18, 2026
fda0502
test: retain exact custom resume authority
lawrencecchen Jul 18, 2026
3de835e
test: require reliable exact shell resume
lawrencecchen Jul 18, 2026
859ec8c
test: cover full legacy graph overlap
lawrencecchen Jul 18, 2026
e41bd7a
fix: preserve proven custom resume authority
lawrencecchen Jul 18, 2026
c696dec
fix: close frozen shell teardown window
lawrencecchen Jul 18, 2026
e829a38
fix: synchronize shell stop without polling
lawrencecchen Jul 18, 2026
3e19992
test: require Kimi process detection parity
lawrencecchen Jul 18, 2026
66e0713
fix: detect Kimi processes across runtime producers
lawrencecchen Jul 18, 2026
f7293b9
fix: import socket settings for ownership probe
lawrencecchen Jul 18, 2026
9eeeb47
fix: avoid overlapping restore snapshot access
lawrencecchen Jul 18, 2026
cdf6e66
test: cover Cursor exec-a launch arguments
lawrencecchen Jul 18, 2026
0db304e
fix: unwrap Cursor exec-a launch arguments
lawrencecchen Jul 18, 2026
116778d
test: cover collapsed Pi and OMP launch titles
lawrencecchen Jul 18, 2026
3c62c11
fix: recover launch mode from exact hook capture
lawrencecchen Jul 18, 2026
7c2832d
fix: harden agent session registry inspection
lawrencecchen Jul 18, 2026
e249c5a
test: cover collapsed Kimi and one-shot titles
lawrencecchen Jul 18, 2026
40fbbd6
test: cover agent inspection aliases and schema
lawrencecchen Jul 18, 2026
7505d81
test: cover legacy sidecar deletion race
lawrencecchen Jul 18, 2026
8e6e347
test: fix empty agent payload assertions
lawrencecchen Jul 18, 2026
ef39525
fix: complete agent inspection filter contracts
lawrencecchen Jul 18, 2026
5ec66f4
fix: recover from legacy sidecar deletion races
lawrencecchen Jul 18, 2026
4a6a149
test: bind fork diagnostics to projected run authority
lawrencecchen Jul 18, 2026
74af52b
test: keep launcher fixtures in test scope
lawrencecchen Jul 18, 2026
473315c
fix: harden transcript recovery authority
lawrencecchen Jul 18, 2026
34704a6
fix: bind fork diagnostics to projected run authority
lawrencecchen Jul 18, 2026
83b9831
test: require append-prefix atomic restore
lawrencecchen Jul 18, 2026
b89ed1e
fix: restore protected transcript prefixes atomically
lawrencecchen Jul 18, 2026
2e3a710
fix: bound transcript restore recovery work
lawrencecchen Jul 18, 2026
6fc67fe
test: prefer canonical fork authority over stale demotion
lawrencecchen Jul 18, 2026
3e731c1
fix: prefer canonical fork authority over stale records
lawrencecchen Jul 18, 2026
14b0401
test: repair hibernation process harness
lawrencecchen Jul 18, 2026
079405a
test: import agent registry package in OpenCode tests
lawrencecchen Jul 18, 2026
7493d44
test: import app restore index in OpenCode tests
lawrencecchen Jul 18, 2026
2426d0b
test: cover restore sidecar replacement race
lawrencecchen Jul 18, 2026
4553329
test: project canonical run restore authority
lawrencecchen Jul 18, 2026
115940e
test: fix agent CLI assertion compilation
lawrencecchen Jul 18, 2026
4fba61b
test: unwrap optional restore authority assertions
lawrencecchen Jul 18, 2026
dfc89a8
fix: project app restore authority from canonical runs
lawrencecchen Jul 18, 2026
c221521
test: expose staged agent output helper
lawrencecchen Jul 18, 2026
e03af34
test: split fork diagnostics fixtures
lawrencecchen Jul 18, 2026
c5c3e16
test: reject invalid startup restore owners
lawrencecchen Jul 18, 2026
e5d05cc
test: canonicalize runtime ownership probes
lawrencecchen Jul 18, 2026
fcdb38b
fix: validate startup restore lifecycle authority
lawrencecchen Jul 18, 2026
5c27be6
fix: pin restored legacy session revisions
lawrencecchen Jul 18, 2026
00c1002
test: unwrap startup restore assertions
lawrencecchen Jul 18, 2026
0b94d09
fix: bind runtime ownership to canonical runs
lawrencecchen Jul 18, 2026
7752564
test: fail closed on canonical run conflicts
lawrencecchen Jul 18, 2026
a8b86ab
test: project hibernation claim authority from runs
lawrencecchen Jul 18, 2026
1fe7341
fix: project hibernation mutations from canonical runs
lawrencecchen Jul 18, 2026
9a3a5a7
fix: canonicalize CLI session mutations
lawrencecchen Jul 18, 2026
6a63679
test: align transcript recovery fixtures
lawrencecchen Jul 18, 2026
cecf407
test: read nested authority from canonical runs
lawrencecchen Jul 18, 2026
4305041
fix: project nested hook restore authority
lawrencecchen Jul 18, 2026
35224fb
test: reject three-way runtime identity conflicts
lawrencecchen Jul 18, 2026
6bd7cb3
test: diagnose frozen child resume boundary
lawrencecchen Jul 18, 2026
0df302b
fix: fail closed on conflicting runtime generations
lawrencecchen Jul 18, 2026
ba22c08
test: cover offline custom agent discovery
lawrencecchen Jul 18, 2026
1bcb7c0
test: reset spawned child signal state
lawrencecchen Jul 18, 2026
56ad970
test: reject child restore authority evidence
lawrencecchen Jul 19, 2026
0672113
fix: discover and restore custom agent providers
lawrencecchen Jul 19, 2026
d66cb1c
fix: normalize child run restore authority
lawrencecchen Jul 19, 2026
9668cf7
test: require batched provider storage metrics
lawrencecchen Jul 19, 2026
1104475
perf: batch provider storage preflight
lawrencecchen Jul 19, 2026
f1b455d
test: preserve monotonic run authority projection
lawrencecchen Jul 19, 2026
98b0c2f
test: cover partial agent registry migrations
lawrencecchen Jul 19, 2026
373b901
test: reject completed legacy restore authority
lawrencecchen Jul 19, 2026
72a3be6
fix: repair partial agent registry migrations
lawrencecchen Jul 19, 2026
81a0486
test: cover legacy and provisional authority transitions
lawrencecchen Jul 19, 2026
4859b14
test: keep hibernation provider loads relevant
lawrencecchen Jul 19, 2026
3e3aa81
fix: preserve monotonic restore authority
lawrencecchen Jul 19, 2026
3df2470
test: reject stale legacy after corrupt registry state
lawrencecchen Jul 19, 2026
333bf7f
test: keep unavailable agent commands retryable
lawrencecchen Jul 19, 2026
99323a2
perf: batch relevant hibernation providers
lawrencecchen Jul 19, 2026
cab62b0
test: bound Vault detection and restore inputs
lawrencecchen Jul 19, 2026
f15b294
test: assert agent projection parity
lawrencecchen Jul 19, 2026
90d86e7
test: cover exact provider selection edge cases
lawrencecchen Jul 19, 2026
66da7a9
test: bound project config lookup fanout
lawrencecchen Jul 19, 2026
6d78728
test: cover case-folded live provider joins
lawrencecchen Jul 19, 2026
948c22a
perf: bound and canonicalize agent discovery
lawrencecchen Jul 19, 2026
d075346
fix: type canonical observation projections
lawrencecchen Jul 19, 2026
1b8cb8e
test: share bounded list budget across providers
lawrencecchen Jul 19, 2026
354e057
perf: apply one global list candidate budget
lawrencecchen Jul 19, 2026
58404ad
test: lock global agent list ordering
lawrencecchen Jul 19, 2026
5ba8dac
test: retain global list cutoff ties
lawrencecchen Jul 19, 2026
89afda2
test: reject legacy fallback for corrupt registry
lawrencecchen Jul 19, 2026
b5d748c
fix: fail closed on unreadable agent registry
lawrencecchen Jul 19, 2026
7ed5852
test: cover replacement roots without start metadata
lawrencecchen Jul 19, 2026
ab802c0
fix: recover authority for replacement agent processes
lawrencecchen Jul 19, 2026
4bea2dd
fix: validate agent commands before restore and fork
lawrencecchen Jul 19, 2026
87bc70a
Fix agent CLI regression test target scope
lawrencecchen Jul 19, 2026
dfb240b
test: bound aggregate legacy refresh reads
lawrencecchen Jul 19, 2026
4253b16
test: prioritize relevant hibernation refreshes
lawrencecchen Jul 19, 2026
01a0a6b
test: cover corrupt canonical agent slot scope
lawrencecchen Jul 19, 2026
cd3aaad
test: retry budget-limited legacy providers
lawrencecchen Jul 19, 2026
bf76625
Make global agent list ordering exact and bounded
lawrencecchen Jul 19, 2026
66aed98
test: exercise corrupt canonical agent slot
lawrencecchen Jul 19, 2026
c099c0f
fix: bound hibernation legacy refresh reads
lawrencecchen Jul 19, 2026
abd0627
test: reject one-shot native agent aliases
lawrencecchen Jul 19, 2026
48eed33
Classify custom aliases by native agent process
lawrencecchen Jul 19, 2026
eb98898
test: require runnable agent script interpreters
lawrencecchen Jul 19, 2026
61d784e
test: cover current agent replay contract drift
lawrencecchen Jul 19, 2026
6a08e20
Fix agent restore command documentation
lawrencecchen Jul 19, 2026
a49ed4f
fix: reject non-replayable current agent modes
lawrencecchen Jul 19, 2026
3e91884
test: cover script runtime availability edges
lawrencecchen Jul 19, 2026
b102426
fix: validate agent script runtimes
lawrencecchen Jul 19, 2026
d07e506
Merge remote-tracking branch 'origin/main' into issue-7867-agent-sess…
lawrencecchen Jul 19, 2026
26eacf2
test: replace lifecycle timing waits with signals
lawrencecchen Jul 19, 2026
2bf5e78
style: simplify session payload lifetime
lawrencecchen Jul 19, 2026
3fbae5b
fix: isolate terminal state delivery capture
lawrencecchen Jul 19, 2026
0022943
test: align lifecycle fixtures with CI
lawrencecchen Jul 19, 2026
8242e12
fix: migrate legacy sessions on first stop
lawrencecchen Jul 19, 2026
8eabffe
Merge remote-tracking branch 'origin/main' into issue-7867-agent-sess…
lawrencecchen Jul 19, 2026
46c8d4d
test: cover agent detection review regressions
lawrencecchen Jul 19, 2026
15d027e
fix: address agent detection review gaps
lawrencecchen Jul 19, 2026
1207d50
test: cover terminal profile ancestry aliases
lawrencecchen Jul 19, 2026
c665991
fix: align ancestry agent aliases
lawrencecchen Jul 19, 2026
b38c5df
fix: preserve stop-only notifications
lawrencecchen Jul 19, 2026
1498a1e
test: reject direct input to suspended terminals
lawrencecchen Jul 19, 2026
6bf8e6e
fix: reject stranded hibernated input
lawrencecchen Jul 19, 2026
83631c4
test: cover final agent CLI review gaps
lawrencecchen Jul 19, 2026
abb97fe
fix: close final agent CLI review gaps
lawrencecchen Jul 19, 2026
8518e2b
test: load hooks localization from app bundle
lawrencecchen Jul 19, 2026
abdb160
Merge remote-tracking branch 'origin/main' into issue-7867-agent-sess…
lawrencecchen Jul 19, 2026
ed9be2a
fix: isolate agent runtime from app-host fixtures
lawrencecchen Jul 19, 2026
53c5721
fix: bound app-host agent test concurrency
lawrencecchen Jul 19, 2026
7ee7289
fix: authenticate hook process fixtures
lawrencecchen Jul 19, 2026
cedcf71
Merge remote-tracking branch 'origin/main' into issue-7867-agent-sess…
lawrencecchen Jul 19, 2026
7d6a7c0
fix: isolate runtime identity from app-host tests
lawrencecchen Jul 19, 2026
6669ab3
fix: handle mock socket clients concurrently
lawrencecchen Jul 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions CLI/AgentActivitySnapshot.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import Foundation

/// Query-friendly aggregate over active workloads without hiding workload detail.
struct AgentActivitySnapshot: Codable, Sendable, Equatable {
struct Counts: Codable, Sendable, Equatable {
var foreground = 0
var backgroundTerminal = 0
var monitor = 0
var scheduled = 0
var subagent = 0
var tool = 0
var other = 0

enum CodingKeys: String, CodingKey {
case foreground
case backgroundTerminal = "background_terminal"
case monitor
case scheduled
case subagent
case tool
case other
}

var total: Int {
foreground + backgroundTerminal + monitor + scheduled + subagent + tool + other
}
}

var state: AgentActivityState
var busy: Bool
var modes: [AgentActivityMode]
var counts: Counts
}
117 changes: 117 additions & 0 deletions CLI/AgentCmuxRuntimeIdentity.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import Foundation

/// Identifies one running cmux app process without consulting a socket or the
/// process table. Every terminal spawned by that process inherits this value.
struct AgentCmuxRuntimeIdentity: Codable, Sendable, Equatable {
var id: String
var socketPath: String?
var bundleIdentifier: String?
var processId: Int?
var processStartSeconds: Int64?
var processStartMicroseconds: Int64?

init?(environment: [String: String]) {
guard let id = Self.normalized(environment["CMUX_RUNTIME_ID"]) else { return nil }
self.id = id
socketPath = Self.normalized(environment["CMUX_SOCKET_PATH"])
?? Self.normalized(environment["CMUX_SOCKET"])
bundleIdentifier = Self.normalized(environment["CMUX_BUNDLE_ID"])
processId = nil
processStartSeconds = nil
processStartMicroseconds = nil
}

init(
id: String,
socketPath: String?,
bundleIdentifier: String?,
processId: Int? = nil,
processStartSeconds: Int64? = nil,
processStartMicroseconds: Int64? = nil
) {
self.id = id
self.socketPath = socketPath
self.bundleIdentifier = bundleIdentifier
self.processId = processId
self.processStartSeconds = processStartSeconds
self.processStartMicroseconds = processStartMicroseconds
}

/// The connected app owns runtime identity. Hook providers may sanitize
/// inherited environment variables, and a surviving process can retain a
/// stale value across an app restart, so socket evidence wins whenever the
/// server advertises it. Older servers fall back to the terminal environment.
static func resolve(
environment: [String: String],
socketCapabilities: [String: Any]
) -> AgentCmuxRuntimeIdentity? {
if let id = normalized(socketCapabilities["runtime_id"] as? String) {
return AgentCmuxRuntimeIdentity(
id: id,
socketPath: normalized(socketCapabilities["socket_path"] as? String),
bundleIdentifier: normalized(socketCapabilities["bundle_identifier"] as? String)
)
}
return AgentCmuxRuntimeIdentity(environment: environment)
}

func applying(to environment: [String: String]) -> [String: String] {
var result = environment
result["CMUX_RUNTIME_ID"] = id
if let socketPath { result["CMUX_SOCKET_PATH"] = socketPath }
if let bundleIdentifier { result["CMUX_BUNDLE_ID"] = bundleIdentifier }
return result
}

private static func normalized(_ value: String?) -> String? {
guard let value = value?.trimmingCharacters(in: .whitespacesAndNewlines),
!value.isEmpty else { return nil }
return value
}
}

/// Chooses current-runtime output without socket I/O. `--all` remains the
/// explicit history view, while shells from older cmux versions retain the
/// legacy evidence filter because they do not carry `CMUX_RUNTIME_ID`.
enum AgentSessionQueryScope: Sendable, Equatable {
case history
case currentRuntime(String)
case legacyUnscoped

init(includeHistory: Bool, environment: [String: String]) {
if includeHistory {
self = .history
} else if let runtime = AgentCmuxRuntimeIdentity(environment: environment) {
self = .currentRuntime(runtime.id)
} else {
self = .legacyUnscoped
}
}

func includes(
recordRuntime: AgentCmuxRuntimeIdentity?,
runRuntime: AgentCmuxRuntimeIdentity?,
legacyVisible: Bool
) -> Bool {
switch self {
case .history:
return true
case let .currentRuntime(runtimeId):
return (runRuntime ?? recordRuntime)?.id == runtimeId
case .legacyUnscoped:
return legacyVisible
}
}

/// The default view is an operational inventory, not a history log. Keep
/// hibernated and restoring sessions visible because cmux still owns their
/// lifecycle, while completed runs remain available through `--all`.
func includes(projection: AgentSessionStateProjection) -> Bool {
switch self {
case .history:
return true
case .currentRuntime, .legacyUnscoped:
return projection.effective != .ended
}
}
}
24 changes: 24 additions & 0 deletions CLI/AgentHookSessionLineage.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import CMUXAgentLaunch
import Foundation

/// The bounded process-lineage result attached to one hook event.
struct AgentHookSessionLineage: Sendable, Equatable {
var runId: String
var pid: Int?
var processStartedAt: TimeInterval?
/// The PID currently resolves to this hook provider's executable, including
/// an allowlisted interpreter entrypoint. Stop events use this with the
/// process start time so PID reuse cannot manufacture a new root run.
var processDescribesAgent: Bool = false
/// Whether the live provider argv is expected to exit after its turn.
/// Replay safety is a separate axis and never controls Stop completion.
var processLaunchMode: AgentProcessLaunchMode = .unknown
/// Exact app-issued claim inherited by a hibernated resume process.
var hibernationResumeAttemptId: UUID? = nil
var cmuxRuntime: AgentCmuxRuntimeIdentity? = nil
var parentRunId: String?
var parentSessionId: String?
var relationship: AgentSessionRelationship?
var restoreAuthority: Bool
var authorityEvidence: AgentSessionAuthorityEvidence? = nil
}
Loading
Loading