pi-harness-runtime 1.1.502 → 1.1.503

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.
Files changed (55) hide show
  1. package/CHANGELOG.md +79 -0
  2. package/harness/jev-request-scope.ts +170 -16
  3. package/index.ts +57 -2
  4. package/package.json +1 -1
  5. package/packages/agent-policy/package.json +1 -1
  6. package/packages/auth/package.json +1 -1
  7. package/packages/autonomous-runtime/package.json +1 -1
  8. package/packages/checkpoint/package.json +1 -1
  9. package/packages/clipboard/package.json +1 -1
  10. package/packages/codex-watcher/package.json +1 -1
  11. package/packages/config-capture/package.json +1 -1
  12. package/packages/contracts/package.json +1 -1
  13. package/packages/cookie-sanitizer/package.json +1 -1
  14. package/packages/evaluation-engine/package.json +1 -1
  15. package/packages/event-bus/package.json +1 -1
  16. package/packages/event-store/package.json +1 -1
  17. package/packages/experience-replay/package.json +1 -1
  18. package/packages/file-copy-helper/package.json +1 -1
  19. package/packages/intent-analyzer/package.json +1 -1
  20. package/packages/jev-judge/dist/continuation-controller.d.ts +10 -1
  21. package/packages/jev-judge/dist/continuation-controller.d.ts.map +1 -1
  22. package/packages/jev-judge/dist/continuation-controller.js +11 -0
  23. package/packages/jev-judge/dist/continuation-controller.js.map +1 -1
  24. package/packages/jev-judge/dist/todo-provider.d.ts +25 -0
  25. package/packages/jev-judge/dist/todo-provider.d.ts.map +1 -1
  26. package/packages/jev-judge/dist/todo-provider.js +56 -0
  27. package/packages/jev-judge/dist/todo-provider.js.map +1 -1
  28. package/packages/jev-judge/package.json +1 -1
  29. package/packages/jev-judge/src/continuation-controller.ts +13 -1
  30. package/packages/jev-judge/src/todo-provider.ts +83 -0
  31. package/packages/knowledge-retrieval/package.json +1 -1
  32. package/packages/learning-engine/package.json +1 -1
  33. package/packages/logging/package.json +1 -1
  34. package/packages/memory-engine/package.json +1 -1
  35. package/packages/notification/package.json +1 -1
  36. package/packages/paperclip-integration/package.json +1 -1
  37. package/packages/performance-optimizer/package.json +1 -1
  38. package/packages/privilege-broker/package.json +1 -1
  39. package/packages/prompt-compiler/package.json +1 -1
  40. package/packages/providers/package.json +1 -1
  41. package/packages/qdrant-skills/package.json +1 -1
  42. package/packages/quota-manager/package.json +1 -1
  43. package/packages/relay/package.json +1 -1
  44. package/packages/skill-mcp-client/package.json +1 -1
  45. package/packages/skills/package.json +1 -1
  46. package/packages/todo-bd-sync/package.json +1 -1
  47. package/packages/token-estimation/package.json +1 -1
  48. package/packages/tooling-preference/package.json +1 -1
  49. package/packages/trajectory/package.json +1 -1
  50. package/packages/tui/package.json +1 -1
  51. package/packages/two-phase-review/package.json +1 -1
  52. package/packages/types/package.json +1 -1
  53. package/packages/webmcp-tester/package.json +1 -1
  54. package/packages/wiki/package.json +1 -1
  55. package/packages/write-review/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,85 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.1.503](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v1.1.448...v1.1.503) (2026-11-10)
6
+
7
+
8
+ ### Features
9
+
10
+ * **actions:** register the job resume, the GLM countdown and the queued continuations ([177c964](https://github.com/ManotLuijiu/pi-harness-runtime/commit/177c964555b0057e6bc7d293dafab10c95eabbf9))
11
+ * **delegation:** a child is only a child when it really ran ([ac4e678](https://github.com/ManotLuijiu/pi-harness-runtime/commit/ac4e6782d7d4bc4941e458425c8a9f38a51fc9d4))
12
+ * **delegation:** the scope of a request is measured before it is judged ([684b6a5](https://github.com/ManotLuijiu/pi-harness-runtime/commit/684b6a55184f63d3be24c48dcecfb0b13410dc15))
13
+ * **honcho:** the memory service speaks the native MCP of Pi ([f9f740c](https://github.com/ManotLuijiu/pi-harness-runtime/commit/f9f740c12869bae4c4380afbe8c76e12388bb744))
14
+ * **jev:** one decision per question, bound to the question it was evaluated for ([03448aa](https://github.com/ManotLuijiu/pi-harness-runtime/commit/03448aaa17f2d0c3bcf644b0b1d5949727dfff8c))
15
+ * **jev:** the evaluation of a choice sees what the options mean ([f0c207e](https://github.com/ManotLuijiu/pi-harness-runtime/commit/f0c207e074701e6b7dab0965170ec39453d9d502))
16
+ * **jev:** the pending question carries the ask and the answer ([a792133](https://github.com/ManotLuijiu/pi-harness-runtime/commit/a792133e517fb8c12d3363e98942f3af30270f27))
17
+ * **jev:** the pending question counts down to the decision ([d0cc171](https://github.com/ManotLuijiu/pi-harness-runtime/commit/d0cc171223986b2d32c670b6c1c74712fe0a4ad8))
18
+ * **keys:** tell the user what to do about an exposed key file ([7031003](https://github.com/ManotLuijiu/pi-harness-runtime/commit/7031003574307351b7a8f28ee14159b58e17b793))
19
+ * **keys:** the key files are repaired when their permissions are unsafe ([e9c2c26](https://github.com/ManotLuijiu/pi-harness-runtime/commit/e9c2c26b287665b56ed749de269737e8403bb8af))
20
+ * **mcp:** the harness connects the registered servers when nobody else does ([7fef951](https://github.com/ManotLuijiu/pi-harness-runtime/commit/7fef95137ad4664df57f045cd91b7d233315b0bc))
21
+ * **merge:** a manual run can leave the merge to the pull request event ([b3d1950](https://github.com/ManotLuijiu/pi-harness-runtime/commit/b3d1950b5941c78ccd56951acdafd1d4afbe1bff))
22
+ * **phase:** the agent owns the todo list and the harness says so ([c489370](https://github.com/ManotLuijiu/pi-harness-runtime/commit/c489370bd7926aece8cb1a77aa20ca2d2672f1fb))
23
+ * **providers:** a shared registry of the pending automatic actions and a bounded recovery ([c5f955b](https://github.com/ManotLuijiu/pi-harness-runtime/commit/c5f955bc82adcb6999a89d5bc278fa87fccee022))
24
+ * **providers:** one failure has one executor, and the retry bridge is checked ([e73c4c7](https://github.com/ManotLuijiu/pi-harness-runtime/commit/e73c4c76ff20a9708083659bdcefe74870a84837))
25
+ * **review:** the review starts on its own when the implementation is done ([04f51f5](https://github.com/ManotLuijiu/pi-harness-runtime/commit/04f51f599cd3222b6c74dd8fadb1373bd72d9bd7))
26
+ * **status:** the status line names the phase, the progress and the children ([0167bf3](https://github.com/ManotLuijiu/pi-harness-runtime/commit/0167bf396a0b987c1d44f3b869351976a951dd65))
27
+ * **test:** the task waits for the final tier of the validation plan ([fa147db](https://github.com/ManotLuijiu/pi-harness-runtime/commit/fa147dbf7d50d56e6ea48c6d8fbb4fcb190caf8a))
28
+ * **validation:** a large job starts with a measured pilot ([425964b](https://github.com/ManotLuijiu/pi-harness-runtime/commit/425964b04a3d4fa02adfabed47ff62c5ec2b9c28))
29
+ * **validation:** the size of a job is a fact, not a phrase ([8aa6c11](https://github.com/ManotLuijiu/pi-harness-runtime/commit/8aa6c119565d0f8412dc8aeafa6b295d47d3f093))
30
+ * **workspace:** a Frappe bench names the mode of the workspace ([9d58517](https://github.com/ManotLuijiu/pi-harness-runtime/commit/9d585172063a330992fee933316e268ae9985e3c))
31
+
32
+
33
+ ### Bug Fixes
34
+
35
+ * **ci:** every run of a required check counts, and the worst one decides ([da9e0da](https://github.com/ManotLuijiu/pi-harness-runtime/commit/da9e0da6b0ca29cb320764fd5fc1b8a8dee8b1e0))
36
+ * **ci:** the newest attempt of a run decides, not the attempt that failed ([9d7adcc](https://github.com/ManotLuijiu/pi-harness-runtime/commit/9d7adcc31cbacc517c3c1a9bcd3956be94c908ef))
37
+ * **harness:** a raw control byte hid the request scope from the review ([852b1ff](https://github.com/ManotLuijiu/pi-harness-runtime/commit/852b1ff3afc21adb71e92b85d21ff1c88e14816a))
38
+ * **honcho:** a handshake that never finishes is named instead of hanging the startup ([d66005f](https://github.com/ManotLuijiu/pi-harness-runtime/commit/d66005f928a4f8df5de5b8a0579cbd4f8df37ff9))
39
+ * **honcho:** a probe that the end of the session cuts off is not a failure ([493fd93](https://github.com/ManotLuijiu/pi-harness-runtime/commit/493fd938ba09fdcf57bed4aaf259d81c4040909e))
40
+ * **honcho:** a slow connector is not a failed one, the row is corrected when the tools appear ([b62ac5b](https://github.com/ManotLuijiu/pi-harness-runtime/commit/b62ac5b16ad93e2bfb10cbec589b80a09b7e20b3))
41
+ * **honcho:** a tools listing that the end of the session cuts off is not a failure ([62cc8c3](https://github.com/ManotLuijiu/pi-harness-runtime/commit/62cc8c376aade01c953ce2a1c6501ed07b74a1e9))
42
+ * **honcho:** the report names the state of the MCP server, not the registration ([762f4d5](https://github.com/ManotLuijiu/pi-harness-runtime/commit/762f4d59e4eabcab9a1c21a61aa522c3267621b3))
43
+ * **hooks:** a tag is checked through the commit behind it ([c823e8e](https://github.com/ManotLuijiu/pi-harness-runtime/commit/c823e8e1f6973c62b5449a97c101759a4d5cbba5))
44
+ * **jev:** a completion question, a stale check and a pending validation ([827120b](https://github.com/ManotLuijiu/pi-harness-runtime/commit/827120b4138b6f5ae253e69154de190085703de8))
45
+ * **jev:** a new request does not inherit the completion of the old one ([0f863c7](https://github.com/ManotLuijiu/pi-harness-runtime/commit/0f863c7fcaf35e261beabebef15b8ab634132fdc))
46
+ * **jev:** a prohibition must not hide a destructive action ([78a6cc1](https://github.com/ManotLuijiu/pi-harness-runtime/commit/78a6cc199e647f812e145483f7e94991358d8f34))
47
+ * **jev:** a refusal without punctuation, and only a decline of an action ([ef3dbf8](https://github.com/ManotLuijiu/pi-harness-runtime/commit/ef3dbf87a2a1725373281613a0d48881ed5d2239))
48
+ * **jev:** a rejection during the countdown pauses the work ([9b018ce](https://github.com/ManotLuijiu/pi-harness-runtime/commit/9b018ce1152b6724dee73cdc901b8a360ecc91ab))
49
+ * **jev:** a session switch ends the wait of the old session ([ca03d39](https://github.com/ManotLuijiu/pi-harness-runtime/commit/ca03d399c0d4a1b2dd428ac39836ab53c0e51ab6))
50
+ * **jev:** an open question is not a permission to answer it ([e20eca2](https://github.com/ManotLuijiu/pi-harness-runtime/commit/e20eca24bb88d385198bb12ee3ebf573af9aea86))
51
+ * **jev:** keep a comparative caveat with the option it constrains ([7be306b](https://github.com/ManotLuijiu/pi-harness-runtime/commit/7be306b0d0872713ebca9386d613ae5a8da9d5b6))
52
+ * **jev:** the action of the question on its own text, and a reply is not an authorization ([7c3fdd6](https://github.com/ManotLuijiu/pi-harness-runtime/commit/7c3fdd6822b58bd6ccfa3bcdf1c5282cb3db52dd))
53
+ * **jev:** the action of the question, and an open question blocks the work ([1f9ff39](https://github.com/ManotLuijiu/pi-harness-runtime/commit/1f9ff39efc4ee17464c54c2ca9b583245093dbac))
54
+ * **jev:** the alternatives of a question are parsed without a quadratic pattern ([63016a3](https://github.com/ManotLuijiu/pi-harness-runtime/commit/63016a3f0488acb801990dd46770c00d382b5858))
55
+ * **jev:** the countdown of an obsolete question does not outlive the work ([fe78b29](https://github.com/ManotLuijiu/pi-harness-runtime/commit/fe78b29e6fc513b11a6993bc68fd9418dc77f79b))
56
+ * **jev:** the facts of an option survive the wording of the agent ([5a6250c](https://github.com/ManotLuijiu/pi-harness-runtime/commit/5a6250c07aa8d965bc6ae242cccbf519477598f8))
57
+ * **jev:** the scope decides the question, the identity guards the awaits ([ed348b2](https://github.com/ManotLuijiu/pi-harness-runtime/commit/ed348b2f94460a3b3ac11c01afd4420ee4ec1020))
58
+ * **jev:** the scope of a request on every human path, and the todos it touched ([cec8f36](https://github.com/ManotLuijiu/pi-harness-runtime/commit/cec8f3644333b1d13a203340df80a30fef5c1ac0))
59
+ * **jev:** the subject of the scope decides, a clarification is preserved ([faf6a0f](https://github.com/ManotLuijiu/pi-harness-runtime/commit/faf6a0fe7d0dce94d4fa48d0d7a57d126556ba6d))
60
+ * **keys:** the key directory is audited as a tree ([081cc75](https://github.com/ManotLuijiu/pi-harness-runtime/commit/081cc75ac8ceff36b0d619c3f76371dc08459d3c))
61
+ * **logging:** the sanitizer of a message writes its control characters as escapes ([f4bbdb9](https://github.com/ManotLuijiu/pi-harness-runtime/commit/f4bbdb94bc1801d4228142bc1a1b31505c42a575))
62
+ * **mcp:** the connector and the watcher stop with the session ([4d1b87d](https://github.com/ManotLuijiu/pi-harness-runtime/commit/4d1b87d14d015749025b62bf54d6d0b6137295f7))
63
+ * **mcp:** the connector survives a runtime that cannot list the servers ([d0f555f](https://github.com/ManotLuijiu/pi-harness-runtime/commit/d0f555fa14f51de33591e572a41ded5b59a3e4dd))
64
+ * **merge:** the boolean input is read as a boolean ([971b716](https://github.com/ManotLuijiu/pi-harness-runtime/commit/971b7169a43db382dbdeb6bb9bab02ab56e0351c))
65
+ * **merge:** the manual job needs the right of the merge ([7ba685e](https://github.com/ManotLuijiu/pi-harness-runtime/commit/7ba685ec43d815f90aa35b742579e87e76c69209))
66
+ * **merge:** the merge of the pull request is the GraphQL mutation ([972bab4](https://github.com/ManotLuijiu/pi-harness-runtime/commit/972bab4b0f7faf1b0047f3bb767ef6db3de4b2fa))
67
+ * **merge:** the workflow merges the pull request the gates cleared ([d7639ec](https://github.com/ManotLuijiu/pi-harness-runtime/commit/d7639ec9b83723510acb4a5c4e23d5d6167c3af6))
68
+ * **providers:** the escape of the user stops the recovery, and a permanent failure clears it ([cfe5797](https://github.com/ManotLuijiu/pi-harness-runtime/commit/cfe57976bf463c327e45b874fd297c3e942246b8))
69
+ * **providers:** the pause wins over a retry, and the retry starts when the run settles ([e016dd2](https://github.com/ManotLuijiu/pi-harness-runtime/commit/e016dd2a5add5b0f3c848a225a28a59e0f5fc7f3))
70
+ * **recovery:** a cancelled countdown does not own the next attempt ([7b79f30](https://github.com/ManotLuijiu/pi-harness-runtime/commit/7b79f301389fae48201e696d3086d257ed722fb9))
71
+ * **recovery:** a cancelled retry of Pi is a cancelled decision, a spent budget is not ([7e13f15](https://github.com/ManotLuijiu/pi-harness-runtime/commit/7e13f156a279cded2b2d4b0c99358100b3d5e038))
72
+ * **recovery:** a manual request takes the work back from the countdown ([fa81d8f](https://github.com/ManotLuijiu/pi-harness-runtime/commit/fa81d8fd9d6160166a095e07bdf17049bbafa32d))
73
+ * **recovery:** the predicate of Pi decides the retry, the provider identity is normalized ([6c8c17b](https://github.com/ManotLuijiu/pi-harness-runtime/commit/6c8c17b53302cea1602d192251eacd0ebbd3e8c9))
74
+ * **release:** a manual release keeps the version of its manifest ([122e661](https://github.com/ManotLuijiu/pi-harness-runtime/commit/122e661ea48cb8aff14c71dbd0221a4cf0ba4c8e))
75
+ * **release:** the alignment names the reason of a failure ([5814dd0](https://github.com/ManotLuijiu/pi-harness-runtime/commit/5814dd0b780f5839cf8011ed0cbbbb31e7eb0418))
76
+ * **release:** the channels of the package name the release ([a7a273f](https://github.com/ManotLuijiu/pi-harness-runtime/commit/a7a273ffe8398e2b5b07ef1c321777de41792c6e))
77
+ * **release:** the release publishes and leaves the channels alone ([5871746](https://github.com/ManotLuijiu/pi-harness-runtime/commit/5871746589c1281d855dbeb591b02419fa43f22e))
78
+ * **release:** the release pull request names the version of its branch ([a846e83](https://github.com/ManotLuijiu/pi-harness-runtime/commit/a846e83e6de6e529f4bca05e869db0b5eebb37c5))
79
+ * **release:** the release scans the tree of the commit it publishes ([7d47a0b](https://github.com/ManotLuijiu/pi-harness-runtime/commit/7d47a0b5406480a1e1d3a52623a76aabd1e2d0ba))
80
+ * **workspace:** a strong bench signal decides, and the question is not a fact of an option ([303a828](https://github.com/ManotLuijiu/pi-harness-runtime/commit/303a828f55aa7c4e0a611231f482489b530ff5a3))
81
+ * **workspace:** keep a client name out of the comment about the search depth ([b572e0a](https://github.com/ManotLuijiu/pi-harness-runtime/commit/b572e0af16ff562203bda2b5c47b41807cff5a95))
82
+ * **workspace:** the repository names the mode before the mode stays unknown ([188a32c](https://github.com/ManotLuijiu/pi-harness-runtime/commit/188a32c7a6af1465dd24714278fccc73d06f6477))
83
+
5
84
  ### [1.1.502](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v1.1.448...v1.1.502) (2026-11-10)
6
85
 
7
86
 
@@ -10,6 +10,11 @@
10
10
  * how the list looked when the request started, and it derives from that
11
11
  * memory which todos belong to the request that is running.
12
12
  *
13
+ * The list alone is not enough to tell that: a todo that the request
14
+ * reopened and finished again looks exactly like the todo it was before.
15
+ * The history of the list says what a change touched, so the request keeps
16
+ * the todo it worked on.
17
+ *
13
18
  * Nothing here touches the list: the history stays a record of what
14
19
  * happened, and the scope is only a reading of it.
15
20
  */
@@ -26,6 +31,14 @@ export interface RequestTodoLike {
26
31
  status: string;
27
32
  }
28
33
 
34
+ /**
35
+ * One state of the list in its history.
36
+ */
37
+ export interface TodoHistoryLike {
38
+ /** The list as it was after the change. */
39
+ items: readonly RequestTodoLike[];
40
+ }
41
+
29
42
  /**
30
43
  * The scope of the request that is running.
31
44
  */
@@ -37,6 +50,27 @@ export interface JevRequestScope {
37
50
  * the shape it had then.
38
51
  */
39
52
  readonly baseline: ReadonlyMap<string, string>;
53
+ /**
54
+ * The keys of the todos that the request touched.
55
+ *
56
+ * A todo belongs to the request when the request changed it, also when
57
+ * the change left it in the state it had before.
58
+ */
59
+ readonly touched: ReadonlySet<string>;
60
+ /**
61
+ * The number of states the list had when the request started.
62
+ *
63
+ * The states after this number are the changes of the request.
64
+ */
65
+ readonly historyIndex: number;
66
+ /**
67
+ * Is the number of states known?
68
+ *
69
+ * The history of the list could not be read when the request started:
70
+ * the changes of the request cannot be told from the changes of the
71
+ * earlier requests, so the history is not used at all.
72
+ */
73
+ readonly historyKnown: boolean;
40
74
  }
41
75
 
42
76
  /**
@@ -64,12 +98,70 @@ function itemShape(item: RequestTodoLike): string {
64
98
  return `${item.status}\0${(item.subject ?? "").trim()}`;
65
99
  }
66
100
 
101
+ /**
102
+ * The keys of the items that a change touched.
103
+ *
104
+ * The history is a sequence of states. A change touched an item when the
105
+ * item is new, when its status or its subject changed, and when it is gone.
106
+ * An item that was reopened and finished again is touched twice: the
107
+ * request that did it keeps the item.
108
+ */
109
+ export function touchedKeys(
110
+ history: readonly TodoHistoryLike[] | null | undefined,
111
+ from: number,
112
+ ): Set<string> {
113
+ const touched = new Set<string>();
114
+ if (!history || history.length === 0) return touched;
115
+ // The state before the request is the last one before its first change.
116
+ const start = Math.max(1, from);
117
+ for (let index = start; index < history.length; index += 1) {
118
+ const before = new Map<string, RequestTodoLike>();
119
+ for (const item of history[index - 1]?.items ?? []) {
120
+ const key = itemKey(item);
121
+ if (key !== null) before.set(key, item);
122
+ }
123
+ const after = new Map<string, RequestTodoLike>();
124
+ for (const item of history[index]?.items ?? []) {
125
+ const key = itemKey(item);
126
+ if (key !== null) after.set(key, item);
127
+ }
128
+ for (const [key, item] of after) {
129
+ const previous = before.get(key);
130
+ if (
131
+ !previous ||
132
+ previous.status !== item.status ||
133
+ (previous.subject ?? "").trim() !== (item.subject ?? "").trim()
134
+ ) {
135
+ touched.add(key);
136
+ }
137
+ }
138
+ for (const key of before.keys()) {
139
+ // The item is gone: the change that removed it touched it.
140
+ if (!after.has(key)) touched.add(key);
141
+ }
142
+ }
143
+ return touched;
144
+ }
145
+
67
146
  /**
68
147
  * Remember how the list looked when the request started.
69
148
  */
70
149
  export function captureRequestScope(
71
150
  items: readonly RequestTodoLike[] | null | undefined,
72
151
  generation: number,
152
+ options: {
153
+ /** The keys of the todos that the request touched. */
154
+ touched?: ReadonlySet<string>;
155
+ /** The number of states the list had when the request started. */
156
+ historyIndex?: number;
157
+ /**
158
+ * Is the number of states known?
159
+ *
160
+ * Without it the history is not read: the changes of the request
161
+ * cannot be told from the changes of the earlier requests.
162
+ */
163
+ historyKnown?: boolean;
164
+ } = {},
73
165
  ): JevRequestScope {
74
166
  const baseline = new Map<string, string>();
75
167
  for (const item of items ?? []) {
@@ -77,7 +169,13 @@ export function captureRequestScope(
77
169
  if (key === null) continue;
78
170
  baseline.set(key, itemShape(item));
79
171
  }
80
- return { generation, baseline };
172
+ return {
173
+ generation,
174
+ baseline,
175
+ touched: options.touched ?? new Set<string>(),
176
+ historyIndex: options.historyIndex ?? 0,
177
+ historyKnown: options.historyKnown ?? options.touched !== undefined,
178
+ };
81
179
  }
82
180
 
83
181
  /**
@@ -97,6 +195,9 @@ export function itemsOfRequest(
97
195
  // An item without an id cannot be told apart: it belongs to the
98
196
  // request that is running.
99
197
  if (key === null) return true;
198
+ // The request touched the item, also when the change left it in the
199
+ // state it had before.
200
+ if (scope.touched.has(key)) return true;
100
201
  const before = scope.baseline.get(key);
101
202
  // The item was not there when the request started.
102
203
  if (before === undefined) return true;
@@ -130,14 +231,25 @@ export class RequestScopeTracker {
130
231
  private readonly readTodos: () => Promise<
131
232
  readonly RequestTodoLike[] | null | undefined
132
233
  >;
234
+ /** The read of the history of the task list. */
235
+ private readonly readHistory?: () => Promise<
236
+ readonly TodoHistoryLike[] | null | undefined
237
+ >;
133
238
 
134
239
  constructor(options: {
135
240
  /** Read the task list as it is now. */
136
- readTodos: () => Promise<
137
- readonly RequestTodoLike[] | null | undefined
138
- >;
241
+ readTodos: () => Promise<readonly RequestTodoLike[] | null | undefined>;
242
+ /**
243
+ * Read the history of the task list: the state after every change.
244
+ *
245
+ * Without it the tracker sees the list alone, and a todo that the
246
+ * request reopened and finished again looks like the todo it was
247
+ * before.
248
+ */
249
+ readHistory?: () => Promise<readonly TodoHistoryLike[] | null | undefined>;
139
250
  }) {
140
251
  this.readTodos = options.readTodos;
252
+ this.readHistory = options.readHistory;
141
253
  }
142
254
 
143
255
  /**
@@ -153,7 +265,9 @@ export class RequestScopeTracker {
153
265
  * The list is read now, while the request has not touched it: this is
154
266
  * the work that the request inherits. The read of the list is
155
267
  * asynchronous, so the capture happens when the list arrives: the
156
- * scope is the list of that moment and not of a later one.
268
+ * scope is the list of that moment and not of a later one. The history
269
+ * is read after the list, so the changes of the request are never
270
+ * counted as the changes of an earlier one.
157
271
  *
158
272
  * A message of the harness itself does not begin a request: it is the
159
273
  * harness that continues the work, not the human that asks for it.
@@ -161,19 +275,42 @@ export class RequestScopeTracker {
161
275
  begin(): number {
162
276
  this._generation += 1;
163
277
  const generation = this._generation;
164
- let captured: Promise<JevRequestScope | null>;
165
- try {
166
- captured = Promise.resolve(this.readTodos()).then(
167
- (items) => captureRequestScope(items, generation),
168
- () => null,
169
- );
170
- } catch {
171
- captured = Promise.resolve(null);
172
- }
173
- this._pending = captured;
278
+ this._pending = (async () => {
279
+ let items: readonly RequestTodoLike[] | null | undefined;
280
+ try {
281
+ items = await this.readTodos();
282
+ } catch {
283
+ // The list could not be read: there is no evidence of what
284
+ // the request inherits, so there is no scope.
285
+ return null;
286
+ }
287
+ let history: readonly TodoHistoryLike[] | null = null;
288
+ try {
289
+ history = (await this.readHistory?.()) ?? null;
290
+ } catch {
291
+ history = null;
292
+ }
293
+ return captureRequestScope(items ?? null, generation, {
294
+ historyIndex: history?.length ?? 0,
295
+ historyKnown: history !== null,
296
+ });
297
+ })();
174
298
  return generation;
175
299
  }
176
300
 
301
+ /**
302
+ * The session changed.
303
+ *
304
+ * The scope of the previous session says nothing about the new one: the
305
+ * todos of the previous session are the history of that session. The
306
+ * scope is dropped, and the work of the new session is read without a
307
+ * scope until the human asks for something.
308
+ */
309
+ reset(): void {
310
+ this._generation += 1;
311
+ this._pending = null;
312
+ }
313
+
177
314
  /**
178
315
  * The scope of the request that is running.
179
316
  *
@@ -195,7 +332,24 @@ export class RequestScopeTracker {
195
332
  }
196
333
  const scope = pending ? await pending : null;
197
334
  // A request that started in the meantime owns the work now.
198
- if (pending === this._pending) return { scope, items };
335
+ if (pending !== this._pending) continue;
336
+ let history: readonly TodoHistoryLike[] | null = null;
337
+ try {
338
+ history = (await this.readHistory?.()) ?? null;
339
+ } catch {
340
+ history = null;
341
+ }
342
+ // A request that started while the history was read owns the
343
+ // work now: the scope of the older request is stale.
344
+ if (pending !== this._pending) continue;
345
+ // The history is only read when the number of states was known
346
+ // when the request started: otherwise the changes of the earlier
347
+ // requests would look like the changes of this one.
348
+ const touched =
349
+ scope?.historyKnown === true
350
+ ? touchedKeys(history, scope.historyIndex)
351
+ : new Set<string>();
352
+ return { scope: scope ? { ...scope, touched } : null, items };
199
353
  }
200
354
  return { scope: null, items: null };
201
355
  }
package/index.ts CHANGED
@@ -612,8 +612,44 @@ const requestScopeTracker = new RequestScopeTracker({
612
612
  const snapshot = await controller.getSnapshot();
613
613
  return snapshot?.items ?? null;
614
614
  },
615
+ readHistory: async () => {
616
+ // The history says what a change touched, also when the todo is
617
+ // back in the state it had before: a todo that the request
618
+ // reopened and finished again is work of the request that did it.
619
+ const controller = sharedState.todoContinuationController as {
620
+ getHistory?: () => Promise<
621
+ { items: TodoStateLike[] }[]
622
+ >;
623
+ } | null;
624
+ if (!controller || typeof controller.getHistory !== "function") {
625
+ return null;
626
+ }
627
+ const history = await controller.getHistory();
628
+ return Array.isArray(history) ? history : null;
629
+ },
615
630
  });
616
631
 
632
+ /**
633
+ * A request of the human begins.
634
+ *
635
+ * Every path that carries the words or the decision of the human into Pi
636
+ * is a boundary of a request. The interactive input event is one. A
637
+ * message of a channel is another, because it reaches Pi as a message of
638
+ * the harness and the input event cannot tell it apart from the traffic
639
+ * of the harness itself.
640
+ *
641
+ * A path that forwards the human without this boundary leaves the scope of
642
+ * the previous request in place, and the new request inherits the
643
+ * completion of the old one: a question of the new request is then a
644
+ * question about work that was already done, and it is dropped.
645
+ *
646
+ * The messages of the harness itself begin nothing. They continue the work
647
+ * of the request that is running.
648
+ */
649
+ function beginHumanRequest(): void {
650
+ requestScopeTracker.begin();
651
+ }
652
+
617
653
  /**
618
654
  * Apply an approval decision from a channel to the pending question.
619
655
  *
@@ -1108,6 +1144,10 @@ async function startBiomeImplementation(
1108
1144
  try {
1109
1145
  const mod = await import("./packages/tooling-preference/dist/index.js");
1110
1146
  const context = mod.detectToolingContext(workspaceRoot);
1147
+ // The decision of the human starts new work: it begins a request.
1148
+ // The prompt reaches Pi as a message of the harness, so the input
1149
+ // event cannot begin the scope of the request.
1150
+ beginHumanRequest();
1111
1151
  await pi.sendUserMessage(
1112
1152
  mod.buildToolingImplementationPrompt(context, workspaceRoot),
1113
1153
  { deliverAs: "steer" },
@@ -2792,6 +2832,9 @@ async function initAutoContinue(pi: ExtensionAPI): Promise<void> {
2792
2832
  // The runtime of the provider recovery reads the pause state
2793
2833
  // of the user through this handle.
2794
2834
  todoContinuationHandle = todoContinuationController;
2835
+ // The scope of the previous session says nothing about this
2836
+ // one: the todos of that session are its history.
2837
+ requestScopeTracker.reset();
2795
2838
  // The callbacks that answer a question in a channel, and the
2796
2839
  // replies of the user, reach the controller through the
2797
2840
  // shared state. Without it every pause and every resume of
@@ -2813,6 +2856,8 @@ async function initAutoContinue(pi: ExtensionAPI): Promise<void> {
2813
2856
  todoContinuationHandle = null;
2814
2857
  sharedState.todoContinuationController = null;
2815
2858
  sharedState.validationLedger = null;
2859
+ // The scope belongs to the session that is ending.
2860
+ requestScopeTracker.reset();
2816
2861
  });
2817
2862
 
2818
2863
  // --- task-intake: Automatic todo capture from user requests -----------
@@ -3410,6 +3455,10 @@ async function advanceCodexTask(
3410
3455
 
3411
3456
  // Execute action
3412
3457
  if (action === "code" || action === "code_again") {
3458
+ // The decision of the human starts new work: it begins a request.
3459
+ // The message reaches Pi as a message of the harness, so the input
3460
+ // event cannot begin the scope of the request.
3461
+ beginHumanRequest();
3413
3462
  await pi.sendUserMessage(
3414
3463
  `Human approved. Proceed to implement: ${event.planPath}`,
3415
3464
  { deliverAs: "steer" }
@@ -3417,6 +3466,8 @@ async function advanceCodexTask(
3417
3466
  event.status = "triggered";
3418
3467
  logToFile("[codex-trigger]", `Advanced to code: ${event.planPath}`);
3419
3468
  } else if (action === "review") {
3469
+ // The decision of the human starts new work: it begins a request.
3470
+ beginHumanRequest();
3420
3471
  await pi.sendUserMessage(
3421
3472
  "Human requests a review of the implementation.",
3422
3473
  { deliverAs: "steer" }
@@ -3744,7 +3795,7 @@ async function initTelegram(pi: ExtensionAPI): Promise<void> {
3744
3795
  // request that ran before it is history now. The message reaches
3745
3796
  // Pi as a message of the harness, so the input event cannot
3746
3797
  // tell that it is a request.
3747
- requestScopeTracker.begin();
3798
+ beginHumanRequest();
3748
3799
  // Forward the message to Pi as a user message
3749
3800
  await pi.sendUserMessage(text, { deliverAs: "steer" });
3750
3801
  });
@@ -5957,6 +6008,10 @@ function initLineVoiceQueue(pi: ExtensionAPI): void {
5957
6008
 
5958
6009
  if (cmd.type === "voice-prompt" && cmd.text) {
5959
6010
  logToFile("[LineVoice]", `Injecting voice prompt: "${cmd.text}"`);
6011
+ // The voice of the human is a request: it reaches Pi as a
6012
+ // message of the harness, so the input event cannot begin
6013
+ // the scope of the request.
6014
+ beginHumanRequest();
5960
6015
  pi.sendUserMessage(cmd.text, { deliverAs: "steer" });
5961
6016
  logToFile("[LineVoice]", "Voice prompt injected via steer");
5962
6017
  }
@@ -6810,7 +6865,7 @@ Run \`bd ready\` to see current bd issues.
6810
6865
  // previous request are history, and the completion of that request
6811
6866
  // is not the completion of this one. The message of the harness
6812
6867
  // itself carries the source `extension` and begins nothing.
6813
- requestScopeTracker.begin();
6868
+ beginHumanRequest();
6814
6869
  });
6815
6870
 
6816
6871
  // The run settled: the internal retries of Pi are over, so a failure
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-harness-runtime",
3
- "version": "1.1.502",
3
+ "version": "1.1.503",
4
4
  "description": "[BETA] Codex-style /usage status + autonomous coding harness for pi. Not production ready — expect breaking changes.",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/agent-policy",
3
- "version": "1.1.502",
3
+ "version": "1.1.503",
4
4
  "description": "Agent policy runtime for pi-harness - enforces mandatory rule delivery and mutation gating",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/auth",
3
- "version": "1.1.502",
3
+ "version": "1.1.503",
4
4
  "description": "pi-harness-runtime — auth",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/autonomous-runtime",
3
- "version": "1.1.502",
3
+ "version": "1.1.503",
4
4
  "description": "Autonomous Operations Runtime — task inbox, lease management, and worker lifecycle (RFC-0101)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/checkpoint",
3
- "version": "1.1.502",
3
+ "version": "1.1.503",
4
4
  "description": "Enhanced checkpoint system with incremental snapshots, diff-based storage, and recovery strategies",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/clipboard",
3
- "version": "1.1.502",
3
+ "version": "1.1.503",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/codex-watcher",
3
- "version": "1.1.502",
3
+ "version": "1.1.503",
4
4
  "description": "Watches Codex CLI sessions and emits visible messages for PING-PONG monitoring",
5
5
  "type": "module",
6
6
  "main": "./dist/src/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moocoding/config-capture",
3
- "version": "1.1.502",
3
+ "version": "1.1.503",
4
4
  "description": "Auto-capture API-fetched configuration values to AGENTS.md",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/contracts",
3
- "version": "1.1.502",
3
+ "version": "1.1.503",
4
4
  "type": "module",
5
5
  "description": "RPC schema definitions for pi-harness runtime",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/cookie-sanitizer",
3
- "version": "1.1.502",
3
+ "version": "1.1.503",
4
4
  "description": "pi-harness-runtime — cookie sanitizer (provider-quota cookie file normaliser)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/evaluation-engine",
3
- "version": "1.1.502",
3
+ "version": "1.1.503",
4
4
  "description": "Evaluation engine for pi-harness runtime (RFC-0057)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/event-bus",
3
- "version": "1.1.502",
3
+ "version": "1.1.503",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/event-store",
3
- "version": "1.1.502",
3
+ "version": "1.1.503",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/experience-replay",
3
- "version": "1.1.502",
3
+ "version": "1.1.503",
4
4
  "description": "Experience replay for debugging and reproducibility (RFC-0059)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moocoding/file-copy-helper",
3
- "version": "1.1.502",
3
+ "version": "1.1.503",
4
4
  "description": "Injects cp/sudo cp rule when user asks to mimic/copy files",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/intent-analyzer",
3
- "version": "1.1.502",
3
+ "version": "1.1.503",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
@@ -1,4 +1,4 @@
1
- import type { TodoItem, TodoContext, TodoProvider } from "./todo-provider.js";
1
+ import type { TodoHistoryEntry, TodoItem, TodoContext, TodoProvider } from "./todo-provider.js";
2
2
  import { type ValidationBudgetStatus } from "./validation-plan.js";
3
3
  import type { ValidationLedger } from "./validation-ledger.js";
4
4
  export interface ContinuationConfig {
@@ -226,6 +226,15 @@ export declare class TodoContinuationController {
226
226
  * Get current todo snapshot (exposed for task intake)
227
227
  */
228
228
  getSnapshot(): Promise<import("./todo-provider.js").TodoSnapshot>;
229
+ /**
230
+ * The history of the todo list: the state after every change.
231
+ *
232
+ * The list says what the work is now. The history says what a request
233
+ * touched, also when the item is back in the state it had before: a
234
+ * todo that was reopened and finished again is work of the request
235
+ * that did it.
236
+ */
237
+ getHistory(): Promise<TodoHistoryEntry[]>;
229
238
  /**
230
239
  * Temporary pause for user input processing
231
240
  * Does not require explicit resume