@vincemakes/kiso-runtime 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -91,6 +91,15 @@ export class LockUnavailableError extends Error {
91
91
  * pre-amendment behavior — alive, the fail-safe refusal (prefer a false
92
92
  * refusal over a double-write). Live-process semantics and the PID-reuse
93
93
  * rules do not move: a live foreign writer is still refused.
94
+ *
95
+ * ADR-0050 Amendment 2 (Finding R-I-p-3): the state letters are matched
96
+ * ANYWHERE in the state string, not as the first character. The
97
+ * exit-path linger's ps output is "?E" — the first character is the
98
+ * no-controlling-terminal marker "?", with the E sitting AFTER it — so
99
+ * first-character matching judged the finding's own documented shape
100
+ * alive. The ps state alphabet (macOS + Linux) has no flag letters
101
+ * "E"/"Z": an occurrence anywhere is the process-state code, and the
102
+ * holder is dead.
94
103
  */
95
104
  function isAlive(pid) {
96
105
  try {
@@ -100,12 +109,16 @@ function isAlive(pid) {
100
109
  return err.code === "EPERM";
101
110
  }
102
111
  const state = processState(pid);
103
- return state !== "E" && state !== "Z";
112
+ // A null state (probe failure) keeps the pre-amendment behavior —
113
+ // judged alive, the fail-safe refusal.
114
+ return state === null || (!state.includes("E") && !state.includes("Z"));
104
115
  }
105
116
  /**
106
- * The process state via `ps -o state= -p <pid>` (macOS/Linux). The
107
- * state is the FIRST character (a multi-char string like "Ss+" is a
108
- * combined flag set). An empty or unreadable state the process
117
+ * The process state via `ps -o state= -p <pid>` (macOS/Linux) — the
118
+ * whole state string (a multi-char string like "Ss+" or "?E" is a
119
+ * combined flag set; the E/Z process-state codes may sit after the "?"
120
+ * no-tty marker or other flag letters, so the matching in isAlive scans
121
+ * the whole string). An empty or unreadable state — the process
109
122
  * vanished between the kill and the probe, or ps itself failed —
110
123
  * returns null; isAlive's fail-safe branch then judges the holder alive
111
124
  * (the pre-amendment behavior).
@@ -113,7 +126,7 @@ function isAlive(pid) {
113
126
  function processState(pid) {
114
127
  try {
115
128
  const state = execFileSync("ps", ["-o", "state=", "-p", String(pid)], { encoding: "utf8" }).trim();
116
- return state.length > 0 ? (state[0] ?? null) : null;
129
+ return state.length > 0 ? state : null;
117
130
  }
118
131
  catch {
119
132
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vincemakes/kiso-runtime",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "kiso runtime — durable multi-turn agent sessions: AgentDefinition, AgentRuntime, AgentSession, Run, append-only JSONL store.",
5
5
  "type": "module",
6
6
  "license": "MIT",