Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 16 additions & 11 deletions crates/pi-shell/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ mod platform {
self.children_observed().unwrap_or_default()
}

/// `None` when this process is live but its `/proc` task list could not be
/// read, i.e. the child set is unknown rather than empty.
/// `None` when this process is live but its `/proc` task list could not
/// be read, i.e. the child set is unknown rather than empty.
pub fn children_observed(&self) -> Option<Vec<Self>> {
// The pidfd-backed status is authoritative and errs toward `Running`, so
// `Exited` is real evidence the process is gone and genuinely has no
Expand All @@ -91,7 +91,11 @@ mod platform {
// failure. `live_identity()` must not be used here: it also reports
// false for an unreadable start time, which is exactly the
// failure-as-empty hole this function exists to close.
return if self.status() == ProcessStatus::Exited { Some(Vec::new()) } else { None };
return if self.status() == ProcessStatus::Exited {
Some(Vec::new())
} else {
None
};
};

let mut seen: HashSet<i32> = HashSet::new();
Expand All @@ -103,9 +107,7 @@ mod platform {
return None;
};
let name = entry.file_name();
let Some(tid_str) = name.to_str() else {
return None;
};
let tid_str = name.to_str()?;
if tid_str.parse::<i32>().is_err() {
// Non-numeric entries are not tasks; skipping them loses nothing.
continue;
Expand Down Expand Up @@ -249,7 +251,8 @@ mod platform {
self.descendants_into(&mut out, &mut visited).then_some(out)
}

/// Returns `false` when a `/proc` read failed, making the walk incomplete.
/// Returns `false` when a `/proc` read failed, making the walk
/// incomplete.
fn descendants_into(&self, out: &mut Vec<Self>, visited: &mut HashSet<i32>) -> bool {
let Some(children) = self.children_observed() else {
return false;
Expand Down Expand Up @@ -488,8 +491,9 @@ mod platform {
self.descendants_observed().unwrap_or_default()
}

/// `None` when the process table could not be observed at all. Callers that
/// terminate descendants MUST NOT treat that as an empty descendant set.
/// `None` when the process table could not be observed at all. Callers
/// that terminate descendants MUST NOT treat that as an empty
/// descendant set.
pub fn descendants_observed(&self) -> Option<Vec<Self>> {
// One process-table snapshot per walk — building it inside the recursion
// would re-scan every pid for every visited node, producing an `O(N · D)`
Expand Down Expand Up @@ -997,8 +1001,9 @@ mod platform {
self.descendants_observed().unwrap_or_default()
}

/// `None` when the Toolhelp snapshot could not be taken at all. Callers that
/// terminate descendants MUST NOT treat that as an empty descendant set.
/// `None` when the Toolhelp snapshot could not be taken at all. Callers
/// that terminate descendants MUST NOT treat that as an empty
/// descendant set.
pub fn descendants_observed(&self) -> Option<Vec<Self>> {
let tree = build_process_tree()?;
let Ok(root) = u32::try_from(self.pid) else {
Expand Down
4 changes: 3 additions & 1 deletion packages/coding-agent/src/sdk/bus/chat-daemon-control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ export type ChatDaemonAction = "stop" | "reload";
* through shared notification parsing. Generation 17 bound managed-session
* replacement to exact native filesystem authority; generation 18 retired that
* binding, and generation 19 binds exact cleanup to parent/link-count authority.
* Discord generation 21 applies rustfmt and clippy-equivalent cleanup to the
* pi-shell process-tree authority (#3682).
*/
export const CHAT_DAEMON_GENERATIONS: Readonly<Record<ChatDaemonKind, number>> = {
discord: 20,
discord: 21,
slack: 20,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ export const NOTIFICATION_PROTOCOL_VERSION = 3;
* managed-session replacement to exact native filesystem authority; generation
* 37 retires that binding (revert of #3489, which stalled POSIX artifact
* cleanup); generation 38 binds exact cleanup to parent and link-count authority.
* Generation 39 applies rustfmt and clippy-equivalent cleanup to the pi-shell
* process-tree authority (#3682).
*/
export const DAEMON_GENERATION = 38;
export const DAEMON_GENERATION = 39;

/**
* Serving-compatibility boundary for daemon lifecycle requests. Epoch 1 covers
Expand Down
10 changes: 6 additions & 4 deletions packages/coding-agent/test/notifications-telegram-daemon.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2911,13 +2911,15 @@ describe("telegram daemon", () => {
}),
);
}
test("keeps wire protocol 3 through generation 38 cleanup authority binding", () => {
test("keeps wire protocol 3 through generation 39 pi-shell authority cleanup", () => {
expect(NOTIFICATION_PROTOCOL_VERSION).toBe(3);
// Generations 34 and 35 add media conversion and topic adoption; generation
// 36 bound managed-session replacement to exact native filesystem authority,
// generation 37 retired that binding, and generation 38 binds exact cleanup
// to parent and link-count authority without changing the wire protocol.
expect(DAEMON_GENERATION).toBe(38);
// generation 37 retired that binding, generation 38 binds exact cleanup
// to parent and link-count authority, and generation 39 applies rustfmt and
// clippy-equivalent cleanup to the pi-shell process-tree authority — none
// change the wire protocol.
expect(DAEMON_GENERATION).toBe(39);
});
test.each([
"1",
Expand Down
6 changes: 3 additions & 3 deletions scripts/telegram-daemon-generation-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@
"discord:packages/coding-agent/src/sdk/bus/chat-daemon-cli.ts:loadConfig": "8fd40d586b1f3f60cfd2285844e08cc3f5235bf83672d268bd698512ec31edd6",
"discord:packages/coding-agent/src/sdk/bus/chat-daemon-cli.ts:ownerPid": "31110dcdd6e0f5dbc8b4dce27383646b9c339739758623ab67dc40ddc36661e0",
"discord:packages/coding-agent/src/sdk/bus/chat-daemon-cli.ts:runChatDaemonInternal": "74c0a7c475325313453a4295479fd4cb2fcb3af6137426b8262b768d5bc276d0",
"discord:packages/coding-agent/src/sdk/bus/chat-daemon-control.ts:CHAT_DAEMON_GENERATIONS.discord": "2e6a4635f0d1eb524dd875190faaa8bad40790f7d77a48d1f9e37d5a9ed63279",
"discord:packages/coding-agent/src/sdk/bus/chat-daemon-control.ts:CHAT_DAEMON_GENERATIONS.discord": "225ac1d15ea68ee7a4125fee1ce6db61386070b2477bbe76af7fc8664ab3133c",
"discord:packages/coding-agent/src/sdk/bus/chat-daemon-control.ts:ChatDaemonAction": "d8acaf90439e410595b5cd56fd187001393ea943517a5563a4a2ea3c88d155ef",
"discord:packages/coding-agent/src/sdk/bus/chat-daemon-control.ts:ChatDaemonController": "476aad2ea908df7fb0cb72be8cea82007b245cd8228d2c7846fd31b3b6d1fb99",
"discord:packages/coding-agent/src/sdk/bus/chat-daemon-control.ts:ChatDaemonKind": "b1c2906c4eb04e120c9ce42f8b549a68cfc834d29d4d745335712a7f61bf09f2",
Expand Down Expand Up @@ -474,7 +474,7 @@
"telegram:packages/coding-agent/src/sdk/bus/telegram-daemon-cli.ts:ownerPidFromOwnerId": "46691373b2bee01f28f3817a6aa6a7efffe880c2cea337c89155582c98d952bf",
"telegram:packages/coding-agent/src/sdk/bus/telegram-daemon-cli.ts:runDaemonInternal": "7689b6c98f5d0a658b3aa921e384c549355aba7eb672c2ebf4014171da01ba5c",
"telegram:packages/coding-agent/src/sdk/bus/telegram-daemon-cli.ts:runDaemonSmoke": "6f085a667aa5c83de46d2d8945fb845c355fcbb43c46872342a44489203a5830",
"telegram:packages/coding-agent/src/sdk/bus/telegram-daemon-contract.ts:DAEMON_GENERATION": "02634937df51a7dd1d5542d1210c937da8b21bab3d764d53eab3b6264717cf47",
"telegram:packages/coding-agent/src/sdk/bus/telegram-daemon-contract.ts:DAEMON_GENERATION": "adc41640c635b42476409aa17f70439e7cad825ed050007d67c92ed3117fa792",
"telegram:packages/coding-agent/src/sdk/bus/telegram-daemon-contract.ts:NOTIFICATION_PROTOCOL_VERSION": "b99289f651fedcf020d28dbaf6f07dd37e7e4a5f6dc1f5118b872112325f1e81",
"telegram:packages/coding-agent/src/sdk/bus/telegram-daemon-control.ts:DaemonProcessReference": "c3d13e3670a6245a1250c4ebfcd80a36dd8fc96c67ab64d9f979182bd117bc4e",
"telegram:packages/coding-agent/src/sdk/bus/telegram-daemon-control.ts:TelegramDaemonController": "d92bf5e0aea850d62c415092a8d9024d3d3571e0f2b8855d7e3fb418ec59a59c",
Expand Down Expand Up @@ -555,7 +555,7 @@
"nativeAuthoritySha256": {
"crates/pi-natives/src/path_identity.rs": "90a5ac813f53dee0f9a81002f5971594c07f8a9bdf8d5f262737be1d8203aae1",
"crates/pi-natives/src/ps.rs": "7696078e123b9beecc7252371c71eab2cec590413be6e6ddf4692ff6fe8c41e1",
"crates/pi-shell/src/process.rs": "8647fbf7c3200be3359bf3d82ba39e56ca24d14bd294662026d373c438517952",
"crates/pi-shell/src/process.rs": "45b222432a70eb056807507f8b4d28cf5fb73a7441ee9a0e28349ec85ef9b177",
"crates/pi-shell/src/shell.rs": "66cacfe63d495b23156d023f2f34f354b657534ee3cdaf01e30d6694af253982",
"crates/brush-core-vendored/src/commands.rs": "55e9dceffad7d829051547e91592ca8e392a9073e2d4ee2f7546e3b6c1b75a9d",
"packages/natives/native/index.d.ts": "c61e02fd4712c822d30fb4b1496f064097a38718c9443bef526711f828165c50",
Expand Down
Loading