pi-harness-runtime 1.1.468 → 1.1.470

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 (50) hide show
  1. package/CHANGELOG.md +97 -0
  2. package/package.json +1 -1
  3. package/packages/agent-policy/package.json +1 -1
  4. package/packages/auth/package.json +1 -1
  5. package/packages/autonomous-runtime/package.json +1 -1
  6. package/packages/checkpoint/package.json +1 -1
  7. package/packages/clipboard/package.json +1 -1
  8. package/packages/codex-watcher/package.json +1 -1
  9. package/packages/config-capture/package.json +1 -1
  10. package/packages/contracts/dist/workspace-env-format.js +19 -0
  11. package/packages/contracts/package.json +1 -1
  12. package/packages/contracts/src/workspace-env-format.ts +19 -0
  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/decision-context.d.ts +12 -0
  21. package/packages/jev-judge/dist/decision-context.d.ts.map +1 -1
  22. package/packages/jev-judge/dist/decision-context.js +163 -10
  23. package/packages/jev-judge/dist/decision-context.js.map +1 -1
  24. package/packages/jev-judge/package.json +1 -1
  25. package/packages/jev-judge/src/decision-context.ts +174 -9
  26. package/packages/knowledge-retrieval/package.json +1 -1
  27. package/packages/learning-engine/package.json +1 -1
  28. package/packages/logging/package.json +1 -1
  29. package/packages/memory-engine/package.json +1 -1
  30. package/packages/notification/package.json +1 -1
  31. package/packages/paperclip-integration/package.json +1 -1
  32. package/packages/performance-optimizer/package.json +1 -1
  33. package/packages/privilege-broker/package.json +1 -1
  34. package/packages/prompt-compiler/package.json +1 -1
  35. package/packages/providers/package.json +1 -1
  36. package/packages/qdrant-skills/package.json +1 -1
  37. package/packages/quota-manager/package.json +1 -1
  38. package/packages/relay/package.json +1 -1
  39. package/packages/skill-mcp-client/package.json +1 -1
  40. package/packages/skills/package.json +1 -1
  41. package/packages/todo-bd-sync/package.json +1 -1
  42. package/packages/token-estimation/package.json +1 -1
  43. package/packages/tooling-preference/package.json +1 -1
  44. package/packages/trajectory/package.json +1 -1
  45. package/packages/tui/package.json +1 -1
  46. package/packages/two-phase-review/package.json +1 -1
  47. package/packages/types/package.json +1 -1
  48. package/packages/webmcp-tester/package.json +1 -1
  49. package/packages/wiki/package.json +1 -1
  50. package/packages/write-review/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,103 @@
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.470](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v1.1.448...v1.1.470) (2026-11-07)
6
+
7
+
8
+ ### Features
9
+
10
+ * **delegation:** a child is only a child when it really ran ([ac4e678](https://github.com/ManotLuijiu/pi-harness-runtime/commit/ac4e6782d7d4bc4941e458425c8a9f38a51fc9d4))
11
+ * **delegation:** the scope of a request is measured before it is judged ([684b6a5](https://github.com/ManotLuijiu/pi-harness-runtime/commit/684b6a55184f63d3be24c48dcecfb0b13410dc15))
12
+ * **honcho:** the memory service speaks the native MCP of Pi ([f9f740c](https://github.com/ManotLuijiu/pi-harness-runtime/commit/f9f740c12869bae4c4380afbe8c76e12388bb744))
13
+ * **jev:** the evaluation of a choice sees what the options mean ([f0c207e](https://github.com/ManotLuijiu/pi-harness-runtime/commit/f0c207e074701e6b7dab0965170ec39453d9d502))
14
+ * **jev:** the pending question carries the ask and the answer ([a792133](https://github.com/ManotLuijiu/pi-harness-runtime/commit/a792133e517fb8c12d3363e98942f3af30270f27))
15
+ * **jev:** the pending question counts down to the decision ([d0cc171](https://github.com/ManotLuijiu/pi-harness-runtime/commit/d0cc171223986b2d32c670b6c1c74712fe0a4ad8))
16
+ * **keys:** the key files are repaired when their permissions are unsafe ([e9c2c26](https://github.com/ManotLuijiu/pi-harness-runtime/commit/e9c2c26b287665b56ed749de269737e8403bb8af))
17
+ * **mcp:** the harness connects the registered servers when nobody else does ([7fef951](https://github.com/ManotLuijiu/pi-harness-runtime/commit/7fef95137ad4664df57f045cd91b7d233315b0bc))
18
+ * **merge:** a manual run can leave the merge to the pull request event ([b3d1950](https://github.com/ManotLuijiu/pi-harness-runtime/commit/b3d1950b5941c78ccd56951acdafd1d4afbe1bff))
19
+ * **phase:** the agent owns the todo list and the harness says so ([c489370](https://github.com/ManotLuijiu/pi-harness-runtime/commit/c489370bd7926aece8cb1a77aa20ca2d2672f1fb))
20
+ * **review:** the review starts on its own when the implementation is done ([04f51f5](https://github.com/ManotLuijiu/pi-harness-runtime/commit/04f51f599cd3222b6c74dd8fadb1373bd72d9bd7))
21
+ * **status:** the status line names the phase, the progress and the children ([0167bf3](https://github.com/ManotLuijiu/pi-harness-runtime/commit/0167bf396a0b987c1d44f3b869351976a951dd65))
22
+ * **test:** the task waits for the final tier of the validation plan ([fa147db](https://github.com/ManotLuijiu/pi-harness-runtime/commit/fa147dbf7d50d56e6ea48c6d8fbb4fcb190caf8a))
23
+ * **validation:** a large job starts with a measured pilot ([425964b](https://github.com/ManotLuijiu/pi-harness-runtime/commit/425964b04a3d4fa02adfabed47ff62c5ec2b9c28))
24
+ * **validation:** the size of a job is a fact, not a phrase ([8aa6c11](https://github.com/ManotLuijiu/pi-harness-runtime/commit/8aa6c119565d0f8412dc8aeafa6b295d47d3f093))
25
+ * **workspace:** a Frappe bench names the mode of the workspace ([9d58517](https://github.com/ManotLuijiu/pi-harness-runtime/commit/9d585172063a330992fee933316e268ae9985e3c))
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * **ci:** every run of a required check counts, and the worst one decides ([da9e0da](https://github.com/ManotLuijiu/pi-harness-runtime/commit/da9e0da6b0ca29cb320764fd5fc1b8a8dee8b1e0))
31
+ * **ci:** the newest attempt of a run decides, not the attempt that failed ([9d7adcc](https://github.com/ManotLuijiu/pi-harness-runtime/commit/9d7adcc31cbacc517c3c1a9bcd3956be94c908ef))
32
+ * **honcho:** the report names the state of the MCP server, not the registration ([762f4d5](https://github.com/ManotLuijiu/pi-harness-runtime/commit/762f4d59e4eabcab9a1c21a61aa522c3267621b3))
33
+ * **hooks:** a tag is checked through the commit behind it ([c823e8e](https://github.com/ManotLuijiu/pi-harness-runtime/commit/c823e8e1f6973c62b5449a97c101759a4d5cbba5))
34
+ * **jev:** a session switch ends the wait of the old session ([ca03d39](https://github.com/ManotLuijiu/pi-harness-runtime/commit/ca03d399c0d4a1b2dd428ac39836ab53c0e51ab6))
35
+ * **jev:** keep a comparative caveat with the option it constrains ([7be306b](https://github.com/ManotLuijiu/pi-harness-runtime/commit/7be306b0d0872713ebca9386d613ae5a8da9d5b6))
36
+ * **jev:** the alternatives of a question are parsed without a quadratic pattern ([63016a3](https://github.com/ManotLuijiu/pi-harness-runtime/commit/63016a3f0488acb801990dd46770c00d382b5858))
37
+ * **jev:** the facts of an option survive the wording of the agent ([5a6250c](https://github.com/ManotLuijiu/pi-harness-runtime/commit/5a6250c07aa8d965bc6ae242cccbf519477598f8))
38
+ * **keys:** the key directory is audited as a tree ([081cc75](https://github.com/ManotLuijiu/pi-harness-runtime/commit/081cc75ac8ceff36b0d619c3f76371dc08459d3c))
39
+ * **mcp:** the connector survives a runtime that cannot list the servers ([d0f555f](https://github.com/ManotLuijiu/pi-harness-runtime/commit/d0f555fa14f51de33591e572a41ded5b59a3e4dd))
40
+ * **merge:** the boolean input is read as a boolean ([971b716](https://github.com/ManotLuijiu/pi-harness-runtime/commit/971b7169a43db382dbdeb6bb9bab02ab56e0351c))
41
+ * **merge:** the manual job needs the right of the merge ([7ba685e](https://github.com/ManotLuijiu/pi-harness-runtime/commit/7ba685ec43d815f90aa35b742579e87e76c69209))
42
+ * **merge:** the merge of the pull request is the GraphQL mutation ([972bab4](https://github.com/ManotLuijiu/pi-harness-runtime/commit/972bab4b0f7faf1b0047f3bb767ef6db3de4b2fa))
43
+ * **merge:** the workflow merges the pull request the gates cleared ([d7639ec](https://github.com/ManotLuijiu/pi-harness-runtime/commit/d7639ec9b83723510acb4a5c4e23d5d6167c3af6))
44
+ * **release:** a manual release keeps the version of its manifest ([122e661](https://github.com/ManotLuijiu/pi-harness-runtime/commit/122e661ea48cb8aff14c71dbd0221a4cf0ba4c8e))
45
+ * **release:** the alignment names the reason of a failure ([5814dd0](https://github.com/ManotLuijiu/pi-harness-runtime/commit/5814dd0b780f5839cf8011ed0cbbbb31e7eb0418))
46
+ * **release:** the channels of the package name the release ([a7a273f](https://github.com/ManotLuijiu/pi-harness-runtime/commit/a7a273ffe8398e2b5b07ef1c321777de41792c6e))
47
+ * **release:** the release publishes and leaves the channels alone ([5871746](https://github.com/ManotLuijiu/pi-harness-runtime/commit/5871746589c1281d855dbeb591b02419fa43f22e))
48
+ * **release:** the release pull request names the version of its branch ([a846e83](https://github.com/ManotLuijiu/pi-harness-runtime/commit/a846e83e6de6e529f4bca05e869db0b5eebb37c5))
49
+ * **release:** the release scans the tree of the commit it publishes ([7d47a0b](https://github.com/ManotLuijiu/pi-harness-runtime/commit/7d47a0b5406480a1e1d3a52623a76aabd1e2d0ba))
50
+ * **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))
51
+ * **workspace:** keep a client name out of the comment about the search depth ([b572e0a](https://github.com/ManotLuijiu/pi-harness-runtime/commit/b572e0af16ff562203bda2b5c47b41807cff5a95))
52
+ * **workspace:** the repository names the mode before the mode stays unknown ([188a32c](https://github.com/ManotLuijiu/pi-harness-runtime/commit/188a32c7a6af1465dd24714278fccc73d06f6477))
53
+
54
+ ### [1.1.469](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v1.1.448...v1.1.469) (2026-11-07)
55
+
56
+
57
+ ### Features
58
+
59
+ * **delegation:** a child is only a child when it really ran ([ac4e678](https://github.com/ManotLuijiu/pi-harness-runtime/commit/ac4e6782d7d4bc4941e458425c8a9f38a51fc9d4))
60
+ * **delegation:** the scope of a request is measured before it is judged ([684b6a5](https://github.com/ManotLuijiu/pi-harness-runtime/commit/684b6a55184f63d3be24c48dcecfb0b13410dc15))
61
+ * **honcho:** the memory service speaks the native MCP of Pi ([f9f740c](https://github.com/ManotLuijiu/pi-harness-runtime/commit/f9f740c12869bae4c4380afbe8c76e12388bb744))
62
+ * **jev:** the evaluation of a choice sees what the options mean ([f0c207e](https://github.com/ManotLuijiu/pi-harness-runtime/commit/f0c207e074701e6b7dab0965170ec39453d9d502))
63
+ * **jev:** the pending question carries the ask and the answer ([a792133](https://github.com/ManotLuijiu/pi-harness-runtime/commit/a792133e517fb8c12d3363e98942f3af30270f27))
64
+ * **jev:** the pending question counts down to the decision ([d0cc171](https://github.com/ManotLuijiu/pi-harness-runtime/commit/d0cc171223986b2d32c670b6c1c74712fe0a4ad8))
65
+ * **keys:** the key files are repaired when their permissions are unsafe ([e9c2c26](https://github.com/ManotLuijiu/pi-harness-runtime/commit/e9c2c26b287665b56ed749de269737e8403bb8af))
66
+ * **mcp:** the harness connects the registered servers when nobody else does ([7fef951](https://github.com/ManotLuijiu/pi-harness-runtime/commit/7fef95137ad4664df57f045cd91b7d233315b0bc))
67
+ * **merge:** a manual run can leave the merge to the pull request event ([b3d1950](https://github.com/ManotLuijiu/pi-harness-runtime/commit/b3d1950b5941c78ccd56951acdafd1d4afbe1bff))
68
+ * **phase:** the agent owns the todo list and the harness says so ([c489370](https://github.com/ManotLuijiu/pi-harness-runtime/commit/c489370bd7926aece8cb1a77aa20ca2d2672f1fb))
69
+ * **review:** the review starts on its own when the implementation is done ([04f51f5](https://github.com/ManotLuijiu/pi-harness-runtime/commit/04f51f599cd3222b6c74dd8fadb1373bd72d9bd7))
70
+ * **status:** the status line names the phase, the progress and the children ([0167bf3](https://github.com/ManotLuijiu/pi-harness-runtime/commit/0167bf396a0b987c1d44f3b869351976a951dd65))
71
+ * **test:** the task waits for the final tier of the validation plan ([fa147db](https://github.com/ManotLuijiu/pi-harness-runtime/commit/fa147dbf7d50d56e6ea48c6d8fbb4fcb190caf8a))
72
+ * **validation:** a large job starts with a measured pilot ([425964b](https://github.com/ManotLuijiu/pi-harness-runtime/commit/425964b04a3d4fa02adfabed47ff62c5ec2b9c28))
73
+ * **validation:** the size of a job is a fact, not a phrase ([8aa6c11](https://github.com/ManotLuijiu/pi-harness-runtime/commit/8aa6c119565d0f8412dc8aeafa6b295d47d3f093))
74
+ * **workspace:** a Frappe bench names the mode of the workspace ([9d58517](https://github.com/ManotLuijiu/pi-harness-runtime/commit/9d585172063a330992fee933316e268ae9985e3c))
75
+
76
+
77
+ ### Bug Fixes
78
+
79
+ * **ci:** every run of a required check counts, and the worst one decides ([da9e0da](https://github.com/ManotLuijiu/pi-harness-runtime/commit/da9e0da6b0ca29cb320764fd5fc1b8a8dee8b1e0))
80
+ * **ci:** the newest attempt of a run decides, not the attempt that failed ([9d7adcc](https://github.com/ManotLuijiu/pi-harness-runtime/commit/9d7adcc31cbacc517c3c1a9bcd3956be94c908ef))
81
+ * **honcho:** the report names the state of the MCP server, not the registration ([762f4d5](https://github.com/ManotLuijiu/pi-harness-runtime/commit/762f4d59e4eabcab9a1c21a61aa522c3267621b3))
82
+ * **hooks:** a tag is checked through the commit behind it ([c823e8e](https://github.com/ManotLuijiu/pi-harness-runtime/commit/c823e8e1f6973c62b5449a97c101759a4d5cbba5))
83
+ * **jev:** a session switch ends the wait of the old session ([ca03d39](https://github.com/ManotLuijiu/pi-harness-runtime/commit/ca03d399c0d4a1b2dd428ac39836ab53c0e51ab6))
84
+ * **jev:** keep a comparative caveat with the option it constrains ([7be306b](https://github.com/ManotLuijiu/pi-harness-runtime/commit/7be306b0d0872713ebca9386d613ae5a8da9d5b6))
85
+ * **jev:** the alternatives of a question are parsed without a quadratic pattern ([63016a3](https://github.com/ManotLuijiu/pi-harness-runtime/commit/63016a3f0488acb801990dd46770c00d382b5858))
86
+ * **jev:** the facts of an option survive the wording of the agent ([5a6250c](https://github.com/ManotLuijiu/pi-harness-runtime/commit/5a6250c07aa8d965bc6ae242cccbf519477598f8))
87
+ * **keys:** the key directory is audited as a tree ([081cc75](https://github.com/ManotLuijiu/pi-harness-runtime/commit/081cc75ac8ceff36b0d619c3f76371dc08459d3c))
88
+ * **mcp:** the connector survives a runtime that cannot list the servers ([d0f555f](https://github.com/ManotLuijiu/pi-harness-runtime/commit/d0f555fa14f51de33591e572a41ded5b59a3e4dd))
89
+ * **merge:** the boolean input is read as a boolean ([971b716](https://github.com/ManotLuijiu/pi-harness-runtime/commit/971b7169a43db382dbdeb6bb9bab02ab56e0351c))
90
+ * **merge:** the manual job needs the right of the merge ([7ba685e](https://github.com/ManotLuijiu/pi-harness-runtime/commit/7ba685ec43d815f90aa35b742579e87e76c69209))
91
+ * **merge:** the merge of the pull request is the GraphQL mutation ([972bab4](https://github.com/ManotLuijiu/pi-harness-runtime/commit/972bab4b0f7faf1b0047f3bb767ef6db3de4b2fa))
92
+ * **merge:** the workflow merges the pull request the gates cleared ([d7639ec](https://github.com/ManotLuijiu/pi-harness-runtime/commit/d7639ec9b83723510acb4a5c4e23d5d6167c3af6))
93
+ * **release:** a manual release keeps the version of its manifest ([122e661](https://github.com/ManotLuijiu/pi-harness-runtime/commit/122e661ea48cb8aff14c71dbd0221a4cf0ba4c8e))
94
+ * **release:** the alignment names the reason of a failure ([5814dd0](https://github.com/ManotLuijiu/pi-harness-runtime/commit/5814dd0b780f5839cf8011ed0cbbbb31e7eb0418))
95
+ * **release:** the channels of the package name the release ([a7a273f](https://github.com/ManotLuijiu/pi-harness-runtime/commit/a7a273ffe8398e2b5b07ef1c321777de41792c6e))
96
+ * **release:** the release publishes and leaves the channels alone ([5871746](https://github.com/ManotLuijiu/pi-harness-runtime/commit/5871746589c1281d855dbeb591b02419fa43f22e))
97
+ * **release:** the release pull request names the version of its branch ([a846e83](https://github.com/ManotLuijiu/pi-harness-runtime/commit/a846e83e6de6e529f4bca05e869db0b5eebb37c5))
98
+ * **release:** the release scans the tree of the commit it publishes ([7d47a0b](https://github.com/ManotLuijiu/pi-harness-runtime/commit/7d47a0b5406480a1e1d3a52623a76aabd1e2d0ba))
99
+ * **workspace:** keep a client name out of the comment about the search depth ([b572e0a](https://github.com/ManotLuijiu/pi-harness-runtime/commit/b572e0af16ff562203bda2b5c47b41807cff5a95))
100
+ * **workspace:** the repository names the mode before the mode stays unknown ([188a32c](https://github.com/ManotLuijiu/pi-harness-runtime/commit/188a32c7a6af1465dd24714278fccc73d06f6477))
101
+
5
102
  ### [1.1.468](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v1.1.448...v1.1.468) (2026-11-07)
6
103
 
7
104
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-harness-runtime",
3
- "version": "1.1.468",
3
+ "version": "1.1.470",
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.468",
3
+ "version": "1.1.470",
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.468",
3
+ "version": "1.1.470",
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.468",
3
+ "version": "1.1.470",
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.468",
3
+ "version": "1.1.470",
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.468",
3
+ "version": "1.1.470",
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.468",
3
+ "version": "1.1.470",
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.468",
3
+ "version": "1.1.470",
4
4
  "description": "Auto-capture API-fetched configuration values to AGENTS.md",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -472,6 +472,25 @@ export function modeFromFrappeBenchFacts(facts) {
472
472
  // A contradiction is not a mode: the facts say both, so nothing is claimed.
473
473
  if (strongDevelopment.length > 0 && strongProduction.length > 0)
474
474
  return null;
475
+ // A strong signal decides: the runtime of the bench says how it runs, and
476
+ // it outweighs the configuration flags, however many of them point the
477
+ // other way.
478
+ if (strongDevelopment.length > 0) {
479
+ return {
480
+ mode: "development",
481
+ key: `frappe bench: ${strongDevelopment
482
+ .map((signal) => signal.reason)
483
+ .join(", ")}`,
484
+ };
485
+ }
486
+ if (strongProduction.length > 0) {
487
+ return {
488
+ mode: "production",
489
+ key: `frappe bench: ${strongProduction
490
+ .map((signal) => signal.reason)
491
+ .join(", ")}`,
492
+ };
493
+ }
475
494
  const score = (signals) => signals.reduce((total, signal) => total + BENCH_SIGNAL_WEIGHT[signal.strength], 0);
476
495
  const developmentScore = score(development);
477
496
  const productionScore = score(production);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/contracts",
3
- "version": "1.1.468",
3
+ "version": "1.1.470",
4
4
  "type": "module",
5
5
  "description": "RPC schema definitions for pi-harness runtime",
6
6
  "main": "./dist/index.js",
@@ -669,6 +669,25 @@ export function modeFromFrappeBenchFacts(
669
669
  const strongProduction = production.filter((signal) => signal.strength === "strong");
670
670
  // A contradiction is not a mode: the facts say both, so nothing is claimed.
671
671
  if (strongDevelopment.length > 0 && strongProduction.length > 0) return null;
672
+ // A strong signal decides: the runtime of the bench says how it runs, and
673
+ // it outweighs the configuration flags, however many of them point the
674
+ // other way.
675
+ if (strongDevelopment.length > 0) {
676
+ return {
677
+ mode: "development",
678
+ key: `frappe bench: ${strongDevelopment
679
+ .map((signal) => signal.reason)
680
+ .join(", ")}`,
681
+ };
682
+ }
683
+ if (strongProduction.length > 0) {
684
+ return {
685
+ mode: "production",
686
+ key: `frappe bench: ${strongProduction
687
+ .map((signal) => signal.reason)
688
+ .join(", ")}`,
689
+ };
690
+ }
672
691
 
673
692
  const score = (signals: BenchSignal[]): number =>
674
693
  signals.reduce((total, signal) => total + BENCH_SIGNAL_WEIGHT[signal.strength], 0);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/cookie-sanitizer",
3
- "version": "1.1.468",
3
+ "version": "1.1.470",
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.468",
3
+ "version": "1.1.470",
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.468",
3
+ "version": "1.1.470",
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.468",
3
+ "version": "1.1.470",
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.468",
3
+ "version": "1.1.470",
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.468",
3
+ "version": "1.1.470",
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.468",
3
+ "version": "1.1.470",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
@@ -15,6 +15,10 @@
15
15
  * - Nothing here decides: the module never selects an option and never
16
16
  * invents an approval. Missing information is surfaced as an uncertainty
17
17
  * so that a wait outcome stays possible.
18
+ * - A comparison is never dropped: a statement that names two options
19
+ * ("Unlike A, B must connect every server") is kept with the option it
20
+ * constrains, and a comparison whose subject is not established is
21
+ * reported as an uncertainty.
18
22
  * - Every bound is declared and every cut is reported, so a reader can tell
19
23
  * what the evaluation did not see.
20
24
  */
@@ -145,6 +149,14 @@ export interface ExtractedOption {
145
149
  * belongs to.
146
150
  */
147
151
  descriptionConstraint: boolean;
152
+ /**
153
+ * The comparisons that could not be attributed to one option.
154
+ *
155
+ * A statement that compares the options without saying which one it
156
+ * constrains is kept with every option it names, and it is reported here
157
+ * so that the comparison does not disappear silently.
158
+ */
159
+ comparative: string[];
148
160
  }
149
161
  /** What the extraction needs to know about one option. */
150
162
  export interface OptionExtractionInput {
@@ -1 +1 @@
1
- {"version":3,"file":"decision-context.d.ts","sourceRoot":"","sources":["../src/decision-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,6CAA6C;AAC7C,eAAO,MAAM,kBAAk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AM,EACV,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EAAE,GACnB,MAAM,CAUR;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,qBAAqB,GAAG,MAAM,CAsC1E"}
@@ -15,6 +15,10 @@
15
15
  * - Nothing here decides: the module never selects an option and never
16
16
  * invents an approval. Missing information is surfaced as an uncertainty
17
17
  * so that a wait outcome stays possible.
18
+ * - A comparison is never dropped: a statement that names two options
19
+ * ("Unlike A, B must connect every server") is kept with the option it
20
+ * constrains, and a comparison whose subject is not established is
21
+ * reported as an uncertainty.
18
22
  * - Every bound is declared and every cut is reported, so a reader can tell
19
23
  * what the evaluation did not see.
20
24
  */
@@ -172,20 +176,50 @@ function isOptionHeader(line, anchor) {
172
176
  return false;
173
177
  return HEADER_SEPARATORS.includes(next);
174
178
  }
179
+ /**
180
+ * The position of the first mention of an anchor in a text (-1 when the
181
+ * anchor is not mentioned).
182
+ */
183
+ function firstMention(text, anchor) {
184
+ if (anchor.length === 0)
185
+ return -1;
186
+ let from = 0;
187
+ for (;;) {
188
+ const index = text.indexOf(anchor, from);
189
+ if (index === -1)
190
+ return -1;
191
+ const before = index > 0 ? text.charAt(index - 1) : "";
192
+ const after = text.charAt(index + anchor.length);
193
+ if ((before === "" || !isWordCharacter(before)) &&
194
+ (after === "" || !isWordCharacter(after))) {
195
+ return index;
196
+ }
197
+ from = index + 1;
198
+ }
199
+ }
175
200
  /** Whether a line mentions the anchor as a word. */
176
201
  function mentionsAnchor(line, anchor) {
177
- if (anchor.length === 0)
178
- return false;
202
+ return firstMention(line, anchor) >= 0;
203
+ }
204
+ /**
205
+ * The position of a word in a text (-1 when the word is not there).
206
+ *
207
+ * The word has to stand on its own: "unlike" inside "unlikelihood" is not a
208
+ * connective.
209
+ */
210
+ function indexOfWord(text, word) {
211
+ const lowerText = text.toLowerCase();
212
+ const lowerWord = word.toLowerCase();
179
213
  let from = 0;
180
214
  for (;;) {
181
- const index = line.indexOf(anchor, from);
215
+ const index = lowerText.indexOf(lowerWord, from);
182
216
  if (index === -1)
183
- return false;
184
- const before = index > 0 ? line.charAt(index - 1) : "";
185
- const after = line.charAt(index + anchor.length);
217
+ return -1;
218
+ const before = index > 0 ? text.charAt(index - 1) : "";
219
+ const after = text.charAt(index + lowerWord.length);
186
220
  if ((before === "" || !isWordCharacter(before)) &&
187
221
  (after === "" || !isWordCharacter(after))) {
188
- return true;
222
+ return index;
189
223
  }
190
224
  from = index + 1;
191
225
  }
@@ -197,6 +231,21 @@ function stripMarkdown(value) {
197
231
  .replace(/(\*\*|__|`)/g, "")
198
232
  .trim();
199
233
  }
234
+ /**
235
+ * Whether a paragraph is the question of the choice.
236
+ *
237
+ * The question names both options, so it is a comparison of them - but it is
238
+ * the question of the context, not a fact of an option: it is already carried
239
+ * by the context itself, and a comparison that only repeats it would be noise
240
+ * in the facts of every option.
241
+ */
242
+ function isQuestionParagraph(text, question) {
243
+ const value = stripMarkdown(text).trim().toLowerCase();
244
+ const asked = stripMarkdown(question).trim().toLowerCase();
245
+ if (asked.length === 0)
246
+ return false;
247
+ return value === asked || value.endsWith(asked);
248
+ }
200
249
  /**
201
250
  * Remove the anchor of an option from the beginning of its description, so
202
251
  * the description starts with the meaning and not with the label.
@@ -219,6 +268,56 @@ function statesConstraint(paragraph) {
219
268
  return (/^\s*(caveat|caveats?|careful|note|warning|constraint|constraints?|however|but|instead|only if|never|must|do not|don't|cannot|can't)\b/i.test(paragraph) ||
220
269
  /\b(must|never|cannot|can not|only if|is required to|has to|not just)\b/i.test(paragraph));
221
270
  }
271
+ /**
272
+ * The connectives that name the option that is contrasted with.
273
+ *
274
+ * "Unlike A, B must ..." contrasts B with A: the connective names the option
275
+ * that is not the subject of the statement.
276
+ */
277
+ const CONTRASTED_CONNECTIVES = [
278
+ "unlike",
279
+ "in contrast to",
280
+ "as opposed to",
281
+ "compared with",
282
+ "compared to",
283
+ "rather than",
284
+ "instead of",
285
+ ];
286
+ /**
287
+ * The anchor of the option that a comparative statement is about.
288
+ *
289
+ * A statement that names more than one option compares them, and the
290
+ * comparison usually says which option the statement is about:
291
+ *
292
+ * - "Unlike A, B must connect every registered server before reporting
293
+ * ready" is about B: the connective names the option that is contrasted
294
+ * with, so the subject is the other one.
295
+ * - "A and B both need the scheduler" is about both: no option is
296
+ * contrasted with the other one, so the statement is shared.
297
+ *
298
+ * @param text The statement
299
+ * @param anchors The anchors of every option
300
+ * @returns The anchor of the subject ("" when the statement is shared)
301
+ */
302
+ function comparativeSubjectAnchor(text, anchors) {
303
+ const mentions = anchors
304
+ .map((anchor) => ({ anchor, at: firstMention(text, anchor) }))
305
+ .filter((mention) => mention.at >= 0)
306
+ .sort((left, right) => left.at - right.at);
307
+ if (mentions.length <= 1)
308
+ return "";
309
+ for (const connective of CONTRASTED_CONNECTIVES) {
310
+ const at = indexOfWord(text, connective);
311
+ if (at < 0)
312
+ continue;
313
+ const contrasted = mentions.find((mention) => mention.at > at);
314
+ if (!contrasted)
315
+ continue;
316
+ const others = mentions.filter((mention) => mention.anchor !== contrasted.anchor);
317
+ return others.length === 1 ? others[0].anchor : "";
318
+ }
319
+ return "";
320
+ }
222
321
  /**
223
322
  * Whether a text mentions an anchor as a word.
224
323
  */
@@ -287,6 +386,7 @@ export function extractOptionFacts(input) {
287
386
  found: false,
288
387
  headerIndex: -1,
289
388
  descriptionConstraint: false,
389
+ comparative: [],
290
390
  };
291
391
  if (headerCandidates.length === 0 || source.length === 0)
292
392
  return empty;
@@ -356,6 +456,8 @@ export function extractOptionFacts(input) {
356
456
  }
357
457
  const tradeoffs = [];
358
458
  const constraints = [];
459
+ /** The comparisons that could not be attributed to one option. */
460
+ const comparisons = [];
359
461
  /** Remember a fact, as a constraint when it states a restriction. */
360
462
  const recordFact = (value) => {
361
463
  if (statesConstraint(value)) {
@@ -366,29 +468,70 @@ export function extractOptionFacts(input) {
366
468
  tradeoffs.push(value);
367
469
  }
368
470
  };
471
+ /**
472
+ * A statement that names more than one option is a comparison, and it is
473
+ * never dropped: the comparison is kept with the option it constrains.
474
+ *
475
+ * The comparison says which option that is when a connective contrasts
476
+ * the options ("Unlike A, B must ..."). A comparison without such a
477
+ * connective is about the options it names, so it is kept with every one
478
+ * of them and reported, so that the reader knows that the subject of the
479
+ * comparison was not established.
480
+ */
481
+ const recordComparison = (value) => {
482
+ const window = value.slice(0, MENTION_WINDOW_CHARS);
483
+ const subject = comparativeSubjectAnchor(window, [
484
+ ...mentionAnchors,
485
+ ...otherMentionAnchors,
486
+ ]);
487
+ if (subject.length > 0) {
488
+ // The comparison constrains one option: it belongs to that one
489
+ // and to no other.
490
+ if (!mentionAnchors.includes(subject))
491
+ return;
492
+ recordFact(value);
493
+ return;
494
+ }
495
+ // The comparison is shared: it is kept with every option it names.
496
+ if (!mentionsAny(window, mentionAnchors))
497
+ return;
498
+ recordFact(value);
499
+ if (!comparisons.includes(value))
500
+ comparisons.push(value);
501
+ };
369
502
  /**
370
503
  * A fact of the section of the option belongs to it by position: the
371
504
  * section writes about that option, and a paragraph that names it with
372
505
  * a pronoun ("it must actually connect") is still about it. A paragraph
373
- * that names another option belongs to that one.
506
+ * that names another option is a comparison, and it is kept with the
507
+ * option it constrains.
374
508
  */
375
509
  const addSectionFact = (text) => {
376
510
  const value = stripMarkdown(text);
377
511
  if (value.length === 0)
378
512
  return;
379
513
  if (mentionsAny(value.slice(0, MENTION_WINDOW_CHARS), otherMentionAnchors)) {
514
+ recordComparison(value);
380
515
  return;
381
516
  }
382
517
  recordFact(value);
383
518
  };
384
519
  /**
385
520
  * A fact from outside the section has to name the option, and it must
386
- * not name another one: "Caveat for B: ..." is about B.
521
+ * not name another one: "Caveat for B: ..." is about B. A fact that names
522
+ * two options is a comparison, and it is kept with the option it
523
+ * constrains.
387
524
  */
388
525
  const addNamedFact = (text) => {
389
526
  const value = stripMarkdown(text);
390
527
  if (value.length === 0)
391
528
  return;
529
+ const window = value.slice(0, MENTION_WINDOW_CHARS);
530
+ if (mentionsAny(window, mentionAnchors) &&
531
+ mentionsAny(window, otherMentionAnchors)) {
532
+ recordComparison(value);
533
+ return;
534
+ }
392
535
  if (!belongsToOption(value, mentionAnchors, otherMentionAnchors))
393
536
  return;
394
537
  recordFact(value);
@@ -398,10 +541,13 @@ export function extractOptionFacts(input) {
398
541
  addSectionFact(paragraph.text);
399
542
  }
400
543
  // A caveat that names the option belongs to the option, even when it
401
- // stands outside the section: "Caveat for B: ..." is about B.
544
+ // stands outside the section: "Caveat for B: ..." is about B. The
545
+ // question of the choice is not a caveat of an option.
402
546
  for (const [paragraphIndex, paragraph] of paragraphs.entries()) {
403
547
  if (covered.has(paragraphIndex))
404
548
  continue;
549
+ if (isQuestionParagraph(paragraph.text, question))
550
+ continue;
405
551
  addNamedFact(paragraph.text);
406
552
  }
407
553
  return {
@@ -411,6 +557,7 @@ export function extractOptionFacts(input) {
411
557
  found: description.length > 0,
412
558
  headerIndex,
413
559
  descriptionConstraint: statesConstraint(description),
560
+ comparative: comparisons,
414
561
  };
415
562
  }
416
563
  /**
@@ -566,6 +713,12 @@ export function buildChoiceDecisionContext(input) {
566
713
  if (extracted.headerIndex >= 0) {
567
714
  claimed.add(extracted.headerIndex);
568
715
  }
716
+ // A comparison that the source does not attach to one option stays
717
+ // visible: the evaluation knows that the alternatives were compared
718
+ // and that the subject of the comparison was not established.
719
+ for (const comparison of extracted.comparative) {
720
+ uncertainties.push(`${id} (${label}): a statement compares the alternatives and its subject was not established: ${comparison.slice(0, MAX_OPTION_FACT_CHARS)}`);
721
+ }
569
722
  let description = suppliedDescription.length > 0
570
723
  ? suppliedDescription
571
724
  : extracted.description;