bailinghub 0.9.2 → 0.9.3
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/README.en.md +6 -6
- package/README.md +6 -6
- package/docker-compose.images.yml +2 -2
- package/docs/CHANGELOG.en.md +12 -1
- package/docs/CHANGELOG.md +12 -1
- package/docs/CORE_RELIABILITY.en.md +22 -2
- package/docs/CORE_RELIABILITY.md +22 -2
- package/docs/IMPLEMENTATION_STATUS.en.md +19 -15
- package/docs/IMPLEMENTATION_STATUS.md +19 -15
- package/docs/INDEPENDENT_VALIDATION.en.md +4 -4
- package/docs/INDEPENDENT_VALIDATION.md +4 -4
- package/docs/OPERATIONS.en.md +13 -0
- package/docs/OPERATIONS.md +12 -0
- package/docs/README.en.md +3 -1
- package/docs/README.md +3 -1
- package/docs/RELEASE_NOTES_v0.9.3.en.md +51 -0
- package/docs/RELEASE_NOTES_v0.9.3.md +51 -0
- package/docs/TOOLS_DESIGN.md +1 -0
- package/docs/UPGRADE_v0.9.3.en.md +63 -0
- package/docs/UPGRADE_v0.9.3.md +63 -0
- package/package.json +1 -1
- package/scripts/check-doc-links.mjs +2 -0
- package/scripts/check-image-tags.sh +1 -1
- package/scripts/check-release-consistency.test.mjs +2 -2
- package/scripts/install.sh +1 -1
- package/scripts/publish-images.sh +1 -1
- package/scripts/release-audit.mjs +4 -0
- package/scripts/verify-github-repo.mjs +4 -0
- package/security/dependency-audit-exceptions.json +1 -1
- package/sql/067_delivery_dlq_replay.sql +10 -0
- package/sql/README.en.md +6 -0
- package/sql/README.md +6 -0
- package/src/adapters/llm/file.test.ts +59 -0
- package/src/adapters/llm/file.ts +11 -4
- package/src/app/agent-tool-invocations.test.ts +3 -1
- package/src/app/approval-continuations.test.ts +27 -1
- package/src/app/approval-continuations.ts +44 -3
- package/src/app/channels-attachments.test.ts +63 -0
- package/src/app/channels.ts +7 -4
- package/src/app/delivery-dlq-replay.mysql.test.ts +139 -0
- package/src/app/delivery-dlq-replay.test.ts +75 -0
- package/src/app/delivery-dlq-replay.ts +41 -0
- package/src/app/delivery.ts +3 -2
- package/src/app/kernel-notification-lifecycle.test.ts +49 -0
- package/src/app/kernel.ts +9 -0
- package/src/app/notification-outbound.test.ts +53 -0
- package/src/app/operational-metrics.test.ts +37 -1
- package/src/app/operational-metrics.ts +25 -2
- package/src/app/outbound.ts +13 -2
- package/src/app/runtime-lifecycle.test.ts +89 -0
- package/src/app/runtime-lifecycle.ts +20 -18
- package/src/app/tool-approvals.ts +2 -1
- package/src/core/contracts/delivery-replay.ts +41 -0
- package/src/core/contracts/tools-idempotency.test.ts +121 -5
- package/src/core/contracts/tools.ts +21 -11
- package/src/core/contracts/types.ts +2 -0
- package/src/core/observability/openmetrics.test.ts +28 -0
- package/src/core/observability/openmetrics.ts +91 -0
- package/src/core/platform/http-body.test.ts +185 -0
- package/src/core/platform/http-body.ts +58 -0
- package/src/core/runtime/finish-runtime.test.ts +2 -0
- package/src/core/runtime/finish-runtime.ts +10 -7
- package/src/core/runtime/notification-background-work.test.ts +50 -0
- package/src/core/runtime/notification-background-work.ts +101 -0
- package/src/core/state/delivery-replay.ts +19 -0
- package/src/core/state/state-codec.ts +1 -0
- package/src/core/state/state-contracts.ts +3 -0
- package/src/infrastructure/config/config-delivery-dlq-ledger.ts +36 -10
- package/src/infrastructure/config/configstore.ts +2 -1
- package/src/infrastructure/state/state-jsonl.ts +16 -1
- package/src/infrastructure/state/state-mysql.ts +27 -0
- package/src/modules/usage/background-work.test.ts +28 -0
- package/src/modules/usage/background-work.ts +43 -7
- package/src/modules/usage/billing-reconciliation.test.ts +16 -2
- package/src/modules/usage/billing-repository.ts +9 -0
- package/src/modules/usage/maintenance.test.ts +18 -2
- package/src/modules/usage/maintenance.ts +8 -0
- package/src/routes/admin-runtime.ts +14 -0
package/docs/README.en.md
CHANGED
|
@@ -7,9 +7,11 @@ This directory contains public documentation for the open-source BailingHub proj
|
|
|
7
7
|
| Document | Purpose |
|
|
8
8
|
|---|---|
|
|
9
9
|
| [IMPLEMENTATION_STATUS.en.md](IMPLEMENTATION_STATUS.en.md) · [Chinese](IMPLEMENTATION_STATUS.md) | Core ownership, formal releases versus main, public evidence, and uncovered scope. |
|
|
10
|
+
| [RELEASE_NOTES_v0.9.3.en.md](RELEASE_NOTES_v0.9.3.en.md) · [Chinese](RELEASE_NOTES_v0.9.3.md) | v0.9.3: bounded bodies, graceful notification close and original-notification DLQ replay, with maintenance metrics. |
|
|
11
|
+
| [UPGRADE_v0.9.3.en.md](UPGRADE_v0.9.3.en.md) · [Chinese](UPGRADE_v0.9.3.md) | Explicit migration 067, matching DLQ/state adapters, rollback manifests and preserved markers. |
|
|
10
12
|
| [RELEASE_NOTES_v0.9.2.en.md](RELEASE_NOTES_v0.9.2.en.md) · [Chinese](RELEASE_NOTES_v0.9.2.md) | v0.9.2: secure installation, automatic settlement and original approval continuation, with deployment diagnostics and process tests. |
|
|
11
13
|
| [UPGRADE_v0.9.2.en.md](UPGRADE_v0.9.2.en.md) · [Chinese](UPGRADE_v0.9.2.md) | Explicit migrations 065/066, matching adapters, original-record checks and rollback limits. |
|
|
12
|
-
| [CORE_RELIABILITY.en.md](CORE_RELIABILITY.en.md) · [Chinese](CORE_RELIABILITY.md) | Installation credentials,
|
|
14
|
+
| [CORE_RELIABILITY.en.md](CORE_RELIABILITY.en.md) · [Chinese](CORE_RELIABILITY.md) | Installation credentials, settlement/approval continuation, bounded bodies, notification close/replay and synthetic acceptance boundaries. |
|
|
13
15
|
| [RELEASE_NOTES_v0.9.1.en.md](RELEASE_NOTES_v0.9.1.en.md) · [Chinese](RELEASE_NOTES_v0.9.1.md) | v0.9.1: asynchronous usage shutdown fix, public capability index, and general security governance. |
|
|
14
16
|
| [UPGRADE_v0.9.1.en.md](UPGRADE_v0.9.1.en.md) · [Chinese](UPGRADE_v0.9.1.md) | 0.9.0 patch upgrade, original requests, artifact manifests, and shutdown acceptance; no new SQL/APIs. |
|
|
15
17
|
| [RELEASE_NOTES_v0.9.0.en.md](RELEASE_NOTES_v0.9.0.en.md) · [Chinese](RELEASE_NOTES_v0.9.0.md) | v0.9.0: optional model billing, shared allowances and image tools. |
|
package/docs/README.md
CHANGED
|
@@ -9,9 +9,11 @@
|
|
|
9
9
|
| 文档 | 用途 |
|
|
10
10
|
|---|---|
|
|
11
11
|
| [IMPLEMENTATION_STATUS.md](IMPLEMENTATION_STATUS.md) · [English](IMPLEMENTATION_STATUS.en.md) | Core 能力归属、正式发行与主分支状态、公开证据和未覆盖范围。 |
|
|
12
|
+
| [RELEASE_NOTES_v0.9.3.md](RELEASE_NOTES_v0.9.3.md) · [English](RELEASE_NOTES_v0.9.3.en.md) | v0.9.3:有限收包、通知关闭与原通知死信重投,含维护指标。 |
|
|
13
|
+
| [UPGRADE_v0.9.3.md](UPGRADE_v0.9.3.md) · [English](UPGRADE_v0.9.3.en.md) | 067 显式迁移、配套 DLQ/state 仓储、回退 manifest 与标记保留。 |
|
|
12
14
|
| [RELEASE_NOTES_v0.9.2.md](RELEASE_NOTES_v0.9.2.md) · [English](RELEASE_NOTES_v0.9.2.en.md) | v0.9.2:安全安装、自动结算与原审批补续,含部署诊断与进程回归。 |
|
|
13
15
|
| [UPGRADE_v0.9.2.md](UPGRADE_v0.9.2.md) · [English](UPGRADE_v0.9.2.en.md) | 065/066显式迁移、配套仓储、原记录核对及回退限制。 |
|
|
14
|
-
| [CORE_RELIABILITY.md](CORE_RELIABILITY.md) · [English](CORE_RELIABILITY.en.md) |
|
|
16
|
+
| [CORE_RELIABILITY.md](CORE_RELIABILITY.md) · [English](CORE_RELIABILITY.en.md) | 安装凭据、结算/审批补续、有限收包、通知关闭/重投与合成验收边界。 |
|
|
15
17
|
| [RELEASE_NOTES_v0.9.1.md](RELEASE_NOTES_v0.9.1.md) · [English](RELEASE_NOTES_v0.9.1.en.md) | v0.9.1:异步 usage 关闭修复、公开能力索引与通用安全治理。 |
|
|
16
18
|
| [UPGRADE_v0.9.1.md](UPGRADE_v0.9.1.md) · [English](UPGRADE_v0.9.1.en.md) | 0.9.0 补丁升级、原请求核对、制品 manifest 与关闭验收;无新增 SQL/API。 |
|
|
17
19
|
| [RELEASE_NOTES_v0.9.0.md](RELEASE_NOTES_v0.9.0.md) · [English](RELEASE_NOTES_v0.9.0.en.md) | v0.9.0:可选模型计费、统一套餐额度与文生图工具。 |
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# v0.9.3: bounded bodies and reliable notification shutdown
|
|
2
|
+
|
|
3
|
+
[简体中文](RELEASE_NOTES_v0.9.3.md)
|
|
4
|
+
|
|
5
|
+
Version date: 2026-10-14. A patch update from public Core 0.9.2.
|
|
6
|
+
|
|
7
|
+
Core previously buffered a complete oversized tool response or remote attachment before rejecting it. Graceful shutdown could release resources before callbacks, notifications or dead-letter records finished, and executor-notification replay could select a native channel incorrectly. BailingHub 0.9.3 fixes these boundaries and adds read-only visibility into existing maintenance.
|
|
8
|
+
|
|
9
|
+
## Fixes
|
|
10
|
+
|
|
11
|
+
### Enforce HTTP and attachment limits while reading
|
|
12
|
+
|
|
13
|
+
Business-tool HTTP bodies have a separate default **5 MiB** transport budget. Excessive `Content-Length` allows early rejection; absent or understated lengths and compressed responses still undergo chunk-by-chunk checks of actual fetch-decoded bytes. Overflow requests cancellation and discards partial contents. Model views default to **8 KiB** and audit payloads use **64 KiB**, now measured as UTF-8 bytes rather than character counts.
|
|
14
|
+
|
|
15
|
+
Remote files retain configured `max_bytes` (**20 MiB** by default), and channel attachments have a **20 MiB** download budget, both checked during reading. Download bounds do not guarantee archive-expansion or parser resource usage.
|
|
16
|
+
|
|
17
|
+
HTTP 200 headers and partial contents do not establish a completed write. A dispatched write with body loss or overflow retains its original Job / invocation, idempotency identity and unknown outcome without automatic redispatch.
|
|
18
|
+
|
|
19
|
+
### Drain actual notification work during graceful close
|
|
20
|
+
|
|
21
|
+
Each Kernel tracks actual callback, delivery, approval-webhook, alert and DLQ work, draining it before resource closure within the shared close budget. Accepted work can register child continuations. Standalone also waits for already-started maintenance producers after stopping timers. Timeouts retain same-instance work and dependencies for a later `close()` attempt.
|
|
22
|
+
|
|
23
|
+
This covers graceful shutdown; completing a drain does not mean every message was delivered. This release does not provide a durable outbox for all notification intents or promise complete HTTP notification recovery after SIGKILL.
|
|
24
|
+
|
|
25
|
+
### Replay the original executor notification child
|
|
26
|
+
|
|
27
|
+
Native channels retain native delivery. Executor DLQs verify kind, original child, recipient and content before requeueing that notification child, retaining full input and request/job identities without rerunning its business parent.
|
|
28
|
+
|
|
29
|
+
Admission and a permanent marker are saved atomically for the same DLQ. Concurrent retries, a lost admission acknowledgement or failed resolve cannot admit it again. `queued` acknowledges admission, not recipient receipt; a later failed execution creates a new DLQ that may be handled separately. Conflicting bindings fail explicitly. Unsupported custom adapters return unavailable rather than using the wrong channel. JSONL remains single-writer.
|
|
30
|
+
|
|
31
|
+
## Additional maintenance metrics
|
|
32
|
+
|
|
33
|
+
The existing optional `/metrics` endpoint adds in-flight work and oldest age, completed/failed totals, recent-run timestamps, drain state/timeouts, latest settlement/approval page progress and settlement backoff.
|
|
34
|
+
|
|
35
|
+
The maintenance collector reads owner-local memory without querying business details, triggering reconciliation or contacting models. Labels use fixed categories, excluding account, principal, job, payload and credential data. Counters reset with owner recreation. Latest-page progress is not persisted total backlog, and continuation completion is not a receipt acknowledgement. See [operations](OPERATIONS.en.md).
|
|
36
|
+
|
|
37
|
+
## Who should upgrade
|
|
38
|
+
|
|
39
|
+
- **Core operators** using business HTTP tools, remote attachments, notifications or DLQs should upgrade. Preserve configuration, data, queue state and rollback artifacts before explicitly applying 067.
|
|
40
|
+
- **Embedded and custom-adapter developers** retain fair `tick()` calls and `close(drainMs)`. Executor replay requires matching `ensureExecutorReplay`, `RuntimeStateStore.requeueDeliveryJobOnce` and atomic semantics.
|
|
41
|
+
- **Business-backend and client integrators** retain original invocation identities, business idempotency and final authorization, and check response download budgets. MCP / Agent Client SDK 0.7.0 and DSH 0.7.0 remain unchanged. ACC, clients and independent Hosts release and deploy separately, outside this Core patch.
|
|
42
|
+
|
|
43
|
+
## Upgrade, verify and understand limits
|
|
44
|
+
|
|
45
|
+
Since 0.9.2, `067_delivery_dlq_replay.sql` adds DLQ kind, original notification child/replay identity and a separate Job admission marker. Apply 067 through the official explicit migrator before all new Core MySQL DLQ reads/writes, including native-channel record/get; startup does not migrate automatically. Legacy rows are not bulk-classified by guesswork; replay verifies original jobs. See the [upgrade guide](UPGRADE_v0.9.3.en.md).
|
|
46
|
+
|
|
47
|
+
Public regressions cover bounded bodies, Unicode budgets, unknown write outcomes, graceful close, original notification replay and metrics isolation. Dedicated MySQL tests cover upgrading from 0.9.2, concurrent admission, acknowledgement exceptions after real COMMIT, failed resolve and store reopening. Notification tests check storage interruption boundaries, not actual process killing, live-channel receipt or production acceptance. See [reliability and regression entry points](CORE_RELIABILITY.en.md).
|
|
48
|
+
|
|
49
|
+
Dependency versions are unchanged. The existing exact Mammoth library-only audit exception still expires at **2026-11-09 00:00 UTC**, without broadening or renewal; this does not claim an advisory-free dependency audit.
|
|
50
|
+
|
|
51
|
+
[Upgrade guide](UPGRADE_v0.9.3.en.md) · [Full changelog](CHANGELOG.en.md) · [Capability and evidence index](IMPLEMENTATION_STATUS.en.md) · [Previous release](RELEASE_NOTES_v0.9.2.en.md)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# v0.9.3:有限收包与通知可靠收尾
|
|
2
|
+
|
|
3
|
+
[English](RELEASE_NOTES_v0.9.3.en.md)
|
|
4
|
+
|
|
5
|
+
版本日期:2026-10-14。相对公开 Core 0.9.2 的补丁更新。
|
|
6
|
+
|
|
7
|
+
业务工具返回过大正文,或远程附件超过限额时,Core 过去会先收完整包再拒绝。一次正常关闭也可能在回调、通知或死信记录完成前释放资源;执行器通知的死信重投则可能走错原生渠道。百灵中枢(BailingHub)0.9.3 修复这些边界,并让既有后台维护进度可被只读观察。
|
|
8
|
+
|
|
9
|
+
## 修复了什么
|
|
10
|
+
|
|
11
|
+
### 收包时执行 HTTP 与附件限额
|
|
12
|
+
|
|
13
|
+
业务工具 HTTP 正文新增独立的默认 **5 MiB** 传输预算。过大的 `Content-Length` 可以提前拒绝;缺少、低报长度或压缩响应仍按 fetch 解码后的实际字节逐块检查。超限请求取消下载,丢弃部分正文。模型回流默认 **8 KiB** 和审计载荷 **64 KiB** 的预算分别按 UTF-8 字节截断,不再把字符数当字节数。
|
|
14
|
+
|
|
15
|
+
远程文件沿用配置的 `max_bytes`(默认 **20 MiB**),渠道附件下载为 **20 MiB**,均在收包时检查。下载预算不保证压缩包展开或解析器的资源用量。
|
|
16
|
+
|
|
17
|
+
HTTP 200 响应头和部分正文不是已完成写入的证据。已尝试外发的写操作遇到正文超限或丢失时,继续保留原 Job / invocation、幂等标识和结果未知状态,不自动重发。
|
|
18
|
+
|
|
19
|
+
### 正常关闭等待通知的实际收尾
|
|
20
|
+
|
|
21
|
+
每个 Kernel 登记回调、送达派生、审批 webhook、告警和 DLQ 写入的实际工作,在释放资源前按共同关闭预算排空;已接受的工作可以登记后续子工作。standalone 停止定时器后也等待已开始的维护生产者。超时保留同实例工作和依赖,等待后可重试 `close()`。
|
|
22
|
+
|
|
23
|
+
这是正常关闭保证,完成排空不等于每条消息成功送达。本版未建立覆盖全部通知意图的持久 outbox,不能承诺 SIGKILL 后全部 HTTP 通知自动补投。
|
|
24
|
+
|
|
25
|
+
### 执行器死信重投原通知子任务
|
|
26
|
+
|
|
27
|
+
原生渠道仍使用原生送达。执行器通知死信先核对类型、原通知子任务、收件人和内容,再重排原通知子任务;保留其完整输入、request/job 标识,不能重跑业务父任务。
|
|
28
|
+
|
|
29
|
+
同一死信的入队和持久标记原子保存,并发请求、入队成功但确认丢失或 resolve 失败不会再次入队。返回 `queued` 只表示入队,不表示收件方已收到;再次执行失败形成的新死信可另行处理。绑定冲突明确失败,自定义仓储未配套时返回 unavailable,不降级到错误渠道。JSONL 仍只支持单 writer。
|
|
30
|
+
|
|
31
|
+
## 新增后台维护指标
|
|
32
|
+
|
|
33
|
+
既有可选 `/metrics` 端点新增后台在途数、最老在途年龄、完成/失败数、最近运行时间、排空状态与超时数,以及结算/审批最近一页进度和结算退避。
|
|
34
|
+
|
|
35
|
+
维护采集器只读 owner 内存,不查询业务明细、不触发核对或模型请求。标签仅使用固定类别,不包含账号、主体、任务、正文或凭据。计数随 owner 重建重置;最近一页进度不是持久积压总量,工作完成数不是收件方确认数。见[运维指标](OPERATIONS.md)。
|
|
36
|
+
|
|
37
|
+
## 谁需要升级
|
|
38
|
+
|
|
39
|
+
- **Core 管理员**:使用业务 HTTP 工具、远程附件、通知或 DLQ 的部署,建议升级;先保留配置、数据、队列和回滚制品,再显式应用 067。
|
|
40
|
+
- **嵌入式及自定义仓储开发者**:继续公平调用 `tick()` 和使用 `close(drainMs)`;执行器重投需配套 `ensureExecutorReplay`、`RuntimeStateStore.requeueDeliveryJobOnce` 及其原子语义。
|
|
41
|
+
- **业务后端及客户端接入方**:保留原调用标识、业务幂等和最终权限;确认工具正文符合下载预算。MCP / Agent Client SDK 0.7.0、DSH 0.7.0 不变。ACC、客户端和独立 Host 各自发行、部署,不包含在本次 Core 补丁中。
|
|
42
|
+
|
|
43
|
+
## 升级、验证与未覆盖范围
|
|
44
|
+
|
|
45
|
+
相对 0.9.2 新增 `067_delivery_dlq_replay.sql`,为 DLQ 保存类型、原通知子任务与重投标识,为 Job 保存独立入队标记。启动新 Core 的全部 MySQL DLQ 读写前必须使用官方显式迁移器应用 067,包括原生渠道 record/get;启动不自动迁移。旧数据不批量猜测类型,重投时核对原任务。见[升级指南](UPGRADE_v0.9.3.md)。
|
|
46
|
+
|
|
47
|
+
公开回归涵盖有限收包、Unicode 预算、未知写结果、正常关闭、原通知重投和指标隔离;专用 MySQL 专项覆盖从 0.9.2 升级、并发及真实 COMMIT 后的确认异常、resolve 失败和仓储重开。通知专项是仓储断点测试,不是实际杀进程、真实渠道送达或生产验收。见[可靠性契约与回归入口](CORE_RELIABILITY.md)。
|
|
48
|
+
|
|
49
|
+
依赖版本未更新。既有 Mammoth library-only 精确审计例外仍于 **2026-11-09 00:00 UTC** 到期,未扩大或续期;这不是全量依赖审计无告警的声明。
|
|
50
|
+
|
|
51
|
+
[升级指南](UPGRADE_v0.9.3.md) · [完整版本记录](CHANGELOG.md) · [能力与证据索引](IMPLEMENTATION_STATUS.md) · [上一版本](RELEASE_NOTES_v0.9.2.md)
|
package/docs/TOOLS_DESIGN.md
CHANGED
|
@@ -267,6 +267,7 @@ X-Bailing-Idempotency-Key: 副作用调用的稳定幂等键(只读/声明幂
|
|
|
267
267
|
|
|
268
268
|
- **签名只有一套:`sha256=`(算法名,非版本号)**。构造 = `sha256=` + `HMAC_SHA256(secret, "<ts>.<METHOD>.<path?query>.<sha256(body)>.<On-Behalf-Of>.<Job-Id>")`,把"谁、为哪个任务"也钉进 HMAC,杜绝窗口内重放篡头换租户/绕幂等。**spec 拉取共用同一套构造**(无操作主体/任务,三者签空串、GET body 也空),300s 时间窗。中枢只发 `sha256=`,`Verify` 与三份单文件参考(`docs/examples/bailing-tool-verify.{php,mjs,py}`)也只验 `sha256=`;
|
|
269
269
|
- 超时默认 10s(provider 的 `timeout_ms` 可配)。只读或显式声明幂等的调用可按路由重试策略重新执行;副作用调用不得把超时、断连或审计降级伪装成可安全重试;
|
|
270
|
+
- 业务工具 HTTP 响应另有固定 **5 MiB** 收包预算,与模型回流 **8 KiB**、审计字段 **64 KiB** 的 UTF-8 字节预算独立。先检查过大的 `Content-Length`,仍逐块累计 fetch 解压后的正文 bytes;缺失或低报长度不能绕过上限。超限立即请求取消正文,不接受部分正文作为成功证据;已尝试外发的写操作仍按原 Job / invocation 与幂等键对账,不自动补发。该上限属于 Core 运行时,没有新增 ACC 字段;
|
|
270
271
|
- **副作用执行日志**:对于非只读、非声明幂等的业务工具,中枢在外发前持久化 `dispatching`,收到 HTTP 响应后写 `response_recorded`,结果审计与终态账本都成功后才写 `completed`;
|
|
271
272
|
- **账本缺失即拒绝**:运行时没有持久化执行日志,或无法在外发前写入占位时,副作用工具直接拒绝且请求不会发出;不能退回“先调用、成功后再记”的旧模式;
|
|
272
273
|
- **不确定结果冻结**:超时、网络断连、进程重启后遗留的 `dispatching`、结果审计失败形成的 `evidence_degraded`,以及响应已记录但终态提交失败形成的 `response_recorded`,都会返回结构化 `reconciliation_required`,并明确 `auto_retry_allowed=false`。恢复任务会在调用模型前扫描未决执行日志;同一任务再次执行时不依赖模型重新选中该工具,也不会向业务系统外发第二次请求;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Core v0.9.3 patch upgrade guide
|
|
2
|
+
|
|
3
|
+
[简体中文](UPGRADE_v0.9.3.md)
|
|
4
|
+
|
|
5
|
+
Upgrade public Core 0.9.2 to 0.9.3 for bounded bodies, graceful notification shutdown and executor-DLQ replay, plus read-only maintenance metrics. This guide concerns Core only. MCP / Agent Client SDK and DSH remain at 0.7.0; ACC, clients and independent Hosts release and deploy through their own procedures.
|
|
6
|
+
|
|
7
|
+
## Preserve data and coordinate writers
|
|
8
|
+
|
|
9
|
+
Back up the target database. Retain configuration and credentials, attachments, original jobs/requests, approvals, dead letters, queues and previous artifacts. Stop new work, coordinate all writers sharing the state database, and reconcile in-flight notifications and delivered/unknown receipts before draining old instances.
|
|
10
|
+
|
|
11
|
+
Retain original Job, request, operation, invocation, approval decision and DLQ IDs. The new shutdown guarantee requires new code; an old instance closing does not prove that untracked notifications finished. After a drain timeout, retain same-instance resources and retry later rather than forcing store closure or blindly resending unknown messages.
|
|
12
|
+
|
|
13
|
+
## Select artifacts and migrate explicitly
|
|
14
|
+
|
|
15
|
+
Use formal `v0.9.3` source, npm packages or images. Verify Tag/commit, version and artifact digest. Installer and prebuilt-image Compose defaults become 0.9.3; existing `.env` files are preserved and dependency versions remain unchanged.
|
|
16
|
+
|
|
17
|
+
Apply outstanding files through the official explicit migrator. Source installations use:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm run db:init
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Embedded integrations use official `migrateBailingHubCoreSchema` and verify the complete `BAILINGHUB_CORE_ARTIFACT_V1` artifact manifest. Startup does not migrate. Recorded SQL is skipped; do not manually edit historical SQL or migration records.
|
|
24
|
+
|
|
25
|
+
| Migration added since 0.9.2 | Purpose |
|
|
26
|
+
| --- | --- |
|
|
27
|
+
| `067_delivery_dlq_replay.sql` | Add `delivery_kind`, `notification_job_id` and `executor_replay_key` to `bz_delivery_dlq`, plus `delivery_replay_keys` to `bz_jobs` for original notification binding and permanent admission markers |
|
|
28
|
+
|
|
29
|
+
067 preserves old data without bulk-guessing historical DLQ kinds. Replay verifies original jobs; ambiguous bindings fail explicitly. Apply 067 before all new Core MySQL DLQ reads/writes, including native-channel record/get. Earlier upgrades also apply all missing preceding migrations; see the [0.9.2 guide](UPGRADE_v0.9.2.en.md) for 065/066 support.
|
|
30
|
+
|
|
31
|
+
## Match adapters and callers
|
|
32
|
+
|
|
33
|
+
Upgrade official MySQL/JSONL state adapters together with the DLQ ledger. Custom ledgers supply optional `ensureExecutorReplay`; state adapters supply `RuntimeStateStore.requeueDeliveryJobOnce`, with original-binding checks, atomic admission/marker writes and marker preservation under ordinary updates. Unsupported executor replay returns `delivery_dlq_replay_unavailable`, without redirecting to a same-named native channel. JSONL remains single-writer.
|
|
34
|
+
|
|
35
|
+
Replay retains full original notification-child input, recipient and request/job identities; do not rerun its business parent to deliver a message. `queued` means queue admission. Verify execution and recipient receipt separately. Permanent markers prevent the same DLQ from admitting twice. A later failure creates a new operational DLQ record. Native channels gain no exactly-once guarantee across systems; reconcile partial or unknown receipts.
|
|
36
|
+
|
|
37
|
+
Managed integrations retain existing `tick()` and `close(drainMs)` calls. Close waits for accepted notification work and dynamic children within its shared budget. Observe fixed-category failure/timeout metrics without treating counts as business or receipt evidence.
|
|
38
|
+
|
|
39
|
+
## Verify the upgrade
|
|
40
|
+
|
|
41
|
+
1. Check new artifact identity, the target migration ledger and actual 067 columns. Verify `/health`, the console and existing smoke checks. Optionally run explicit read-only diagnostics:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npm run --silent doctor -- --deployment --url http://127.0.0.1:18900 --readiness --json
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
This performs no migration and does not establish image digest or complete database identity. Read exit codes and unchecked scope; see [deployment diagnostics](DEPLOYMENT_DIAGNOSTICS.en.md).
|
|
48
|
+
2. In isolation, check within-budget and oversized tool bodies/attachments, including absent/understated lengths and multibyte text. Overflow after a dispatched write retains the original unknown outcome; recovery must not dispatch another business write.
|
|
49
|
+
3. Replay a failed executor-notification DLQ and verify only its original child is admitted. Concurrent retries and lost acknowledgements cannot duplicate admission or rerun the business parent. Real recipient receipt requires separate acceptance.
|
|
50
|
+
4. Verify delayed callbacks, delivery creation and DLQ writes block resource closure. A timeout preserves resources and permits same-instance retry. This does not test full notification recovery after SIGKILL.
|
|
51
|
+
5. If protected `/metrics` is enabled, inspect fixed-category in-flight work, failures, recent-run age, drain timeouts and last-page progress. Scraping starts no maintenance or provider request; process-local counts are not persisted backlog.
|
|
52
|
+
|
|
53
|
+
See [Core reliability](CORE_RELIABILITY.en.md#core-v093-http-and-notification-fixes) for synthetic tests and dedicated MySQL regressions. Skips are not passes. Release acceptance does not replace target-environment deployment acceptance.
|
|
54
|
+
|
|
55
|
+
## Rollback boundary
|
|
56
|
+
|
|
57
|
+
067 is additive. A code rollback preserves DLQ kind/binding/replay identity, `delivery_replay_keys`, queues, original records and migration history. Never delete markers and resubmit. Stop related writers and reconcile admitted/in-flight notifications and recipient evidence before deciding on rollback.
|
|
58
|
+
|
|
59
|
+
**Old versions do not automatically accept the newer migration ledger.** An older complete schema manifest or migrator may fail closed on unknown 067 history. Additive columns do not mean old readiness or migration paths must pass. Verify the intended older artifact against the retained new schema/ledger in an isolated copy and define recovery; deleting migration rows to bypass checks is not an acceptable shortcut. Old code also loses this release's body, graceful-close and replay-deduplication guarantees.
|
|
60
|
+
|
|
61
|
+
Restoring an older backup requires reconciling business effects, receipt and charges since the backup. A database restore does not undo those external effects. Do not blindly resend unknown deliveries; business services retain their own idempotency and final authorization.
|
|
62
|
+
|
|
63
|
+
[Release notes](RELEASE_NOTES_v0.9.3.en.md) · [Reliability contract](CORE_RELIABILITY.en.md) · [Compatibility policy](COMPATIBILITY.en.md)
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Core v0.9.3 补丁升级指南
|
|
2
|
+
|
|
3
|
+
[English](UPGRADE_v0.9.3.en.md)
|
|
4
|
+
|
|
5
|
+
从公开 Core 0.9.2 升级到 0.9.3,修复有限收包、通知正常关闭与执行器死信重投,增加只读维护指标。本指南只涉及 Core;MCP / Agent Client SDK、DSH 仍为 0.7.0,ACC、客户端与独立 Host 按各自流程发行和部署。
|
|
6
|
+
|
|
7
|
+
## 保留数据并协调写入
|
|
8
|
+
|
|
9
|
+
备份目标数据库,保留配置与凭据、附件、原任务/请求、审批、死信、队列及旧制品。停止新工作并协调所有共用状态库的写入方,核对在途通知和已送达/未知送达记录,再排空关闭旧实例。
|
|
10
|
+
|
|
11
|
+
保留原 Job、request、operation、invocation、审批 decision 和死信 ID。新关闭保证需新代码参与;旧实例的关闭成功不证明尚未登记的通知已完成。关闭超时后保留同实例资源,等待后重试,不强制关库或盲目重发未知消息。
|
|
12
|
+
|
|
13
|
+
## 选择制品并显式迁移
|
|
14
|
+
|
|
15
|
+
选择正式 `v0.9.3` 源码、npm 包或镜像,核对 Tag/提交、版本和制品摘要。安装器、预构建镜像 Compose 默认版本同步为 0.9.3;已有 `.env` 保留,依赖版本不更新。
|
|
16
|
+
|
|
17
|
+
通过官方显式迁移器应用全部未执行文件。源码入口:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm run db:init
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
嵌入式使用官方 `migrateBailingHubCoreSchema` 显式入口;核对完整 `BAILINGHUB_CORE_ARTIFACT_V1` 制品 manifest。启动不自动迁移,已记账 SQL 跳过,不手工编辑历史 SQL 或迁移账本。
|
|
24
|
+
|
|
25
|
+
| 相对 0.9.2 新增迁移 | 作用 |
|
|
26
|
+
| --- | --- |
|
|
27
|
+
| `067_delivery_dlq_replay.sql` | 在 `bz_delivery_dlq` 增加 `delivery_kind`、`notification_job_id`、`executor_replay_key`;在 `bz_jobs` 增加 `delivery_replay_keys`,保存通知原记录与永久入队标记 |
|
|
28
|
+
|
|
29
|
+
067 不清除旧数据,不批量猜测历史死信类型。旧死信重投时由 Core 核对原任务;绑定不明时明确拒绝。启动新 Core 的全部 MySQL DLQ 读写前必须应用 067,包括原生渠道 record/get;从更早版本升级还须补全部前序迁移,065/066 配套见 [0.9.2 指南](UPGRADE_v0.9.2.md)。
|
|
30
|
+
|
|
31
|
+
## 配套仓储与调用方
|
|
32
|
+
|
|
33
|
+
官方 MySQL/JSONL 状态仓储及 DLQ ledger 一起升级。自定义 ledger 提供可选 `ensureExecutorReplay`,自定义状态仓提供 `RuntimeStateStore.requeueDeliveryJobOnce`,并保证核对原绑定、原子入队和标记、标记不被普通更新清除。未配套时执行器重投返回 `delivery_dlq_replay_unavailable`,不改发同名原生渠道。JSONL 仍仅支持单 writer。
|
|
34
|
+
|
|
35
|
+
重投保留原通知子任务的完整输入、收件人和 request/job 标识;不使用业务父任务重跑来补发。返回 `queued` 是队列准入,实际送达另看执行状态/收件方证据。同一死信的永久标记阻止重复入队;再次失败形成的新死信属于新的运营处理记录。原生渠道不新增跨系统恰好一次保证,部分或未知送达仍需核对。
|
|
36
|
+
|
|
37
|
+
保持 managed 的既有 `tick()` 与 `close(drainMs)`;关闭按共同预算等待已接受通知及动态子工作。通知失败和超时应观察固定类别指标,不能用计数代替业务或接收方证据。
|
|
38
|
+
|
|
39
|
+
## 升级验收
|
|
40
|
+
|
|
41
|
+
1. 核对新制品身份、目标库迁移账本与 067 实际字段,检查 `/health`、控制台和既有 smoke。可显式运行只读诊断:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npm run --silent doctor -- --deployment --url http://127.0.0.1:18900 --readiness --json
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
它不执行迁移或确认镜像摘要、完整数据库身份。读取退出码及未检查范围,见[部署诊断](DEPLOYMENT_DIAGNOSTICS.md)。
|
|
48
|
+
2. 在隔离环境检查限额内/超限工具正文与附件,包含缺少/低报长度和多字节文本。已外发写操作超限后保留原调用未知结果,恢复不得出现第二次业务派发。
|
|
49
|
+
3. 核对执行器通知失败产生的死信:一次重投仅将原通知子任务入队;并发/确认丢失重试不重复入队,也不重跑业务父任务。实际收件方送达另行验收。
|
|
50
|
+
4. 核对延迟回调、通知派生和 DLQ 写入阻挡资源关闭,排空超时保留资源且同实例重试成功。这不验证 SIGKILL 后全量通知补投。
|
|
51
|
+
5. 若启用受保护的 `/metrics`,检查固定类别的后台在途、失败、运行年龄、排空超时和最近一页进度。抓取不触发维护或供应商请求;进程计数不是持久积压量。
|
|
52
|
+
|
|
53
|
+
合成测试及专用 MySQL 回归入口见 [Core 可靠性](CORE_RELIABILITY.md#core-v093-的-http-与通知修复)。跳过不计通过,发行验收不代替目标环境的部署验收。
|
|
54
|
+
|
|
55
|
+
## 回退边界
|
|
56
|
+
|
|
57
|
+
067 是增量结构;代码回退保留死信类型/绑定/重投标识、`delivery_replay_keys`、队列、原记录及迁移账本,不能删除标记后重投。先停止相关写入,核对已准入和在途通知、收件方证据,再决定回退。
|
|
58
|
+
|
|
59
|
+
**旧版本不自动兼容新迁移账本。** 旧制品的完整 schema manifest 或迁移器可能因未知的 067 记录失败关闭;字段增量不等于旧 readiness/迁移入口必然通过。必须在隔离副本验证目标旧制品与保留的新 schema/账本组合,明确恢复方式,不能靠删除迁移记录绕过检查。回退旧代码也会失去本版收包、通知关闭及重投去重保证。
|
|
60
|
+
|
|
61
|
+
若恢复旧备份,核对备份后已经发生的业务、消息送达和账务;数据库恢复不撤销这些外部效果。未知送达不能盲目补发,业务方保留自己的幂等与最终授权。
|
|
62
|
+
|
|
63
|
+
[版本说明](RELEASE_NOTES_v0.9.3.md) · [可靠性契约](CORE_RELIABILITY.md) · [兼容策略](兼容性与升级.md)
|
package/package.json
CHANGED
|
@@ -109,6 +109,8 @@ const englishCompanions = {
|
|
|
109
109
|
'docs/RELEASE_NOTES_v0.9.1.md': 'docs/RELEASE_NOTES_v0.9.1.en.md',
|
|
110
110
|
'docs/RELEASE_NOTES_v0.9.2.md': 'docs/RELEASE_NOTES_v0.9.2.en.md',
|
|
111
111
|
'docs/UPGRADE_v0.9.2.md': 'docs/UPGRADE_v0.9.2.en.md',
|
|
112
|
+
'docs/RELEASE_NOTES_v0.9.3.md': 'docs/RELEASE_NOTES_v0.9.3.en.md',
|
|
113
|
+
'docs/UPGRADE_v0.9.3.md': 'docs/UPGRADE_v0.9.3.en.md',
|
|
112
114
|
'docs/UPGRADE_v0.9.1.md': 'docs/UPGRADE_v0.9.1.en.md',
|
|
113
115
|
'docs/MODEL_BILLING.md': 'docs/MODEL_BILLING.en.md',
|
|
114
116
|
'docs/PERIOD_ALLOWANCE_UPGRADE.md': 'docs/PERIOD_ALLOWANCE_UPGRADE.en.md',
|
|
@@ -9,7 +9,7 @@ REGISTRY="${BAILING_IMAGE_REGISTRY:-$DEFAULT_REGISTRY}"
|
|
|
9
9
|
NAMESPACE="${BAILING_IMAGE_NAMESPACE:-$DEFAULT_NAMESPACE}"
|
|
10
10
|
PACKAGE_VERSION="$(sed -n 's/.*"version"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' package.json | head -1)"
|
|
11
11
|
TAG="${BAILING_IMAGE_TAG:-$PACKAGE_VERSION}"
|
|
12
|
-
[ -n "$TAG" ] || TAG="0.9.
|
|
12
|
+
[ -n "$TAG" ] || TAG="0.9.3"
|
|
13
13
|
MYSQL_TAG="${BAILING_MYSQL_IMAGE_TAG:-8.4}"
|
|
14
14
|
MYSQL_IMAGE="${BAILING_MYSQL_IMAGE:-$REGISTRY/$NAMESPACE/bailing-mysql:$MYSQL_TAG}"
|
|
15
15
|
PLATFORM="${BAILING_IMAGE_PLATFORM:-linux/amd64}"
|
|
@@ -38,8 +38,8 @@ function updateJson(root, relativePath, update) {
|
|
|
38
38
|
test('current release surface is internally consistent', () => {
|
|
39
39
|
const result = checkReleaseConsistency({ root: repoRoot });
|
|
40
40
|
assert.deepEqual(result.findings, []);
|
|
41
|
-
assert.equal(result.version, '0.9.
|
|
42
|
-
assert.equal(result.stableVersion, '0.9.
|
|
41
|
+
assert.equal(result.version, '0.9.3');
|
|
42
|
+
assert.equal(result.stableVersion, '0.9.3');
|
|
43
43
|
assert.equal(result.publishTag, 'latest');
|
|
44
44
|
});
|
|
45
45
|
|
package/scripts/install.sh
CHANGED
|
@@ -279,7 +279,7 @@ write_env() {
|
|
|
279
279
|
TOOL_SECRET="${DEMO_TOOL_SECRET:-$(secret)}"
|
|
280
280
|
CLIENT_TOKEN="${DEMO_CLIENT_TOKEN:-$(secret)}"
|
|
281
281
|
IMAGE_TAG="${BAILING_IMAGE_TAG:-$(sed -n 's/.*"version"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "$APP_DIR/package.json" | head -1)}"
|
|
282
|
-
[ -n "$IMAGE_TAG" ] || IMAGE_TAG="0.9.
|
|
282
|
+
[ -n "$IMAGE_TAG" ] || IMAGE_TAG="0.9.3"
|
|
283
283
|
IMAGE_REGISTRY="${BAILING_IMAGE_REGISTRY:-$DEFAULT_IMAGE_REGISTRY}"
|
|
284
284
|
IMAGE_NAMESPACE="${BAILING_IMAGE_NAMESPACE:-$DEFAULT_IMAGE_NAMESPACE}"
|
|
285
285
|
cat > "$ENV_FILE" <<EOF
|
|
@@ -9,7 +9,7 @@ REGISTRY="${BAILING_IMAGE_REGISTRY:-$DEFAULT_REGISTRY}"
|
|
|
9
9
|
NAMESPACE="${BAILING_IMAGE_NAMESPACE:-$DEFAULT_NAMESPACE}"
|
|
10
10
|
PACKAGE_VERSION="$(sed -n 's/.*"version"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' package.json | head -1)"
|
|
11
11
|
TAG="${BAILING_IMAGE_TAG:-$PACKAGE_VERSION}"
|
|
12
|
-
[ -n "$TAG" ] || TAG="0.9.
|
|
12
|
+
[ -n "$TAG" ] || TAG="0.9.3"
|
|
13
13
|
NODE_IMAGE="${BAILING_NODE_IMAGE:-node:22-bookworm-slim}"
|
|
14
14
|
PLATFORM="${BAILING_IMAGE_PLATFORM:-linux/amd64}"
|
|
15
15
|
PUSH="${BAILING_PUSH_IMAGES:-0}"
|
|
@@ -45,6 +45,10 @@ const requiredRepoFiles = [
|
|
|
45
45
|
'docs/RELEASE_NOTES_v0.9.2.en.md',
|
|
46
46
|
'docs/UPGRADE_v0.9.2.md',
|
|
47
47
|
'docs/UPGRADE_v0.9.2.en.md',
|
|
48
|
+
'docs/RELEASE_NOTES_v0.9.3.md',
|
|
49
|
+
'docs/RELEASE_NOTES_v0.9.3.en.md',
|
|
50
|
+
'docs/UPGRADE_v0.9.3.md',
|
|
51
|
+
'docs/UPGRADE_v0.9.3.en.md',
|
|
48
52
|
'docs/RELEASE_NOTES_v0.6.1.md',
|
|
49
53
|
'docs/RELEASE_NOTES_v0.6.0.md',
|
|
50
54
|
'docs/CHANGELOG.md',
|
|
@@ -137,6 +137,10 @@ const requiredFiles = [
|
|
|
137
137
|
'docs/RELEASE_NOTES_v0.9.2.en.md',
|
|
138
138
|
'docs/UPGRADE_v0.9.2.md',
|
|
139
139
|
'docs/UPGRADE_v0.9.2.en.md',
|
|
140
|
+
'docs/RELEASE_NOTES_v0.9.3.md',
|
|
141
|
+
'docs/RELEASE_NOTES_v0.9.3.en.md',
|
|
142
|
+
'docs/UPGRADE_v0.9.3.md',
|
|
143
|
+
'docs/UPGRADE_v0.9.3.en.md',
|
|
140
144
|
'docs/RELEASE_NOTES_v0.6.1.md',
|
|
141
145
|
'docs/RELEASE_NOTES_v0.6.0.md',
|
|
142
146
|
'docs/CHANGELOG.md',
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"node_modules/mammoth|dependencies|argparse|~1.0.3"
|
|
95
95
|
],
|
|
96
96
|
"reviewedUsageFiles": {
|
|
97
|
-
"src/adapters/llm/file.ts": "
|
|
97
|
+
"src/adapters/llm/file.ts": "7e793f4d4a36402cf7b4ca295483ab7327ca29fb045c91c2ef35c3c4f9187d84"
|
|
98
98
|
}
|
|
99
99
|
},
|
|
100
100
|
"web-admin": {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
-- Keep native channels separate from executor notification targets. Legacy rows
|
|
2
|
+
-- stay unclassified until their original job can be checked by Core.
|
|
3
|
+
ALTER TABLE `bz_delivery_dlq`
|
|
4
|
+
ADD COLUMN `delivery_kind` VARCHAR(24) DEFAULT NULL,
|
|
5
|
+
ADD COLUMN `notification_job_id` VARCHAR(191) DEFAULT NULL,
|
|
6
|
+
ADD COLUMN `executor_replay_key` VARCHAR(191) DEFAULT NULL;
|
|
7
|
+
|
|
8
|
+
ALTER TABLE `bz_jobs`
|
|
9
|
+
ADD COLUMN `delivery_replay_keys` JSON DEFAULT NULL
|
|
10
|
+
COMMENT 'Core-owned notification DLQ queue markers, never business metadata';
|
package/sql/README.en.md
CHANGED
|
@@ -62,3 +62,9 @@ For incompatible changes, use a transition window and document the upgrade path.
|
|
|
62
62
|
## Naming
|
|
63
63
|
|
|
64
64
|
Use `NNN_short_description.sql` with three-digit increasing numbers. Gaps are allowed. New files should use the current maximum number plus one.
|
|
65
|
+
|
|
66
|
+
## Core 0.9.3: migration 067 for notification DLQ replay
|
|
67
|
+
|
|
68
|
+
`067_delivery_dlq_replay.sql` adds DLQ `delivery_kind`, `notification_job_id`, `executor_replay_key` and Job `delivery_replay_keys` for original notification binding and separate admission markers. Legacy rows remain without bulk-guessing kinds. Replay verifies the original notification child rather than rerunning its business parent.
|
|
69
|
+
|
|
70
|
+
Explicitly apply 067 before all new Core MySQL DLQ reads/writes, including native-channel record/get, and match state/config adapters. Startup does not migrate. Rollback retains queues, markers and history. Older artifact schema manifests do not automatically accept 067; verify in an isolated copy without clearing markers to replay or deleting migration rows to bypass checks. See the [0.9.3 upgrade guide](../docs/UPGRADE_v0.9.3.en.md).
|
package/sql/README.md
CHANGED
|
@@ -80,3 +80,9 @@ Host 需把官方 SQL 一起打包,并通过现有迁移入口显式执行;
|
|
|
80
80
|
## 命名
|
|
81
81
|
|
|
82
82
|
`NNN_简短描述.sql`,三位编号递增。编号只用于排序,**允许缺号**;新文件取当前最大编号 +1 即可。
|
|
83
|
+
|
|
84
|
+
## Core 0.9.3:067 通知死信重投
|
|
85
|
+
|
|
86
|
+
`067_delivery_dlq_replay.sql` 增加 DLQ 的 `delivery_kind`、`notification_job_id`、`executor_replay_key` 及 Job 的 `delivery_replay_keys`,保存原通知绑定和独立入队标记。旧行保留,不批量猜测类型;重投时核对原通知子任务,不能重跑业务父任务。
|
|
87
|
+
|
|
88
|
+
启动新 Core 的全部 MySQL DLQ 读写前显式应用 067,包含原生渠道 record/get,并配套 state/config 仓储。运行时不自动迁移。回退保留队列、标记和账本;旧制品 schema manifest 不保证接受 067,须在隔离副本核验,不能删标记重投或删迁移记录绕过检查。见[0.9.3 升级指南](../docs/UPGRADE_v0.9.3.md)。
|
|
@@ -79,3 +79,62 @@ test('buildFileContext: PDF 文本型文档可本地抽取并审计 parser/pages
|
|
|
79
79
|
assert.equal(audits[0]?.detail['parser'], 'pdf');
|
|
80
80
|
assert.equal(audits[0]?.detail['pages'], 1);
|
|
81
81
|
});
|
|
82
|
+
|
|
83
|
+
test('buildFileContext: 超限声明不读取正文,不运行解析器', async () => {
|
|
84
|
+
let pulls = 0;
|
|
85
|
+
let cancels = 0;
|
|
86
|
+
const audits: Array<{ event: string; detail: Record<string, unknown> }> = [];
|
|
87
|
+
const got = await withMockFetch(() => new Response(new ReadableStream<Uint8Array>({
|
|
88
|
+
pull(controller) { pulls++; controller.enqueue(new Uint8Array(1024)); },
|
|
89
|
+
cancel() { cancels++; },
|
|
90
|
+
}, { highWaterMark: 0 }), { headers: { 'content-type': 'text/plain', 'content-length': '1025' } }),
|
|
91
|
+
() => buildFileContext({ files: [{ url: 'https://synthetic.invalid/a.txt' }],
|
|
92
|
+
config: { mode: 'extract', max_bytes: 1024 }, audit: (event, detail) => audits.push({ event, detail }) }));
|
|
93
|
+
assert.match(got, /文件过大/);
|
|
94
|
+
assert.equal(pulls, 0);
|
|
95
|
+
assert.equal(cancels, 1);
|
|
96
|
+
assert.equal(audits[0]!.detail.ok, false);
|
|
97
|
+
assert.equal(audits[0]!.detail.parser, undefined);
|
|
98
|
+
assert.equal(audits[0]!.detail.bytes, undefined, 'declared length is not consumed bytes');
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
test('buildFileContext: 无长度/低报长度均流式停止,半截文件不注入', async () => {
|
|
102
|
+
for (const declared of [false, true]) {
|
|
103
|
+
let pulls = 0;
|
|
104
|
+
let cancels = 0;
|
|
105
|
+
const audits: Array<{ event: string; detail: Record<string, unknown> }> = [];
|
|
106
|
+
const got = await withMockFetch(() => new Response(new ReadableStream<Uint8Array>({
|
|
107
|
+
pull(controller) { pulls++; controller.enqueue(new Uint8Array(pulls === 1 ? 1024 : 1).fill(65)); },
|
|
108
|
+
cancel() { cancels++; },
|
|
109
|
+
}, { highWaterMark: 0 }), { headers: { 'content-type': 'text/plain', ...(declared ? { 'content-length': '1' } : {}) } }),
|
|
110
|
+
() => buildFileContext({ files: [{ url: 'https://synthetic.invalid/a.txt' }],
|
|
111
|
+
config: { mode: 'extract', max_bytes: 1024 }, audit: (event, detail) => audits.push({ event, detail }) }));
|
|
112
|
+
assert.match(got, /文件过大/);
|
|
113
|
+
assert.equal(got.includes('AAAA'), false);
|
|
114
|
+
assert.equal(pulls, 2);
|
|
115
|
+
assert.equal(cancels, 1);
|
|
116
|
+
assert.equal(audits[0]!.detail.ok, false);
|
|
117
|
+
assert.equal(audits[0]!.detail.parser, undefined);
|
|
118
|
+
assert.equal(audits[0]!.detail.bytes, 1025);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
test('buildFileContext: 恰好达到预算的文件仍正常抽取', async () => {
|
|
123
|
+
const got = await withMockFetch(() => new Response('a'.repeat(1024)),
|
|
124
|
+
() => buildFileContext({ files: [{ url: 'https://synthetic.invalid/a.txt' }], config: { mode: 'extract', max_bytes: 1024 } }));
|
|
125
|
+
assert.equal(got.includes('a'.repeat(1024)), true);
|
|
126
|
+
assert.equal(got.includes('文件过大'), false);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
test('buildFileContext: HTTP 错误取消正文而不读取', async () => {
|
|
130
|
+
let cancels = 0;
|
|
131
|
+
let pulls = 0;
|
|
132
|
+
const got = await withMockFetch(() => new Response(new ReadableStream<Uint8Array>({
|
|
133
|
+
pull(controller) { pulls++; controller.enqueue(new Uint8Array(1024)); },
|
|
134
|
+
cancel() { cancels++; return new Promise<void>(() => undefined); },
|
|
135
|
+
}, { highWaterMark: 0 }), { status: 500 }),
|
|
136
|
+
() => buildFileContext({ files: [{ url: 'https://synthetic.invalid/a.txt' }], config: { mode: 'extract' } }));
|
|
137
|
+
assert.match(got, /文件下载失败(HTTP 500)/);
|
|
138
|
+
assert.equal(cancels, 1);
|
|
139
|
+
assert.equal(pulls, 0);
|
|
140
|
+
});
|
package/src/adapters/llm/file.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { FileRef } from '../../core/platform/content';
|
|
2
2
|
import type { ResolvedCredential } from './perception';
|
|
3
|
+
import { cancelResponseBody, readResponseBody, ResponseBodyLimitError } from '../../core/platform/http-body';
|
|
3
4
|
|
|
4
5
|
export interface FileConfig {
|
|
5
6
|
/** 文件处理凭证名;留空复用 brain 凭证 */
|
|
@@ -153,10 +154,12 @@ async function fetchFile(file: FileRef, index: number, maxBytes: number): Promis
|
|
|
153
154
|
const name = fileName(file, index);
|
|
154
155
|
try {
|
|
155
156
|
const resp = await fetch(file.url, { signal: AbortSignal.timeout(FILE_TIMEOUT_MS) });
|
|
156
|
-
if (!resp.ok)
|
|
157
|
+
if (!resp.ok) {
|
|
158
|
+
cancelResponseBody(resp);
|
|
159
|
+
return { ok: false, name, text: `文件下载失败(HTTP ${resp.status}):${file.url}` };
|
|
160
|
+
}
|
|
157
161
|
const mime = String(resp.headers.get('content-type') ?? '').split(';')[0]!.trim().toLowerCase();
|
|
158
|
-
const ab = await resp
|
|
159
|
-
if (ab.byteLength > maxBytes) return { ok: false, name, mime, bytes: ab.byteLength, text: `文件过大(${ab.byteLength} bytes > ${maxBytes} bytes),未读取内容:${file.url}` };
|
|
162
|
+
const ab = await readResponseBody(resp, maxBytes);
|
|
160
163
|
const extracted = await extractFileText(file, mime, ab);
|
|
161
164
|
return {
|
|
162
165
|
ok: extracted.ok,
|
|
@@ -168,6 +171,10 @@ async function fetchFile(file: FileRef, index: number, maxBytes: number): Promis
|
|
|
168
171
|
text: extracted.text,
|
|
169
172
|
};
|
|
170
173
|
} catch (e) {
|
|
174
|
+
if (e instanceof ResponseBodyLimitError) {
|
|
175
|
+
return { ok: false, name, ...(e.source === 'stream' ? { bytes: e.observedBytes } : {}),
|
|
176
|
+
text: `文件过大(超过 ${maxBytes} bytes 上限),已停止下载:${file.url}` };
|
|
177
|
+
}
|
|
171
178
|
const isTimeout = (e as Error)?.name === 'TimeoutError';
|
|
172
179
|
return { ok: false, name, text: isTimeout ? `文件下载超时(${FILE_TIMEOUT_MS}ms):${file.url}` : `文件读取失败:${String(e).slice(0, 200)}` };
|
|
173
180
|
}
|
|
@@ -215,7 +222,7 @@ export async function buildFileContext(opts: {
|
|
|
215
222
|
: FILE_MODE_DEFAULT;
|
|
216
223
|
if (!opts.files.length || mode === 'off' || mode === 'inline') return '';
|
|
217
224
|
|
|
218
|
-
const maxBytes = Math.max(1024, Math.min(Number(cfg.max_bytes ?? FILE_MAX_BYTES_DEFAULT) || FILE_MAX_BYTES_DEFAULT, 100 * 1024 * 1024));
|
|
225
|
+
const maxBytes = Math.floor(Math.max(1024, Math.min(Number(cfg.max_bytes ?? FILE_MAX_BYTES_DEFAULT) || FILE_MAX_BYTES_DEFAULT, 100 * 1024 * 1024)));
|
|
219
226
|
const maxChars = Math.max(1000, Math.min(Number(cfg.max_chars ?? FILE_MAX_CHARS_DEFAULT) || FILE_MAX_CHARS_DEFAULT, 200000));
|
|
220
227
|
const lines: string[] = [];
|
|
221
228
|
const perFileChars = Math.max(1000, Math.floor(maxChars / Math.max(1, opts.files.length)));
|
|
@@ -616,7 +616,9 @@ test('Agent direct: transport uncertainty and lost client receipts resume the or
|
|
|
616
616
|
attempts++;
|
|
617
617
|
if (failure === 'fetch_rejected') throw new TypeError('synthetic transport failure');
|
|
618
618
|
if (failure === 'client_receipt_lost') return new Response('{"ok":true}', { status: 200 });
|
|
619
|
-
return
|
|
619
|
+
return new Response(new ReadableStream({
|
|
620
|
+
start(controller) { controller.error(new TypeError('synthetic response body loss')); },
|
|
621
|
+
}), { status: 200 });
|
|
620
622
|
});
|
|
621
623
|
const fx = fixture('https://business.invalid');
|
|
622
624
|
if (kind === 'idempotent_write') {
|
|
@@ -13,7 +13,7 @@ import { JsonlStore } from '../infrastructure/state/state-jsonl';
|
|
|
13
13
|
import { ApprovalLedger } from '../infrastructure/config/config-approval-ledger';
|
|
14
14
|
import { handleApprovalDecisionFor, type ApprovalDecisionDeps } from '../routes/approvals';
|
|
15
15
|
import { handleAdminRuntimeApiFor } from '../routes/admin-runtime';
|
|
16
|
-
import { continueApprovalDecisionFor, reconcileApprovalContinuationsFor, type ApprovalContinuationDeps } from './approval-continuations';
|
|
16
|
+
import { continueApprovalDecisionFor, reconcileApprovalContinuationsFor, approvalContinuationMaintenanceSnapshotFor, type ApprovalContinuationDeps } from './approval-continuations';
|
|
17
17
|
|
|
18
18
|
class Response {
|
|
19
19
|
statusCode = 0;
|
|
@@ -119,6 +119,32 @@ async function fixture(status: Job['status'] = 'done', direct = false) {
|
|
|
119
119
|
close: () => rm(directory, { recursive: true, force: true }) };
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
+
test('approval maintenance snapshots report page failures and isolated run history without enumerating records', async () => {
|
|
123
|
+
const one = await fixture(), two = await fixture();
|
|
124
|
+
try {
|
|
125
|
+
one.faults.queue = true;
|
|
126
|
+
await one.call();
|
|
127
|
+
assert.equal(await reconcileApprovalContinuationsFor(one.deps), 0);
|
|
128
|
+
const snapshot = approvalContinuationMaintenanceSnapshotFor(one.deps)!;
|
|
129
|
+
assert.deepEqual(snapshot.progress, { scanned: 1, completed: 0, pending: 0, failed: 1 });
|
|
130
|
+
assert.equal(snapshot.work.kinds[0]!.completed, 1); // A completed pass can retain failed individual intents.
|
|
131
|
+
assert.equal(snapshot.work.kinds[0]!.failed, 0);
|
|
132
|
+
assert.equal(approvalContinuationMaintenanceSnapshotFor(two.deps)!.work.kinds[0]!.completed, 0);
|
|
133
|
+
snapshot.progress!.failed = 1000;
|
|
134
|
+
let reads = 0;
|
|
135
|
+
one.ledger.pendingContinuations = async () => { reads++; throw new Error('PRIVATE_LEDGER_TOKEN_JOB_ID'); };
|
|
136
|
+
assert.equal(approvalContinuationMaintenanceSnapshotFor(one.deps)!.progress!.failed, 1);
|
|
137
|
+
assert.equal(reads, 0);
|
|
138
|
+
await assert.rejects(reconcileApprovalContinuationsFor(one.deps));
|
|
139
|
+
const failed = approvalContinuationMaintenanceSnapshotFor(one.deps)!;
|
|
140
|
+
assert.equal(reads, 1);
|
|
141
|
+
assert.equal(failed.work.kinds[0]!.failed, 1);
|
|
142
|
+
assert.equal(failed.work.kinds[0]!.inFlight, 0);
|
|
143
|
+
assert(failed.work.kinds[0]!.lastFailedAt);
|
|
144
|
+
assert.doesNotMatch(JSON.stringify(failed), /PRIVATE_LEDGER|TOKEN|JOB_ID/);
|
|
145
|
+
} finally { await one.close(); await two.close(); }
|
|
146
|
+
});
|
|
147
|
+
|
|
122
148
|
for (const failure of ['audit', 'queue'] as const) test(`decision submitted then ${failure} fails: identical callback resumes only original job`, async () => {
|
|
123
149
|
const h = await fixture();
|
|
124
150
|
try {
|