pi-harness-runtime 1.1.505 → 1.1.507
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.
- package/CHANGELOG.md +163 -0
- package/harness/provider-quota-reset.ts +125 -0
- package/harness/provider-recovery-runtime.ts +77 -2
- package/harness/quota-capture.ts +150 -0
- package/harness/quota-low-remaining.ts +75 -0
- package/harness/quota-reset-duration.ts +87 -0
- package/harness/quota-threshold.ts +117 -0
- package/harness/resume-scope.ts +85 -0
- package/harness/scope-expansion.ts +438 -0
- package/index.ts +213 -4
- package/mirror.ts +4 -0
- package/package.json +1 -1
- package/packages/agent-policy/package.json +1 -1
- package/packages/auth/package.json +1 -1
- package/packages/autonomous-runtime/package.json +1 -1
- package/packages/checkpoint/package.json +1 -1
- package/packages/clipboard/package.json +1 -1
- package/packages/codex-watcher/package.json +1 -1
- package/packages/config-capture/package.json +1 -1
- package/packages/contracts/package.json +1 -1
- package/packages/cookie-sanitizer/package.json +1 -1
- package/packages/evaluation-engine/package.json +1 -1
- package/packages/event-bus/package.json +1 -1
- package/packages/event-store/package.json +1 -1
- package/packages/experience-replay/package.json +1 -1
- package/packages/file-copy-helper/package.json +1 -1
- package/packages/intent-analyzer/package.json +1 -1
- package/packages/jev-judge/package.json +1 -1
- package/packages/knowledge-retrieval/package.json +1 -1
- package/packages/learning-engine/package.json +1 -1
- package/packages/logging/package.json +1 -1
- package/packages/memory-engine/package.json +1 -1
- package/packages/notification/dist/adapters/detail-format.d.ts +5 -2
- package/packages/notification/dist/adapters/detail-format.d.ts.map +1 -1
- package/packages/notification/dist/adapters/detail-format.js +17 -0
- package/packages/notification/dist/adapters/detail-format.js.map +1 -1
- package/packages/notification/dist/adapters/email-adapter.d.ts.map +1 -1
- package/packages/notification/dist/adapters/email-adapter.js +1 -0
- package/packages/notification/dist/adapters/email-adapter.js.map +1 -1
- package/packages/notification/dist/adapters/line-adapter.d.ts.map +1 -1
- package/packages/notification/dist/adapters/line-adapter.js +1 -0
- package/packages/notification/dist/adapters/line-adapter.js.map +1 -1
- package/packages/notification/dist/adapters/ntfy-adapter.d.ts.map +1 -1
- package/packages/notification/dist/adapters/ntfy-adapter.js +1 -0
- package/packages/notification/dist/adapters/ntfy-adapter.js.map +1 -1
- package/packages/notification/dist/adapters/telegram-adapter.d.ts.map +1 -1
- package/packages/notification/dist/adapters/telegram-adapter.js +1 -0
- package/packages/notification/dist/adapters/telegram-adapter.js.map +1 -1
- package/packages/notification/dist/notification-center.d.ts.map +1 -1
- package/packages/notification/dist/notification-center.js +10 -0
- package/packages/notification/dist/notification-center.js.map +1 -1
- package/packages/notification/dist/types.d.ts +14 -1
- package/packages/notification/dist/types.d.ts.map +1 -1
- package/packages/notification/package.json +1 -1
- package/packages/notification/src/adapters/detail-format.ts +29 -2
- package/packages/notification/src/adapters/email-adapter.ts +1 -0
- package/packages/notification/src/adapters/line-adapter.ts +1 -0
- package/packages/notification/src/adapters/ntfy-adapter.ts +1 -0
- package/packages/notification/src/adapters/telegram-adapter.ts +1 -0
- package/packages/notification/src/notification-center.ts +14 -0
- package/packages/notification/src/types.ts +14 -0
- package/packages/paperclip-integration/package.json +1 -1
- package/packages/performance-optimizer/package.json +1 -1
- package/packages/privilege-broker/package.json +1 -1
- package/packages/prompt-compiler/package.json +1 -1
- package/packages/providers/package.json +1 -1
- package/packages/qdrant-skills/package.json +1 -1
- package/packages/quota-manager/package.json +1 -1
- package/packages/relay/package.json +1 -1
- package/packages/skill-mcp-client/package.json +1 -1
- package/packages/skills/package.json +1 -1
- package/packages/todo-bd-sync/package.json +1 -1
- package/packages/token-estimation/package.json +1 -1
- package/packages/tooling-preference/package.json +1 -1
- package/packages/trajectory/package.json +1 -1
- package/packages/tui/package.json +1 -1
- package/packages/two-phase-review/package.json +1 -1
- package/packages/types/package.json +1 -1
- package/packages/webmcp-tester/package.json +1 -1
- package/packages/wiki/package.json +1 -1
- package/packages/write-review/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,169 @@
|
|
|
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.507](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v1.1.448...v1.1.507) (2026-11-11)
|
|
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
|
+
* **harness:** the startup tells the user that the session keeps its issues with bd ([81d63c5](https://github.com/ManotLuijiu/pi-harness-runtime/commit/81d63c5dc2452b9f08001756866db80046a2532a))
|
|
14
|
+
* **honcho:** the memory service speaks the native MCP of Pi ([f9f740c](https://github.com/ManotLuijiu/pi-harness-runtime/commit/f9f740c12869bae4c4380afbe8c76e12388bb744))
|
|
15
|
+
* **jev:** one decision per question, bound to the question it was evaluated for ([03448aa](https://github.com/ManotLuijiu/pi-harness-runtime/commit/03448aaa17f2d0c3bcf644b0b1d5949727dfff8c))
|
|
16
|
+
* **jev:** the evaluation of a choice sees what the options mean ([f0c207e](https://github.com/ManotLuijiu/pi-harness-runtime/commit/f0c207e074701e6b7dab0965170ec39453d9d502))
|
|
17
|
+
* **jev:** the pending question carries the ask and the answer ([a792133](https://github.com/ManotLuijiu/pi-harness-runtime/commit/a792133e517fb8c12d3363e98942f3af30270f27))
|
|
18
|
+
* **jev:** the pending question counts down to the decision ([d0cc171](https://github.com/ManotLuijiu/pi-harness-runtime/commit/d0cc171223986b2d32c670b6c1c74712fe0a4ad8))
|
|
19
|
+
* **keys:** tell the user what to do about an exposed key file ([7031003](https://github.com/ManotLuijiu/pi-harness-runtime/commit/7031003574307351b7a8f28ee14159b58e17b793))
|
|
20
|
+
* **keys:** the key files are repaired when their permissions are unsafe ([e9c2c26](https://github.com/ManotLuijiu/pi-harness-runtime/commit/e9c2c26b287665b56ed749de269737e8403bb8af))
|
|
21
|
+
* **mcp:** the harness connects the registered servers when nobody else does ([7fef951](https://github.com/ManotLuijiu/pi-harness-runtime/commit/7fef95137ad4664df57f045cd91b7d233315b0bc))
|
|
22
|
+
* **merge:** a manual run can leave the merge to the pull request event ([b3d1950](https://github.com/ManotLuijiu/pi-harness-runtime/commit/b3d1950b5941c78ccd56951acdafd1d4afbe1bff))
|
|
23
|
+
* **phase:** the agent owns the todo list and the harness says so ([c489370](https://github.com/ManotLuijiu/pi-harness-runtime/commit/c489370bd7926aece8cb1a77aa20ca2d2672f1fb))
|
|
24
|
+
* **providers:** a shared registry of the pending automatic actions and a bounded recovery ([c5f955b](https://github.com/ManotLuijiu/pi-harness-runtime/commit/c5f955bc82adcb6999a89d5bc278fa87fccee022))
|
|
25
|
+
* **providers:** one failure has one executor, and the retry bridge is checked ([e73c4c7](https://github.com/ManotLuijiu/pi-harness-runtime/commit/e73c4c76ff20a9708083659bdcefe74870a84837))
|
|
26
|
+
* **quota:** a fresh capture and a low allowance decide the MiniMax recovery ([06d7b8e](https://github.com/ManotLuijiu/pi-harness-runtime/commit/06d7b8e971e0da58a344f75778c98edb442562bd))
|
|
27
|
+
* **recovery:** a MiniMax quota exhaustion waits for the captured reset plus ten minutes ([5af08a0](https://github.com/ManotLuijiu/pi-harness-runtime/commit/5af08a0e86c8c93fa5b7ff64a7b08e4514bc68f3))
|
|
28
|
+
* **review:** the review starts on its own when the implementation is done ([04f51f5](https://github.com/ManotLuijiu/pi-harness-runtime/commit/04f51f599cd3222b6c74dd8fadb1373bd72d9bd7))
|
|
29
|
+
* **status:** the status line names the phase, the progress and the children ([0167bf3](https://github.com/ManotLuijiu/pi-harness-runtime/commit/0167bf396a0b987c1d44f3b869351976a951dd65))
|
|
30
|
+
* **test:** the task waits for the final tier of the validation plan ([fa147db](https://github.com/ManotLuijiu/pi-harness-runtime/commit/fa147dbf7d50d56e6ea48c6d8fbb4fcb190caf8a))
|
|
31
|
+
* **validation:** a large job starts with a measured pilot ([425964b](https://github.com/ManotLuijiu/pi-harness-runtime/commit/425964b04a3d4fa02adfabed47ff62c5ec2b9c28))
|
|
32
|
+
* **validation:** the size of a job is a fact, not a phrase ([8aa6c11](https://github.com/ManotLuijiu/pi-harness-runtime/commit/8aa6c119565d0f8412dc8aeafa6b295d47d3f093))
|
|
33
|
+
* **workspace:** a Frappe bench names the mode of the workspace ([9d58517](https://github.com/ManotLuijiu/pi-harness-runtime/commit/9d585172063a330992fee933316e268ae9985e3c))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### Bug Fixes
|
|
37
|
+
|
|
38
|
+
* **ci:** every run of a required check counts, and the worst one decides ([da9e0da](https://github.com/ManotLuijiu/pi-harness-runtime/commit/da9e0da6b0ca29cb320764fd5fc1b8a8dee8b1e0))
|
|
39
|
+
* **ci:** the newest attempt of a run decides, not the attempt that failed ([9d7adcc](https://github.com/ManotLuijiu/pi-harness-runtime/commit/9d7adcc31cbacc517c3c1a9bcd3956be94c908ef))
|
|
40
|
+
* **harness:** a raw control byte hid the request scope from the review ([852b1ff](https://github.com/ManotLuijiu/pi-harness-runtime/commit/852b1ff3afc21adb71e92b85d21ff1c88e14816a))
|
|
41
|
+
* **honcho:** a handshake that never finishes is named instead of hanging the startup ([d66005f](https://github.com/ManotLuijiu/pi-harness-runtime/commit/d66005f928a4f8df5de5b8a0579cbd4f8df37ff9))
|
|
42
|
+
* **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))
|
|
43
|
+
* **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))
|
|
44
|
+
* **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))
|
|
45
|
+
* **honcho:** the report names the state of the MCP server, not the registration ([762f4d5](https://github.com/ManotLuijiu/pi-harness-runtime/commit/762f4d59e4eabcab9a1c21a61aa522c3267621b3))
|
|
46
|
+
* **hooks:** a tag is checked through the commit behind it ([c823e8e](https://github.com/ManotLuijiu/pi-harness-runtime/commit/c823e8e1f6973c62b5449a97c101759a4d5cbba5))
|
|
47
|
+
* **jev:** a completion question, a stale check and a pending validation ([827120b](https://github.com/ManotLuijiu/pi-harness-runtime/commit/827120b4138b6f5ae253e69154de190085703de8))
|
|
48
|
+
* **jev:** a new request does not inherit the completion of the old one ([0f863c7](https://github.com/ManotLuijiu/pi-harness-runtime/commit/0f863c7fcaf35e261beabebef15b8ab634132fdc))
|
|
49
|
+
* **jev:** a prohibition must not hide a destructive action ([78a6cc1](https://github.com/ManotLuijiu/pi-harness-runtime/commit/78a6cc199e647f812e145483f7e94991358d8f34))
|
|
50
|
+
* **jev:** a refusal without punctuation, and only a decline of an action ([ef3dbf8](https://github.com/ManotLuijiu/pi-harness-runtime/commit/ef3dbf87a2a1725373281613a0d48881ed5d2239))
|
|
51
|
+
* **jev:** a rejection during the countdown pauses the work ([9b018ce](https://github.com/ManotLuijiu/pi-harness-runtime/commit/9b018ce1152b6724dee73cdc901b8a360ecc91ab))
|
|
52
|
+
* **jev:** a session switch ends the wait of the old session ([ca03d39](https://github.com/ManotLuijiu/pi-harness-runtime/commit/ca03d399c0d4a1b2dd428ac39836ab53c0e51ab6))
|
|
53
|
+
* **jev:** an open question is not a permission to answer it ([e20eca2](https://github.com/ManotLuijiu/pi-harness-runtime/commit/e20eca24bb88d385198bb12ee3ebf573af9aea86))
|
|
54
|
+
* **jev:** keep a comparative caveat with the option it constrains ([7be306b](https://github.com/ManotLuijiu/pi-harness-runtime/commit/7be306b0d0872713ebca9386d613ae5a8da9d5b6))
|
|
55
|
+
* **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))
|
|
56
|
+
* **jev:** the action of the question, and an open question blocks the work ([1f9ff39](https://github.com/ManotLuijiu/pi-harness-runtime/commit/1f9ff39efc4ee17464c54c2ca9b583245093dbac))
|
|
57
|
+
* **jev:** the alternatives of a question are parsed without a quadratic pattern ([63016a3](https://github.com/ManotLuijiu/pi-harness-runtime/commit/63016a3f0488acb801990dd46770c00d382b5858))
|
|
58
|
+
* **jev:** the countdown of an obsolete question does not outlive the work ([fe78b29](https://github.com/ManotLuijiu/pi-harness-runtime/commit/fe78b29e6fc513b11a6993bc68fd9418dc77f79b))
|
|
59
|
+
* **jev:** the facts of an option survive the wording of the agent ([5a6250c](https://github.com/ManotLuijiu/pi-harness-runtime/commit/5a6250c07aa8d965bc6ae242cccbf519477598f8))
|
|
60
|
+
* **jev:** the scope decides the question, the identity guards the awaits ([ed348b2](https://github.com/ManotLuijiu/pi-harness-runtime/commit/ed348b2f94460a3b3ac11c01afd4420ee4ec1020))
|
|
61
|
+
* **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))
|
|
62
|
+
* **jev:** the subject of the scope decides, a clarification is preserved ([faf6a0f](https://github.com/ManotLuijiu/pi-harness-runtime/commit/faf6a0fe7d0dce94d4fa48d0d7a57d126556ba6d))
|
|
63
|
+
* **keys:** the key directory is audited as a tree ([081cc75](https://github.com/ManotLuijiu/pi-harness-runtime/commit/081cc75ac8ceff36b0d619c3f76371dc08459d3c))
|
|
64
|
+
* **logging:** the sanitizer of a message writes its control characters as escapes ([f4bbdb9](https://github.com/ManotLuijiu/pi-harness-runtime/commit/f4bbdb94bc1801d4228142bc1a1b31505c42a575))
|
|
65
|
+
* **mcp:** the connector and the watcher stop with the session ([4d1b87d](https://github.com/ManotLuijiu/pi-harness-runtime/commit/4d1b87d14d015749025b62bf54d6d0b6137295f7))
|
|
66
|
+
* **mcp:** the connector survives a runtime that cannot list the servers ([d0f555f](https://github.com/ManotLuijiu/pi-harness-runtime/commit/d0f555fa14f51de33591e572a41ded5b59a3e4dd))
|
|
67
|
+
* **merge:** the boolean input is read as a boolean ([971b716](https://github.com/ManotLuijiu/pi-harness-runtime/commit/971b7169a43db382dbdeb6bb9bab02ab56e0351c))
|
|
68
|
+
* **merge:** the manual job needs the right of the merge ([7ba685e](https://github.com/ManotLuijiu/pi-harness-runtime/commit/7ba685ec43d815f90aa35b742579e87e76c69209))
|
|
69
|
+
* **merge:** the merge of the pull request is the GraphQL mutation ([972bab4](https://github.com/ManotLuijiu/pi-harness-runtime/commit/972bab4b0f7faf1b0047f3bb767ef6db3de4b2fa))
|
|
70
|
+
* **merge:** the workflow merges the pull request the gates cleared ([d7639ec](https://github.com/ManotLuijiu/pi-harness-runtime/commit/d7639ec9b83723510acb4a5c4e23d5d6167c3af6))
|
|
71
|
+
* **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))
|
|
72
|
+
* **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))
|
|
73
|
+
* **recovery:** a cancelled countdown does not own the next attempt ([7b79f30](https://github.com/ManotLuijiu/pi-harness-runtime/commit/7b79f301389fae48201e696d3086d257ed722fb9))
|
|
74
|
+
* **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))
|
|
75
|
+
* **recovery:** a manual request takes the work back from the countdown ([fa81d8f](https://github.com/ManotLuijiu/pi-harness-runtime/commit/fa81d8fd9d6160166a095e07bdf17049bbafa32d))
|
|
76
|
+
* **recovery:** the predicate of Pi decides the retry, the provider identity is normalized ([6c8c17b](https://github.com/ManotLuijiu/pi-harness-runtime/commit/6c8c17b53302cea1602d192251eacd0ebbd3e8c9))
|
|
77
|
+
* **release:** a manual release keeps the version of its manifest ([122e661](https://github.com/ManotLuijiu/pi-harness-runtime/commit/122e661ea48cb8aff14c71dbd0221a4cf0ba4c8e))
|
|
78
|
+
* **release:** the alignment names the reason of a failure ([5814dd0](https://github.com/ManotLuijiu/pi-harness-runtime/commit/5814dd0b780f5839cf8011ed0cbbbb31e7eb0418))
|
|
79
|
+
* **release:** the channels of the package name the release ([a7a273f](https://github.com/ManotLuijiu/pi-harness-runtime/commit/a7a273ffe8398e2b5b07ef1c321777de41792c6e))
|
|
80
|
+
* **release:** the release publishes and leaves the channels alone ([5871746](https://github.com/ManotLuijiu/pi-harness-runtime/commit/5871746589c1281d855dbeb591b02419fa43f22e))
|
|
81
|
+
* **release:** the release pull request names the version of its branch ([a846e83](https://github.com/ManotLuijiu/pi-harness-runtime/commit/a846e83e6de6e529f4bca05e869db0b5eebb37c5))
|
|
82
|
+
* **release:** the release scans the tree of the commit it publishes ([7d47a0b](https://github.com/ManotLuijiu/pi-harness-runtime/commit/7d47a0b5406480a1e1d3a52623a76aabd1e2d0ba))
|
|
83
|
+
* **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))
|
|
84
|
+
* **workspace:** keep a client name out of the comment about the search depth ([b572e0a](https://github.com/ManotLuijiu/pi-harness-runtime/commit/b572e0af16ff562203bda2b5c47b41807cff5a95))
|
|
85
|
+
* **workspace:** the repository names the mode before the mode stays unknown ([188a32c](https://github.com/ManotLuijiu/pi-harness-runtime/commit/188a32c7a6af1465dd24714278fccc73d06f6477))
|
|
86
|
+
|
|
87
|
+
### [1.1.506](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v1.1.448...v1.1.506) (2026-11-11)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
### Features
|
|
91
|
+
|
|
92
|
+
* **actions:** register the job resume, the GLM countdown and the queued continuations ([177c964](https://github.com/ManotLuijiu/pi-harness-runtime/commit/177c964555b0057e6bc7d293dafab10c95eabbf9))
|
|
93
|
+
* **delegation:** a child is only a child when it really ran ([ac4e678](https://github.com/ManotLuijiu/pi-harness-runtime/commit/ac4e6782d7d4bc4941e458425c8a9f38a51fc9d4))
|
|
94
|
+
* **delegation:** the scope of a request is measured before it is judged ([684b6a5](https://github.com/ManotLuijiu/pi-harness-runtime/commit/684b6a55184f63d3be24c48dcecfb0b13410dc15))
|
|
95
|
+
* **harness:** the startup tells the user that the session keeps its issues with bd ([81d63c5](https://github.com/ManotLuijiu/pi-harness-runtime/commit/81d63c5dc2452b9f08001756866db80046a2532a))
|
|
96
|
+
* **honcho:** the memory service speaks the native MCP of Pi ([f9f740c](https://github.com/ManotLuijiu/pi-harness-runtime/commit/f9f740c12869bae4c4380afbe8c76e12388bb744))
|
|
97
|
+
* **jev:** one decision per question, bound to the question it was evaluated for ([03448aa](https://github.com/ManotLuijiu/pi-harness-runtime/commit/03448aaa17f2d0c3bcf644b0b1d5949727dfff8c))
|
|
98
|
+
* **jev:** the evaluation of a choice sees what the options mean ([f0c207e](https://github.com/ManotLuijiu/pi-harness-runtime/commit/f0c207e074701e6b7dab0965170ec39453d9d502))
|
|
99
|
+
* **jev:** the pending question carries the ask and the answer ([a792133](https://github.com/ManotLuijiu/pi-harness-runtime/commit/a792133e517fb8c12d3363e98942f3af30270f27))
|
|
100
|
+
* **jev:** the pending question counts down to the decision ([d0cc171](https://github.com/ManotLuijiu/pi-harness-runtime/commit/d0cc171223986b2d32c670b6c1c74712fe0a4ad8))
|
|
101
|
+
* **keys:** tell the user what to do about an exposed key file ([7031003](https://github.com/ManotLuijiu/pi-harness-runtime/commit/7031003574307351b7a8f28ee14159b58e17b793))
|
|
102
|
+
* **keys:** the key files are repaired when their permissions are unsafe ([e9c2c26](https://github.com/ManotLuijiu/pi-harness-runtime/commit/e9c2c26b287665b56ed749de269737e8403bb8af))
|
|
103
|
+
* **mcp:** the harness connects the registered servers when nobody else does ([7fef951](https://github.com/ManotLuijiu/pi-harness-runtime/commit/7fef95137ad4664df57f045cd91b7d233315b0bc))
|
|
104
|
+
* **merge:** a manual run can leave the merge to the pull request event ([b3d1950](https://github.com/ManotLuijiu/pi-harness-runtime/commit/b3d1950b5941c78ccd56951acdafd1d4afbe1bff))
|
|
105
|
+
* **phase:** the agent owns the todo list and the harness says so ([c489370](https://github.com/ManotLuijiu/pi-harness-runtime/commit/c489370bd7926aece8cb1a77aa20ca2d2672f1fb))
|
|
106
|
+
* **providers:** a shared registry of the pending automatic actions and a bounded recovery ([c5f955b](https://github.com/ManotLuijiu/pi-harness-runtime/commit/c5f955bc82adcb6999a89d5bc278fa87fccee022))
|
|
107
|
+
* **providers:** one failure has one executor, and the retry bridge is checked ([e73c4c7](https://github.com/ManotLuijiu/pi-harness-runtime/commit/e73c4c76ff20a9708083659bdcefe74870a84837))
|
|
108
|
+
* **recovery:** a MiniMax quota exhaustion waits for the captured reset plus ten minutes ([5af08a0](https://github.com/ManotLuijiu/pi-harness-runtime/commit/5af08a0e86c8c93fa5b7ff64a7b08e4514bc68f3))
|
|
109
|
+
* **review:** the review starts on its own when the implementation is done ([04f51f5](https://github.com/ManotLuijiu/pi-harness-runtime/commit/04f51f599cd3222b6c74dd8fadb1373bd72d9bd7))
|
|
110
|
+
* **status:** the status line names the phase, the progress and the children ([0167bf3](https://github.com/ManotLuijiu/pi-harness-runtime/commit/0167bf396a0b987c1d44f3b869351976a951dd65))
|
|
111
|
+
* **test:** the task waits for the final tier of the validation plan ([fa147db](https://github.com/ManotLuijiu/pi-harness-runtime/commit/fa147dbf7d50d56e6ea48c6d8fbb4fcb190caf8a))
|
|
112
|
+
* **validation:** a large job starts with a measured pilot ([425964b](https://github.com/ManotLuijiu/pi-harness-runtime/commit/425964b04a3d4fa02adfabed47ff62c5ec2b9c28))
|
|
113
|
+
* **validation:** the size of a job is a fact, not a phrase ([8aa6c11](https://github.com/ManotLuijiu/pi-harness-runtime/commit/8aa6c119565d0f8412dc8aeafa6b295d47d3f093))
|
|
114
|
+
* **workspace:** a Frappe bench names the mode of the workspace ([9d58517](https://github.com/ManotLuijiu/pi-harness-runtime/commit/9d585172063a330992fee933316e268ae9985e3c))
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
### Bug Fixes
|
|
118
|
+
|
|
119
|
+
* **ci:** every run of a required check counts, and the worst one decides ([da9e0da](https://github.com/ManotLuijiu/pi-harness-runtime/commit/da9e0da6b0ca29cb320764fd5fc1b8a8dee8b1e0))
|
|
120
|
+
* **ci:** the newest attempt of a run decides, not the attempt that failed ([9d7adcc](https://github.com/ManotLuijiu/pi-harness-runtime/commit/9d7adcc31cbacc517c3c1a9bcd3956be94c908ef))
|
|
121
|
+
* **harness:** a raw control byte hid the request scope from the review ([852b1ff](https://github.com/ManotLuijiu/pi-harness-runtime/commit/852b1ff3afc21adb71e92b85d21ff1c88e14816a))
|
|
122
|
+
* **honcho:** a handshake that never finishes is named instead of hanging the startup ([d66005f](https://github.com/ManotLuijiu/pi-harness-runtime/commit/d66005f928a4f8df5de5b8a0579cbd4f8df37ff9))
|
|
123
|
+
* **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))
|
|
124
|
+
* **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))
|
|
125
|
+
* **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))
|
|
126
|
+
* **honcho:** the report names the state of the MCP server, not the registration ([762f4d5](https://github.com/ManotLuijiu/pi-harness-runtime/commit/762f4d59e4eabcab9a1c21a61aa522c3267621b3))
|
|
127
|
+
* **hooks:** a tag is checked through the commit behind it ([c823e8e](https://github.com/ManotLuijiu/pi-harness-runtime/commit/c823e8e1f6973c62b5449a97c101759a4d5cbba5))
|
|
128
|
+
* **jev:** a completion question, a stale check and a pending validation ([827120b](https://github.com/ManotLuijiu/pi-harness-runtime/commit/827120b4138b6f5ae253e69154de190085703de8))
|
|
129
|
+
* **jev:** a new request does not inherit the completion of the old one ([0f863c7](https://github.com/ManotLuijiu/pi-harness-runtime/commit/0f863c7fcaf35e261beabebef15b8ab634132fdc))
|
|
130
|
+
* **jev:** a prohibition must not hide a destructive action ([78a6cc1](https://github.com/ManotLuijiu/pi-harness-runtime/commit/78a6cc199e647f812e145483f7e94991358d8f34))
|
|
131
|
+
* **jev:** a refusal without punctuation, and only a decline of an action ([ef3dbf8](https://github.com/ManotLuijiu/pi-harness-runtime/commit/ef3dbf87a2a1725373281613a0d48881ed5d2239))
|
|
132
|
+
* **jev:** a rejection during the countdown pauses the work ([9b018ce](https://github.com/ManotLuijiu/pi-harness-runtime/commit/9b018ce1152b6724dee73cdc901b8a360ecc91ab))
|
|
133
|
+
* **jev:** a session switch ends the wait of the old session ([ca03d39](https://github.com/ManotLuijiu/pi-harness-runtime/commit/ca03d399c0d4a1b2dd428ac39836ab53c0e51ab6))
|
|
134
|
+
* **jev:** an open question is not a permission to answer it ([e20eca2](https://github.com/ManotLuijiu/pi-harness-runtime/commit/e20eca24bb88d385198bb12ee3ebf573af9aea86))
|
|
135
|
+
* **jev:** keep a comparative caveat with the option it constrains ([7be306b](https://github.com/ManotLuijiu/pi-harness-runtime/commit/7be306b0d0872713ebca9386d613ae5a8da9d5b6))
|
|
136
|
+
* **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))
|
|
137
|
+
* **jev:** the action of the question, and an open question blocks the work ([1f9ff39](https://github.com/ManotLuijiu/pi-harness-runtime/commit/1f9ff39efc4ee17464c54c2ca9b583245093dbac))
|
|
138
|
+
* **jev:** the alternatives of a question are parsed without a quadratic pattern ([63016a3](https://github.com/ManotLuijiu/pi-harness-runtime/commit/63016a3f0488acb801990dd46770c00d382b5858))
|
|
139
|
+
* **jev:** the countdown of an obsolete question does not outlive the work ([fe78b29](https://github.com/ManotLuijiu/pi-harness-runtime/commit/fe78b29e6fc513b11a6993bc68fd9418dc77f79b))
|
|
140
|
+
* **jev:** the facts of an option survive the wording of the agent ([5a6250c](https://github.com/ManotLuijiu/pi-harness-runtime/commit/5a6250c07aa8d965bc6ae242cccbf519477598f8))
|
|
141
|
+
* **jev:** the scope decides the question, the identity guards the awaits ([ed348b2](https://github.com/ManotLuijiu/pi-harness-runtime/commit/ed348b2f94460a3b3ac11c01afd4420ee4ec1020))
|
|
142
|
+
* **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))
|
|
143
|
+
* **jev:** the subject of the scope decides, a clarification is preserved ([faf6a0f](https://github.com/ManotLuijiu/pi-harness-runtime/commit/faf6a0fe7d0dce94d4fa48d0d7a57d126556ba6d))
|
|
144
|
+
* **keys:** the key directory is audited as a tree ([081cc75](https://github.com/ManotLuijiu/pi-harness-runtime/commit/081cc75ac8ceff36b0d619c3f76371dc08459d3c))
|
|
145
|
+
* **logging:** the sanitizer of a message writes its control characters as escapes ([f4bbdb9](https://github.com/ManotLuijiu/pi-harness-runtime/commit/f4bbdb94bc1801d4228142bc1a1b31505c42a575))
|
|
146
|
+
* **mcp:** the connector and the watcher stop with the session ([4d1b87d](https://github.com/ManotLuijiu/pi-harness-runtime/commit/4d1b87d14d015749025b62bf54d6d0b6137295f7))
|
|
147
|
+
* **mcp:** the connector survives a runtime that cannot list the servers ([d0f555f](https://github.com/ManotLuijiu/pi-harness-runtime/commit/d0f555fa14f51de33591e572a41ded5b59a3e4dd))
|
|
148
|
+
* **merge:** the boolean input is read as a boolean ([971b716](https://github.com/ManotLuijiu/pi-harness-runtime/commit/971b7169a43db382dbdeb6bb9bab02ab56e0351c))
|
|
149
|
+
* **merge:** the manual job needs the right of the merge ([7ba685e](https://github.com/ManotLuijiu/pi-harness-runtime/commit/7ba685ec43d815f90aa35b742579e87e76c69209))
|
|
150
|
+
* **merge:** the merge of the pull request is the GraphQL mutation ([972bab4](https://github.com/ManotLuijiu/pi-harness-runtime/commit/972bab4b0f7faf1b0047f3bb767ef6db3de4b2fa))
|
|
151
|
+
* **merge:** the workflow merges the pull request the gates cleared ([d7639ec](https://github.com/ManotLuijiu/pi-harness-runtime/commit/d7639ec9b83723510acb4a5c4e23d5d6167c3af6))
|
|
152
|
+
* **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))
|
|
153
|
+
* **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))
|
|
154
|
+
* **recovery:** a cancelled countdown does not own the next attempt ([7b79f30](https://github.com/ManotLuijiu/pi-harness-runtime/commit/7b79f301389fae48201e696d3086d257ed722fb9))
|
|
155
|
+
* **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))
|
|
156
|
+
* **recovery:** a manual request takes the work back from the countdown ([fa81d8f](https://github.com/ManotLuijiu/pi-harness-runtime/commit/fa81d8fd9d6160166a095e07bdf17049bbafa32d))
|
|
157
|
+
* **recovery:** the predicate of Pi decides the retry, the provider identity is normalized ([6c8c17b](https://github.com/ManotLuijiu/pi-harness-runtime/commit/6c8c17b53302cea1602d192251eacd0ebbd3e8c9))
|
|
158
|
+
* **release:** a manual release keeps the version of its manifest ([122e661](https://github.com/ManotLuijiu/pi-harness-runtime/commit/122e661ea48cb8aff14c71dbd0221a4cf0ba4c8e))
|
|
159
|
+
* **release:** the alignment names the reason of a failure ([5814dd0](https://github.com/ManotLuijiu/pi-harness-runtime/commit/5814dd0b780f5839cf8011ed0cbbbb31e7eb0418))
|
|
160
|
+
* **release:** the channels of the package name the release ([a7a273f](https://github.com/ManotLuijiu/pi-harness-runtime/commit/a7a273ffe8398e2b5b07ef1c321777de41792c6e))
|
|
161
|
+
* **release:** the release publishes and leaves the channels alone ([5871746](https://github.com/ManotLuijiu/pi-harness-runtime/commit/5871746589c1281d855dbeb591b02419fa43f22e))
|
|
162
|
+
* **release:** the release pull request names the version of its branch ([a846e83](https://github.com/ManotLuijiu/pi-harness-runtime/commit/a846e83e6de6e529f4bca05e869db0b5eebb37c5))
|
|
163
|
+
* **release:** the release scans the tree of the commit it publishes ([7d47a0b](https://github.com/ManotLuijiu/pi-harness-runtime/commit/7d47a0b5406480a1e1d3a52623a76aabd1e2d0ba))
|
|
164
|
+
* **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))
|
|
165
|
+
* **workspace:** keep a client name out of the comment about the search depth ([b572e0a](https://github.com/ManotLuijiu/pi-harness-runtime/commit/b572e0af16ff562203bda2b5c47b41807cff5a95))
|
|
166
|
+
* **workspace:** the repository names the mode before the mode stays unknown ([188a32c](https://github.com/ManotLuijiu/pi-harness-runtime/commit/188a32c7a6af1465dd24714278fccc73d06f6477))
|
|
167
|
+
|
|
5
168
|
### [1.1.505](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v1.1.448...v1.1.505) (2026-11-10)
|
|
6
169
|
|
|
7
170
|
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import type { ProviderMirrorRecord } from "../mirror.ts";
|
|
2
|
+
import type { ProviderFailure } from "./provider-failure.ts";
|
|
3
|
+
import {
|
|
4
|
+
MAX_RESET_EVIDENCE_AGE_MS,
|
|
5
|
+
normalizeProviderIdentity,
|
|
6
|
+
type RecoveryResetEvidence,
|
|
7
|
+
} from "./provider-recovery.ts";
|
|
8
|
+
import { decideQuotaReset, quotaWindowState } from "./quota-threshold.ts";
|
|
9
|
+
|
|
10
|
+
/** Give the quota service time to settle before probing it again. */
|
|
11
|
+
export const QUOTA_RESET_BUFFER_MS = 10 * 60_000;
|
|
12
|
+
|
|
13
|
+
/** The name of a quota window of the provider. */
|
|
14
|
+
type QuotaWindowName = "h5" | "weekly";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A failed request plus fresh quota can identify a reset even when the
|
|
18
|
+
* provider's generic error does not name its window.
|
|
19
|
+
*
|
|
20
|
+
* A window that is empty decides on its own: the account is blocked until
|
|
21
|
+
* it resets, and the bounded cycle cannot change that. A window that is
|
|
22
|
+
* nearly empty - below ten percent of the allowance - decides as well,
|
|
23
|
+
* when its reset is more than an hour away. A reset that arrives sooner is
|
|
24
|
+
* reached by the bounded cycle, and the cycle keeps the failure.
|
|
25
|
+
*
|
|
26
|
+
* The percentages of the mirror are the used percentages; the policy is
|
|
27
|
+
* stated in the remaining percentage, and the conversion is in
|
|
28
|
+
* `quota-threshold.ts`.
|
|
29
|
+
*
|
|
30
|
+
* The selector reads the capture that the harness already has. It never
|
|
31
|
+
* scrapes again and never parses the text of the console: a capture that is
|
|
32
|
+
* not fresh, not complete or not for this provider proves nothing.
|
|
33
|
+
*/
|
|
34
|
+
export function confirmedQuotaReset(
|
|
35
|
+
failure: ProviderFailure,
|
|
36
|
+
provider: string,
|
|
37
|
+
mirror: ProviderMirrorRecord | null | undefined,
|
|
38
|
+
now: number,
|
|
39
|
+
): RecoveryResetEvidence | undefined {
|
|
40
|
+
if (failure.kind !== "usage-exhausted" && failure.kind !== "rate-limit") {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
if (
|
|
44
|
+
!mirror ||
|
|
45
|
+
normalizeProviderIdentity(mirror.provider) !==
|
|
46
|
+
normalizeProviderIdentity(provider)
|
|
47
|
+
) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
const observedAt = Date.parse(mirror.synced_at);
|
|
51
|
+
if (
|
|
52
|
+
!Number.isFinite(observedAt) ||
|
|
53
|
+
observedAt > now ||
|
|
54
|
+
now - observedAt > MAX_RESET_EVIDENCE_AGE_MS
|
|
55
|
+
) {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
const windows: {
|
|
59
|
+
window: QuotaWindowName;
|
|
60
|
+
used: number | undefined;
|
|
61
|
+
resetAt: number | undefined;
|
|
62
|
+
}[] = [
|
|
63
|
+
{
|
|
64
|
+
window: "h5",
|
|
65
|
+
used: mirror.h5_used_pct,
|
|
66
|
+
resetAt: mirror.h5_resets_at_epoch,
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
window: "weekly",
|
|
70
|
+
used: mirror.weekly_used_pct,
|
|
71
|
+
resetAt: mirror.weekly_resets_at_epoch,
|
|
72
|
+
},
|
|
73
|
+
];
|
|
74
|
+
// An empty window blocks the account until it resets.
|
|
75
|
+
const exhausted = windows.filter(
|
|
76
|
+
({ used }) => quotaWindowState(used) === "exhausted",
|
|
77
|
+
);
|
|
78
|
+
if (exhausted.length > 0) {
|
|
79
|
+
// If an exhausted window has no usable reset, another window cannot
|
|
80
|
+
// establish when the account becomes usable. Keep bounded recovery.
|
|
81
|
+
let latest: { window: QuotaWindowName; resetAt: number } | undefined;
|
|
82
|
+
for (const { window, resetAt } of exhausted) {
|
|
83
|
+
if (
|
|
84
|
+
typeof resetAt !== "number" ||
|
|
85
|
+
!Number.isFinite(resetAt) ||
|
|
86
|
+
resetAt <= now
|
|
87
|
+
) {
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
if (!latest || resetAt > latest.resetAt) latest = { window, resetAt };
|
|
91
|
+
}
|
|
92
|
+
if (!latest) return undefined;
|
|
93
|
+
return {
|
|
94
|
+
provider: normalizeProviderIdentity(provider),
|
|
95
|
+
window: latest.window,
|
|
96
|
+
resetAt: latest.resetAt,
|
|
97
|
+
observedAt,
|
|
98
|
+
source: mirror.source,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// No window is empty. A window that is nearly empty decides, when its
|
|
103
|
+
// reset is far enough away: a reset that arrives within the hour is
|
|
104
|
+
// reached by the bounded cycle of the failure.
|
|
105
|
+
const low = windows.filter(({ used }) => quotaWindowState(used) === "low");
|
|
106
|
+
let latestLow: { window: QuotaWindowName; resetAt: number } | undefined;
|
|
107
|
+
for (const { window, used, resetAt } of low) {
|
|
108
|
+
if (decideQuotaReset({ usedPct: used, resetAt, now }) !== "reset") {
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (typeof resetAt !== "number" || !Number.isFinite(resetAt)) continue;
|
|
112
|
+
if (!latestLow || resetAt > latestLow.resetAt) {
|
|
113
|
+
latestLow = { window, resetAt };
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (!latestLow) return undefined;
|
|
117
|
+
|
|
118
|
+
return {
|
|
119
|
+
provider: normalizeProviderIdentity(provider),
|
|
120
|
+
window: latestLow.window,
|
|
121
|
+
resetAt: latestLow.resetAt,
|
|
122
|
+
observedAt,
|
|
123
|
+
source: mirror.source,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
@@ -34,6 +34,8 @@ import type {
|
|
|
34
34
|
ProviderRecoveryController,
|
|
35
35
|
RecoveryResetEvidence,
|
|
36
36
|
} from "./provider-recovery.ts";
|
|
37
|
+
import { MAX_RESET_EVIDENCE_AGE_MS, normalizeProviderIdentity } from "./provider-recovery.ts";
|
|
38
|
+
import { QUOTA_RESET_BUFFER_MS } from "./provider-quota-reset.ts";
|
|
37
39
|
|
|
38
40
|
/**
|
|
39
41
|
* The state of the session, read when a resume would run.
|
|
@@ -158,6 +160,8 @@ export interface ProviderRecoveryRuntimeOptions {
|
|
|
158
160
|
clearTimeout?: (handle: unknown) => void;
|
|
159
161
|
/** The reset evidence of the provider, when the harness observed one. */
|
|
160
162
|
resetEvidence?: (failure: ProviderFailure) => RecoveryResetEvidence | undefined;
|
|
163
|
+
/** Fresh evidence that quota is fully consumed, including for generic 2067 errors. */
|
|
164
|
+
quotaResetEvidence?: (failure: ProviderFailure, provider: string) => RecoveryResetEvidence | undefined;
|
|
161
165
|
/** The number of attempts the cycle allows. */
|
|
162
166
|
maxAttempts: number;
|
|
163
167
|
/** The wait of the overload executor, in milliseconds. */
|
|
@@ -222,6 +226,26 @@ export class ProviderRecoveryRuntime {
|
|
|
222
226
|
};
|
|
223
227
|
}
|
|
224
228
|
|
|
229
|
+
/**
|
|
230
|
+
* The failure that waits for the settled boundary.
|
|
231
|
+
*
|
|
232
|
+
* The caller reads it to prepare what the recovery needs before it
|
|
233
|
+
* picks a deadline - a fresh quota capture, for example. Reading it
|
|
234
|
+
* changes nothing: the candidate stays where it is until the run
|
|
235
|
+
* settles.
|
|
236
|
+
*/
|
|
237
|
+
pendingQuotaFailure(): { provider: string; kind: string } | null {
|
|
238
|
+
const candidate = this.candidate;
|
|
239
|
+
if (!candidate) return null;
|
|
240
|
+
if (
|
|
241
|
+
candidate.failure.kind !== "usage-exhausted" &&
|
|
242
|
+
candidate.failure.kind !== "rate-limit"
|
|
243
|
+
) {
|
|
244
|
+
return null;
|
|
245
|
+
}
|
|
246
|
+
return { provider: candidate.provider, kind: candidate.failure.kind };
|
|
247
|
+
}
|
|
248
|
+
|
|
225
249
|
/**
|
|
226
250
|
* The run settled.
|
|
227
251
|
*
|
|
@@ -354,6 +378,9 @@ export class ProviderRecoveryRuntime {
|
|
|
354
378
|
private startRecovery(candidate: ProviderFailureCandidate): void {
|
|
355
379
|
const { failure, failureKey, provider } = candidate;
|
|
356
380
|
const sessionId = this.options.context().sessionId;
|
|
381
|
+
// A real quota reset is a different wait from a transient retry.
|
|
382
|
+
// It remains available even after the four short retries were used.
|
|
383
|
+
if (this.scheduleQuotaReset(candidate, sessionId)) return;
|
|
357
384
|
const outcome = this.options.controller.noteFailure(
|
|
358
385
|
{
|
|
359
386
|
failureKey,
|
|
@@ -372,7 +399,7 @@ export class ProviderRecoveryRuntime {
|
|
|
372
399
|
this.log(
|
|
373
400
|
`Provider recovery attempt ${outcome.attempt}/${this.maxAttempts} at ${new Date(outcome.dueAt).toISOString()} (bound=${outcome.boundBy})`,
|
|
374
401
|
);
|
|
375
|
-
this.scheduleAttempt(outcome.dueAt, outcome.attempt,
|
|
402
|
+
this.scheduleAttempt(outcome.dueAt, outcome.attempt, candidate, sessionId);
|
|
376
403
|
return;
|
|
377
404
|
}
|
|
378
405
|
|
|
@@ -389,6 +416,50 @@ export class ProviderRecoveryRuntime {
|
|
|
389
416
|
);
|
|
390
417
|
}
|
|
391
418
|
|
|
419
|
+
private scheduleQuotaReset(candidate: ProviderFailureCandidate, sessionId: string): boolean {
|
|
420
|
+
const { failure, provider } = candidate;
|
|
421
|
+
if (failure.kind !== "usage-exhausted" && failure.kind !== "rate-limit") return false;
|
|
422
|
+
const evidence = this.options.quotaResetEvidence?.(failure, provider);
|
|
423
|
+
const now = this.now();
|
|
424
|
+
if (!evidence || normalizeProviderIdentity(evidence.provider) !== normalizeProviderIdentity(provider) ||
|
|
425
|
+
!Number.isFinite(evidence.resetAt) || evidence.resetAt <= now ||
|
|
426
|
+
!Number.isFinite(evidence.observedAt) || evidence.observedAt > now ||
|
|
427
|
+
now - evidence.observedAt > MAX_RESET_EVIDENCE_AGE_MS) return false;
|
|
428
|
+
const dueAt = Math.max(evidence.resetAt + QUOTA_RESET_BUFFER_MS, now + (failure.retryAfterMs ?? 0));
|
|
429
|
+
this.cancelRecoveryAttempt();
|
|
430
|
+
this.options.controller.invalidatePending({ sessionId });
|
|
431
|
+
this.options.actions.remove(this.options.blockedActionId);
|
|
432
|
+
this.options.actions.register({
|
|
433
|
+
id: this.options.recoveryActionId,
|
|
434
|
+
sessionId,
|
|
435
|
+
owner: "provider-recovery",
|
|
436
|
+
kind: "retry",
|
|
437
|
+
state: "scheduled",
|
|
438
|
+
dueAt,
|
|
439
|
+
provider,
|
|
440
|
+
...(failure.code ? { code: failure.code } : {}),
|
|
441
|
+
reason: `${evidence.window} quota exhausted; waiting for reset + 10m`,
|
|
442
|
+
});
|
|
443
|
+
this.log(`Provider quota reset wait until ${new Date(dueAt).toISOString()} (${evidence.window})`);
|
|
444
|
+
const arm = () => {
|
|
445
|
+
// Node timers longer than roughly 24 days otherwise fire immediately.
|
|
446
|
+
this.recoveryTimer = this.setTimer(() => {
|
|
447
|
+
if (this.now() < dueAt) { arm(); return; }
|
|
448
|
+
this.recoveryTimer = null;
|
|
449
|
+
this.options.actions.remove(this.options.recoveryActionId);
|
|
450
|
+
if (!mayDispatchResume({ scheduledSessionId: sessionId, current: this.options.context() }).allowed) return;
|
|
451
|
+
// A newly observed exhausted window may have a later reset.
|
|
452
|
+
if (this.scheduleQuotaReset(candidate, sessionId)) return;
|
|
453
|
+
// The reset itself does not prove success. Give the request a
|
|
454
|
+
// fresh bounded budget if it still fails after this one probe.
|
|
455
|
+
this.options.controller.cancel({ sessionId, provider });
|
|
456
|
+
this.dispatchIfOwned(sessionId, "provider-recovery");
|
|
457
|
+
}, Math.min(2_147_483_647, Math.max(0, dueAt - this.now())));
|
|
458
|
+
};
|
|
459
|
+
arm();
|
|
460
|
+
return true;
|
|
461
|
+
}
|
|
462
|
+
|
|
392
463
|
/**
|
|
393
464
|
* The number of attempts the cycle allows.
|
|
394
465
|
*/
|
|
@@ -419,9 +490,10 @@ export class ProviderRecoveryRuntime {
|
|
|
419
490
|
private scheduleAttempt(
|
|
420
491
|
dueAt: number,
|
|
421
492
|
attempt: number,
|
|
422
|
-
|
|
493
|
+
candidate: ProviderFailureCandidate,
|
|
423
494
|
sessionId: string,
|
|
424
495
|
): void {
|
|
496
|
+
const { failure } = candidate;
|
|
425
497
|
this.cancelRecoveryAttempt();
|
|
426
498
|
this.options.actions.register({
|
|
427
499
|
id: this.options.recoveryActionId,
|
|
@@ -442,6 +514,9 @@ export class ProviderRecoveryRuntime {
|
|
|
442
514
|
// The row leaves when the attempt runs: a countdown must not stay
|
|
443
515
|
// at 00:00.
|
|
444
516
|
this.options.actions.remove(this.options.recoveryActionId);
|
|
517
|
+
if (!mayDispatchResume({ scheduledSessionId: sessionId, current: this.options.context() }).allowed) return;
|
|
518
|
+
// Quota may have become exhausted while a short retry counted down.
|
|
519
|
+
if (this.scheduleQuotaReset(candidate, sessionId)) return;
|
|
445
520
|
this.dispatchIfOwned(sessionId, "provider-recovery");
|
|
446
521
|
}, delayMs);
|
|
447
522
|
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The quota capture that a provider recovery needs.
|
|
3
|
+
*
|
|
4
|
+
* The recovery decides when to continue from a capture of the quota, and
|
|
5
|
+
* the row of the mirror can be hours old. A capture that is forced before
|
|
6
|
+
* the decision refreshes that row.
|
|
7
|
+
*
|
|
8
|
+
* The capture is the one of the harness: it refreshes the mirror and
|
|
9
|
+
* nothing else. It never charges an attempt of the recovery and it never
|
|
10
|
+
* schedules anything.
|
|
11
|
+
*
|
|
12
|
+
* A capture that failed is remembered as a failure: the row of the mirror
|
|
13
|
+
* is the old one then, and an old row cannot prove a deadline.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/** The time a capture of the same failure may be reused. */
|
|
17
|
+
export const QUOTA_CAPTURE_REUSE_MS = 2 * 60_000;
|
|
18
|
+
|
|
19
|
+
/** The time the recovery waits for the capture. */
|
|
20
|
+
export const QUOTA_CAPTURE_WAIT_MS = 15_000;
|
|
21
|
+
|
|
22
|
+
/** What the last capture did. */
|
|
23
|
+
export interface QuotaCaptureOutcome {
|
|
24
|
+
/** The provider the capture was about. */
|
|
25
|
+
provider: string;
|
|
26
|
+
/** Did the capture work? */
|
|
27
|
+
ok: boolean;
|
|
28
|
+
/** When the capture ended. */
|
|
29
|
+
at: number;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** The dependencies of the controller. */
|
|
33
|
+
export interface QuotaCaptureOptions {
|
|
34
|
+
/**
|
|
35
|
+
* Capture the quota of a provider.
|
|
36
|
+
*
|
|
37
|
+
* The result says whether the capture worked. A capture that throws is
|
|
38
|
+
* a failed capture, not a crash of the harness.
|
|
39
|
+
*/
|
|
40
|
+
capture(provider: string): Promise<boolean>;
|
|
41
|
+
/** The clock of the controller. */
|
|
42
|
+
now?(): number;
|
|
43
|
+
/** The log of the controller. */
|
|
44
|
+
log?(message: string): void;
|
|
45
|
+
/** The time the recovery waits for the capture. */
|
|
46
|
+
waitMs?: number;
|
|
47
|
+
/** The time a capture of the same failure may be reused. */
|
|
48
|
+
reuseMs?: number;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The capture of the quota of a provider failure.
|
|
53
|
+
*
|
|
54
|
+
* One capture at a time: the browser of the harness is not a resource that
|
|
55
|
+
* is spent twice for one failure.
|
|
56
|
+
*/
|
|
57
|
+
export class QuotaCaptureController {
|
|
58
|
+
private readonly options: QuotaCaptureOptions;
|
|
59
|
+
private readonly now: () => number;
|
|
60
|
+
private readonly waitMs: number;
|
|
61
|
+
private readonly reuseMs: number;
|
|
62
|
+
private pending: {
|
|
63
|
+
provider: string;
|
|
64
|
+
promise: Promise<boolean>;
|
|
65
|
+
startedAt: number;
|
|
66
|
+
} | null = null;
|
|
67
|
+
private last: QuotaCaptureOutcome | null = null;
|
|
68
|
+
|
|
69
|
+
constructor(options: QuotaCaptureOptions) {
|
|
70
|
+
this.options = options;
|
|
71
|
+
this.now = options.now ?? (() => Date.now());
|
|
72
|
+
this.waitMs = options.waitMs ?? QUOTA_CAPTURE_WAIT_MS;
|
|
73
|
+
this.reuseMs = options.reuseMs ?? QUOTA_CAPTURE_REUSE_MS;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** The outcome of the last capture. */
|
|
77
|
+
get outcome(): QuotaCaptureOutcome | null {
|
|
78
|
+
return this.last;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Did the last capture of this provider fail?
|
|
83
|
+
*
|
|
84
|
+
* A failed capture means that the row of the mirror is the old one, so
|
|
85
|
+
* it cannot prove a deadline.
|
|
86
|
+
*/
|
|
87
|
+
failed(provider: string): boolean {
|
|
88
|
+
const outcome = this.last;
|
|
89
|
+
if (!outcome) return false;
|
|
90
|
+
return outcome.provider === provider.toLowerCase() && !outcome.ok;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Start the capture of a quota failure.
|
|
95
|
+
*
|
|
96
|
+
* A capture that is running for the same provider is not started again,
|
|
97
|
+
* and a capture that ended recently is not repeated: its row is fresh
|
|
98
|
+
* enough for the decision.
|
|
99
|
+
*/
|
|
100
|
+
begin(provider: string): void {
|
|
101
|
+
const key = provider.toLowerCase();
|
|
102
|
+
const current = this.pending;
|
|
103
|
+
if (
|
|
104
|
+
current &&
|
|
105
|
+
current.provider === key &&
|
|
106
|
+
current.startedAt > this.now() - this.reuseMs
|
|
107
|
+
) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const promise = (async () => {
|
|
111
|
+
try {
|
|
112
|
+
const ok = await this.options.capture(key);
|
|
113
|
+
this.last = { provider: key, ok, at: this.now() };
|
|
114
|
+
return ok;
|
|
115
|
+
} catch (error) {
|
|
116
|
+
this.options.log?.(
|
|
117
|
+
`The forced quota capture of ${key} failed: ${
|
|
118
|
+
error instanceof Error ? error.message : String(error)
|
|
119
|
+
}`,
|
|
120
|
+
);
|
|
121
|
+
this.last = { provider: key, ok: false, at: this.now() };
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
})();
|
|
125
|
+
this.pending = { provider: key, promise, startedAt: this.now() };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Wait for the capture, within a bound.
|
|
130
|
+
*
|
|
131
|
+
* A capture that takes too long is given up: the recovery keeps the
|
|
132
|
+
* bounded cycle, and the capture that finishes later only refreshes
|
|
133
|
+
* the mirror.
|
|
134
|
+
*/
|
|
135
|
+
async wait(): Promise<void> {
|
|
136
|
+
const current = this.pending;
|
|
137
|
+
if (!current) return;
|
|
138
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
139
|
+
try {
|
|
140
|
+
await Promise.race([
|
|
141
|
+
current.promise,
|
|
142
|
+
new Promise<void>((resolve) => {
|
|
143
|
+
timer = setTimeout(resolve, this.waitMs);
|
|
144
|
+
}),
|
|
145
|
+
]);
|
|
146
|
+
} finally {
|
|
147
|
+
if (timer) clearTimeout(timer);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|