@dsh-cc/progress-rebuild 0.0.0-stage → 0.9.1-rc.1
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/LICENSE +201 -0
- package/README.i18n.yaml +6 -0
- package/README.md +29 -2
- package/README.zh.md +30 -0
- package/lib/brief.d.ts +59 -0
- package/lib/brief.d.ts.map +1 -0
- package/lib/brief.js +141 -0
- package/lib/brief.js.map +1 -0
- package/lib/delivery.d.ts +32 -0
- package/lib/delivery.d.ts.map +1 -0
- package/lib/delivery.js +225 -0
- package/lib/delivery.js.map +1 -0
- package/lib/events.d.ts +45 -0
- package/lib/events.d.ts.map +1 -0
- package/lib/events.js +29 -0
- package/lib/events.js.map +1 -0
- package/lib/index.d.ts +48 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +55 -0
- package/lib/index.js.map +1 -0
- package/lib/settings.d.ts +35 -0
- package/lib/settings.d.ts.map +1 -0
- package/lib/settings.js +69 -0
- package/lib/settings.js.map +1 -0
- package/lib/state.d.ts +85 -0
- package/lib/state.d.ts.map +1 -0
- package/lib/state.js +234 -0
- package/lib/state.js.map +1 -0
- package/package.json +54 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.i18n.yaml
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# Bilingual-pair consistency record (docs/i18n/README.md): the git blob hash of each
|
|
2
|
+
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
|
3
|
+
# after editing either side, bring the other along and re-record with:
|
|
4
|
+
# pnpm check:readme --write
|
|
5
|
+
README.md: e101233c9cc8e3cfc36a03a687ae9141801fe201
|
|
6
|
+
README.zh.md: 935898767a9025a0771427ee211f56e4ec3cef99
|
package/README.md
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @dsh-cc/progress-rebuild
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
English | [中文](README.zh.md)
|
|
4
|
+
|
|
5
|
+
Structured progress state + post-compact context rebuild. A registered **session projection** derives a typed per-session progress state from already-committed session events — goal state via the upstream canonical `applyGoalProjection` fold (fed EVERY event, `clear` tombstones and goal-round counting included), the latest `todo/write` snapshot, verified bash execution receipts, and the last genuine user message. On a **successful** `compaction/end`, the derived brief is delivered into the **first model request built after the compaction boundary**: in-turn compaction via an `agent/pre-step` decision splice (the same step's request), idle compaction via a deferred durable `agent.inject` (survives persist+resume, claimed by the user's next turn). **Default off** (`progress-rebuild.enabled: false`, ship-dark).
|
|
6
|
+
|
|
7
|
+
## How it works
|
|
8
|
+
|
|
9
|
+
Plain plugin (no Service) with `inject: ['sessionProjections']`, registering:
|
|
10
|
+
|
|
11
|
+
- **The `progress-rebuild` session projection** (host-only key, no client view): a pure, never-throwing fold over every committed session event, driven and resume-restored by the projections framework — no `snapshotEvents()`/`eventAt()`/`ownEvents()` call anywhere (new production uses are deprecated upstream). State is plain JSON (arrays only).
|
|
12
|
+
- **Listener B** (`session/event`, `compaction/end`): skips error-carrying ends (a failed compaction amputated nothing), gates on `enabled`, resolves the agent through the sessionId-keyed agents registry, then branches on `turn` — `null` (idle) defers a durable `agent.inject` to a microtask (the session append reentry guard forbids inlining it); non-null sets an in-memory `pendingBrief` flag.
|
|
13
|
+
- **Listener C** (`agent/pre-step` waterfall): after `next()`, splices the brief message into the enter decision's messages — the loop commits it as a durable `user/message`, so the brief rides the first post-compaction request. A `reject` decision leaves the flag for the next step.
|
|
14
|
+
- **The ACK observer** (`session/event`, `progress-rebuild`-sourced `user/message`): delivery acknowledgment is the COMMITTED brief, not the splice call — a cancelled step before the durable append yields no row. Emits the `progress-rebuild/injected` dogfood event (`{bytes, sections, path}`) through a deferred, KNOWN_SESSION_EVENT_TYPES-registered widened append.
|
|
15
|
+
|
|
16
|
+
Verified receipts are conservative by construction: bash tool only, `isError` false, a rendered tail carrying NO terminal marker line (`[exit code: N]` / signal / timed-out / stopped / still-running / sandbox markers — a clean exit-0 renders no marker at all), non-compound commands only (`;`, `&&`, `||`, `|`, newline, `&`, `$(…)`, backticks all rejected), and no `run_in_background`. Receipts render execution evidence (command head + exit 0), never inferred completion claims; dedup is keyed by `callId` (first occurrence kept — microcompact replacement re-appends do not double-count). The goal arm latches `failure` explicitly and renders "goal state unavailable" instead of stale state.
|
|
17
|
+
|
|
18
|
+
Cross-package obligation: the injected kind `progress-rebuild` is added to the denylists in `@dsh-cc/turn-rules` (matcher), `@dsh-cc/memory` (recall), and `@dsh-cc/advisor-watchdog` (delta) — the brief can never feed on injected text, and the projection's own brief is excluded from `lastUser` by the genuine-user rule (`source` undefined or `kind === 'user'` with non-empty text).
|
|
19
|
+
|
|
20
|
+
## Settings
|
|
21
|
+
|
|
22
|
+
| Key | Default | Meaning |
|
|
23
|
+
|---|---|---|
|
|
24
|
+
| `enabled` | `false` | Master flag. Ship-dark; gates Listener B, Listener C, and the measurement append (the projection registration stays mounted so resume restore is unaffected). |
|
|
25
|
+
| `max-lines` | `120` | Brief line budget (a 6 KiB byte cap and 240-char line truncation apply independently). |
|
|
26
|
+
| `include-verified` | `true` | Governs the whole verified section (bash fallback now, D1 receipts once the sibling design ships). |
|
|
27
|
+
|
|
28
|
+
## Shape
|
|
29
|
+
|
|
30
|
+
Plain cordis plugin mounted by `packages/preset/cc` in the cc-services group, after advisor-watchdog. All failure modes fail soft; no path wakes a settled session. Known trade-off (session-cwd class): once a session records `progress-rebuild/injected`, resuming it requires a composition that loads this package.
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# @dsh-cc/progress-rebuild
|
|
2
|
+
|
|
3
|
+
English | [中文](README.zh.md)
|
|
4
|
+
|
|
5
|
+
结构化进度状态 + 压缩后上下文重建。一个注册的**会话投影**从已提交的会话事件派生每会话的类型化进度状态——goal 走上游 canonical `applyGoalProjection` 折叠(喂全部事件,含 `clear` 墓碑与 goal 轮次计数)、最新 `todo/write` 快照、已验证的 bash 执行回执、以及最近一条真实用户消息。在**成功的** `compaction/end` 上,派生简报被投递进**压缩边界后构建的第一个模型请求**:turn 内压缩走 `agent/pre-step` 决策拼接(同一步的请求),空闲压缩走延迟的持久 `agent.inject`(可跨持久化+恢复存活,由用户下一轮认领)。**默认关闭**(`progress-rebuild.enabled: false`,暗发布)。
|
|
6
|
+
|
|
7
|
+
## 工作方式
|
|
8
|
+
|
|
9
|
+
普通插件(无 Service),声明 `inject: ['sessionProjections']`,注册:
|
|
10
|
+
|
|
11
|
+
- **`progress-rebuild` 会话投影**(host-only 键、无客户端视图):对每个已提交会话事件的纯函数、绝不抛错的折叠,由投影框架驱动并在 resume 时恢复——全程无任何 `snapshotEvents()`/`eventAt()`/`ownEvents()` 调用(上游对新生产调用已弃用)。状态为纯 JSON(仅数组)。
|
|
12
|
+
- **监听器 B**(`session/event`,`compaction/end`):先跳过带 `error` 的结束事件(失败的压缩什么都没截肢),过 `enabled` 闸门,经 sessionId 键控的 agents registry 解析 agent,再按 `turn` 分支——`null`(空闲)用微任务延迟持久 `agent.inject`(会话 append 重入守卫禁止内联调用);非空则设置内存态 `pendingBrief` 标记。
|
|
13
|
+
- **监听器 C**(`agent/pre-step` 瀑布):在 `next()` 之后把简报消息拼进 enter 决策的 messages——循环将其提交为持久 `user/message`,简报由此搭上压缩后的首个请求。`reject` 决策保留标记到下一步。
|
|
14
|
+
- **ACK 观察者**(`session/event`,`progress-rebuild` 来源的 `user/message`):交付确认是**已提交**的简报而非拼接调用——拼接后、持久 append 前被取消的步骤不产生记录。经延迟的、KNOWN_SESSION_EVENT_TYPES 注册的加宽 append 发出 `progress-rebuild/injected` dogfood 事件(`{bytes, sections, path}`)。
|
|
15
|
+
|
|
16
|
+
已验证回执按构造保守:仅 bash 工具、`isError` 为 false、渲染尾部**无任何**终态 marker 行(`[exit code: N]`/signal/超时/停止/仍在运行/沙箱标记——干净的 exit-0 根本不渲染 marker)、仅非复合命令(`;`、`&&`、`||`、`|`、换行、`&`、`$(…)`、反引号全拒)、且非 `run_in_background`。回执渲染执行证据(命令头 + exit 0),绝不渲染推断出的完成断言;按 `callId` 去重(保留首次出现——microcompact 的替换重追加不会重复计数)。goal 臂显式闩锁 `failure` 并渲染 "goal state unavailable" 而非陈旧状态。
|
|
17
|
+
|
|
18
|
+
跨包义务:注入类型 `progress-rebuild` 已加入 `@dsh-cc/turn-rules`(matcher)、`@dsh-cc/memory`(recall)与 `@dsh-cc/advisor-watchdog`(delta)的拒绝列表——简报永不以注入文本为食;投影自身的简报也被真实用户规则(`source` 缺席或 `kind === 'user'` 且含非空文本)排除在 `lastUser` 之外。
|
|
19
|
+
|
|
20
|
+
## 设置
|
|
21
|
+
|
|
22
|
+
| 键 | 默认 | 含义 |
|
|
23
|
+
|---|---|---|
|
|
24
|
+
| `enabled` | `false` | 总开关。暗发布;闸住监听器 B、监听器 C 与测量 append(投影注册保持挂载,resume 恢复不受影响)。 |
|
|
25
|
+
| `max-lines` | `120` | 简报行预算(6 KiB 字节上限与 240 字符行截断独立生效)。 |
|
|
26
|
+
| `include-verified` | `true` | 管辖整个 verified 节(当下的 bash 回退 + 姊妹设计落地后的 D1 回执)。 |
|
|
27
|
+
|
|
28
|
+
## 形态
|
|
29
|
+
|
|
30
|
+
普通 cordis 插件,由 `packages/preset/cc` 挂载在 cc-services 组、advisor-watchdog 之后。所有失败路径 fail-soft;没有任何路径会唤醒已静置的会话。已知取舍(session-cwd 同类):一旦会话记录了 `progress-rebuild/injected`,恢复该会话需要装载本包的组合。
|
package/lib/brief.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The post-compact rebuild brief renderer (design
|
|
3
|
+
* docs/plans/2026-10-09-structured-progress-and-post-compact-rebuild.md
|
|
4
|
+
* §3.3 step 2): pure Markdown derivation from the registered
|
|
5
|
+
* `progress-rebuild` projection state. Hard budget on BOTH axes —
|
|
6
|
+
* ≤ `maxLines` lines AND ≤ {@link BRIEF_MAX_BYTES} bytes, every line
|
|
7
|
+
* truncated at {@link MAX_LINE_CHARS} chars, the todo section elided with
|
|
8
|
+
* TAIL preference (recent todos matter more than the opening ones).
|
|
9
|
+
*
|
|
10
|
+
* @module @dsh-cc/progress-rebuild/brief
|
|
11
|
+
*/
|
|
12
|
+
import type { ProgressRebuildState } from './state.ts';
|
|
13
|
+
/** Per-line hard truncation (§3.3 step 2). */
|
|
14
|
+
export declare const MAX_LINE_CHARS = 240;
|
|
15
|
+
/** Whole-brief byte ceiling (§5.2: ≤ 6 KiB). */
|
|
16
|
+
export declare const BRIEF_MAX_BYTES: number;
|
|
17
|
+
/** The stub-marker note sentence (§3.4): fixed text, never derived. */
|
|
18
|
+
export declare const STUB_MARKER_NOTE: string;
|
|
19
|
+
/** The closing anti-fabrication paragraph (§3.3 step 2). */
|
|
20
|
+
export declare const NOT_VERIFIED_NOTE: string;
|
|
21
|
+
/** The fixed header line. */
|
|
22
|
+
export declare const BRIEF_HEADER = "## Resume after compaction (auto-generated, derived from session events \u2014 trust over prose memory)";
|
|
23
|
+
/** The verified-commands section header. */
|
|
24
|
+
export declare const VERIFIED_HEADER = "Verified commands (executed, exit 0 \u2014 execution evidence, NOT inferred completion claims)";
|
|
25
|
+
/** One rendered brief plus the section count for the measurement event. */
|
|
26
|
+
export interface RenderedBrief {
|
|
27
|
+
/** The full Markdown brief. */
|
|
28
|
+
text: string;
|
|
29
|
+
/** Number of top-level sections rendered (goal / verified / todos / last-user). */
|
|
30
|
+
sections: number;
|
|
31
|
+
}
|
|
32
|
+
/** Rendering options (resolved settings). */
|
|
33
|
+
export interface BriefOptions {
|
|
34
|
+
/** Line budget (§3.5 `progress-rebuild.max-lines`). */
|
|
35
|
+
maxLines: number;
|
|
36
|
+
/** §3.5 `progress-rebuild.include-verified`: governs the WHOLE verified section. */
|
|
37
|
+
includeVerified: boolean;
|
|
38
|
+
}
|
|
39
|
+
/** Hard-truncate one line at {@link MAX_LINE_CHARS} chars. */
|
|
40
|
+
export declare function truncateLine(line: string): string;
|
|
41
|
+
/** The Goal line: objective + phase, replay-failure, or none-recorded. */
|
|
42
|
+
export declare function renderGoalLine(state: ProgressRebuildState): string;
|
|
43
|
+
/**
|
|
44
|
+
* Render the brief. Never throws: every field read is defensive and the
|
|
45
|
+
* budget pass is total (worst case a truncated header-only brief).
|
|
46
|
+
* @param state - the current projection state.
|
|
47
|
+
* @param options - resolved rendering settings.
|
|
48
|
+
* @returns the bounded brief text and its section count.
|
|
49
|
+
*/
|
|
50
|
+
export declare function renderBrief(state: ProgressRebuildState, options: BriefOptions): RenderedBrief;
|
|
51
|
+
/**
|
|
52
|
+
* Line-and-byte budget (§3.3 step 2): drop from the MIDDLE of the todo
|
|
53
|
+
* lines only (tail preference — head lines and the fixed sentences stay),
|
|
54
|
+
* until both the line count and the byte size fit. Non-todo lines are
|
|
55
|
+
* never dropped: if the fixed content alone exceeds the budget the brief
|
|
56
|
+
* is byte-clipped, which can only happen with pathological settings.
|
|
57
|
+
*/
|
|
58
|
+
export declare function applyBudget(lines: string[], maxLines: number): string[];
|
|
59
|
+
//# sourceMappingURL=brief.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brief.d.ts","sourceRoot":"","sources":["../src/brief.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAEtD,8CAA8C;AAC9C,eAAO,MAAM,cAAc,MAAM,CAAA;AAEjC,gDAAgD;AAChD,eAAO,MAAM,eAAe,QAAW,CAAA;AAEvC,uEAAuE;AACvE,eAAO,MAAM,gBAAgB,QAE4D,CAAA;AAEzF,4DAA4D;AAC5D,eAAO,MAAM,iBAAiB,QAEY,CAAA;AAE1C,6BAA6B;AAC7B,eAAO,MAAM,YAAY,4GAC6E,CAAA;AAEtG,4CAA4C;AAC5C,eAAO,MAAM,eAAe,mGACiE,CAAA;AAE7F,2EAA2E;AAC3E,MAAM,WAAW,aAAa;IAC5B,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,mFAAmF;IACnF,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,6CAA6C;AAC7C,MAAM,WAAW,YAAY;IAC3B,uDAAuD;IACvD,QAAQ,EAAE,MAAM,CAAA;IAChB,oFAAoF;IACpF,eAAe,EAAE,OAAO,CAAA;CACzB;AAOD,8DAA8D;AAC9D,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,0EAA0E;AAC1E,wBAAgB,cAAc,CAAC,KAAK,EAAE,oBAAoB,GAAG,MAAM,CAKlE;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,oBAAoB,EAAE,OAAO,EAAE,YAAY,GAAG,aAAa,CAmC7F;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAmBvE"}
|
package/lib/brief.js
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The post-compact rebuild brief renderer (design
|
|
3
|
+
* docs/plans/2026-10-09-structured-progress-and-post-compact-rebuild.md
|
|
4
|
+
* §3.3 step 2): pure Markdown derivation from the registered
|
|
5
|
+
* `progress-rebuild` projection state. Hard budget on BOTH axes —
|
|
6
|
+
* ≤ `maxLines` lines AND ≤ {@link BRIEF_MAX_BYTES} bytes, every line
|
|
7
|
+
* truncated at {@link MAX_LINE_CHARS} chars, the todo section elided with
|
|
8
|
+
* TAIL preference (recent todos matter more than the opening ones).
|
|
9
|
+
*
|
|
10
|
+
* @module @dsh-cc/progress-rebuild/brief
|
|
11
|
+
*/
|
|
12
|
+
/** Per-line hard truncation (§3.3 step 2). */
|
|
13
|
+
export const MAX_LINE_CHARS = 240;
|
|
14
|
+
/** Whole-brief byte ceiling (§5.2: ≤ 6 KiB). */
|
|
15
|
+
export const BRIEF_MAX_BYTES = 6 * 1024;
|
|
16
|
+
/** The stub-marker note sentence (§3.4): fixed text, never derived. */
|
|
17
|
+
export const STUB_MARKER_NOTE = 'Note: earlier tool outputs may appear as deterministic placeholder stubs '
|
|
18
|
+
+ '(microcompact collapsed them out of the window); their content is elided, not lost.';
|
|
19
|
+
/** The closing anti-fabrication paragraph (§3.3 step 2). */
|
|
20
|
+
export const NOT_VERIFIED_NOTE = 'Not verified: any completion claim not listed above is NOT backed by a '
|
|
21
|
+
+ 'receipt — re-verify before claiming.';
|
|
22
|
+
/** The fixed header line. */
|
|
23
|
+
export const BRIEF_HEADER = '## Resume after compaction (auto-generated, derived from session events — trust over prose memory)';
|
|
24
|
+
/** The verified-commands section header. */
|
|
25
|
+
export const VERIFIED_HEADER = 'Verified commands (executed, exit 0 — execution evidence, NOT inferred completion claims)';
|
|
26
|
+
/** ISO-ish short timestamp for brief lines. */
|
|
27
|
+
function stamp(ts) {
|
|
28
|
+
return new Date(ts).toISOString();
|
|
29
|
+
}
|
|
30
|
+
/** Hard-truncate one line at {@link MAX_LINE_CHARS} chars. */
|
|
31
|
+
export function truncateLine(line) {
|
|
32
|
+
return line.length > MAX_LINE_CHARS ? line.slice(0, MAX_LINE_CHARS) : line;
|
|
33
|
+
}
|
|
34
|
+
/** The Goal line: objective + phase, replay-failure, or none-recorded. */
|
|
35
|
+
export function renderGoalLine(state) {
|
|
36
|
+
if (state.goal.failure !== null)
|
|
37
|
+
return '- Goal: goal state unavailable (replay failure)';
|
|
38
|
+
const current = state.goal.current;
|
|
39
|
+
if (current === null)
|
|
40
|
+
return '- Goal: none recorded';
|
|
41
|
+
return `- Goal: ${current.goal.objective} (phase: ${current.goal.phase})`;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Render the brief. Never throws: every field read is defensive and the
|
|
45
|
+
* budget pass is total (worst case a truncated header-only brief).
|
|
46
|
+
* @param state - the current projection state.
|
|
47
|
+
* @param options - resolved rendering settings.
|
|
48
|
+
* @returns the bounded brief text and its section count.
|
|
49
|
+
*/
|
|
50
|
+
export function renderBrief(state, options) {
|
|
51
|
+
const lines = [BRIEF_HEADER, ''];
|
|
52
|
+
let sections = 0;
|
|
53
|
+
lines.push(truncateLine(renderGoalLine(state)));
|
|
54
|
+
sections += 1;
|
|
55
|
+
if (options.includeVerified && state.verified.length > 0) {
|
|
56
|
+
lines.push(`- ${VERIFIED_HEADER}:`);
|
|
57
|
+
for (const receipt of state.verified) {
|
|
58
|
+
lines.push(truncateLine(` - ${stamp(receipt.ts)} \`${receipt.commandHead}\``));
|
|
59
|
+
}
|
|
60
|
+
sections += 1;
|
|
61
|
+
}
|
|
62
|
+
if (state.todos !== null && state.todos.length > 0) {
|
|
63
|
+
lines.push('- Todo snapshot (verbatim):');
|
|
64
|
+
for (const todo of state.todos) {
|
|
65
|
+
const mark = todo.status === 'completed' ? 'x' : ' ';
|
|
66
|
+
lines.push(truncateLine(` - [${mark}] ${todo.content}`));
|
|
67
|
+
}
|
|
68
|
+
sections += 1;
|
|
69
|
+
}
|
|
70
|
+
lines.push(truncateLine(STUB_MARKER_NOTE));
|
|
71
|
+
if (state.lastUser !== null) {
|
|
72
|
+
lines.push(truncateLine(`- Last user instruction at ${stamp(state.lastUser.ts)}: ${state.lastUser.text}`));
|
|
73
|
+
sections += 1;
|
|
74
|
+
}
|
|
75
|
+
lines.push(truncateLine(NOT_VERIFIED_NOTE), '');
|
|
76
|
+
const budgeted = applyBudget(lines, options.maxLines);
|
|
77
|
+
return { text: budgeted.join('\n'), sections };
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Line-and-byte budget (§3.3 step 2): drop from the MIDDLE of the todo
|
|
81
|
+
* lines only (tail preference — head lines and the fixed sentences stay),
|
|
82
|
+
* until both the line count and the byte size fit. Non-todo lines are
|
|
83
|
+
* never dropped: if the fixed content alone exceeds the budget the brief
|
|
84
|
+
* is byte-clipped, which can only happen with pathological settings.
|
|
85
|
+
*/
|
|
86
|
+
export function applyBudget(lines, maxLines) {
|
|
87
|
+
const todoRange = todoLineRange(lines);
|
|
88
|
+
let out = lines;
|
|
89
|
+
if (out.length > maxLines && todoRange !== undefined) {
|
|
90
|
+
out = elideTodos(out, todoRange, maxLines);
|
|
91
|
+
}
|
|
92
|
+
let text = out.join('\n');
|
|
93
|
+
if (Buffer.byteLength(text, 'utf8') > BRIEF_MAX_BYTES) {
|
|
94
|
+
const room = BRIEF_MAX_BYTES - Buffer.byteLength(BRIEF_HEADER + '\n' + NOT_VERIFIED_NOTE, 'utf8') - 2;
|
|
95
|
+
if (todoRange !== undefined) {
|
|
96
|
+
out = elideTodos(out, todoLineRange(out) ?? todoRange, Math.max(4, Math.ceil(room / (MAX_LINE_CHARS + 1))));
|
|
97
|
+
text = out.join('\n');
|
|
98
|
+
}
|
|
99
|
+
if (Buffer.byteLength(text, 'utf8') > BRIEF_MAX_BYTES) {
|
|
100
|
+
text = Buffer.from(text, 'utf8').subarray(0, BRIEF_MAX_BYTES).toString('utf8');
|
|
101
|
+
out = text.split('\n');
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return out;
|
|
105
|
+
}
|
|
106
|
+
/** First..last indexes (inclusive) of the verbatim todo lines (an elision marker counts as part of the block). */
|
|
107
|
+
function todoLineRange(lines) {
|
|
108
|
+
const isTodoLine = (line) => line.startsWith(' - [') || line.startsWith(' - … (');
|
|
109
|
+
const first = lines.findIndex(isTodoLine);
|
|
110
|
+
if (first === -1)
|
|
111
|
+
return undefined;
|
|
112
|
+
let last = first;
|
|
113
|
+
while (last + 1 < lines.length && isTodoLine(lines[last + 1]))
|
|
114
|
+
last += 1;
|
|
115
|
+
return { first, last };
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Elide todo lines with TAIL preference: keep the head few and the tail
|
|
119
|
+
* many, dropping from the middle. `budget` is the TOTAL line budget for the
|
|
120
|
+
* whole brief, so the todo allowance is what remains after the fixed lines.
|
|
121
|
+
*/
|
|
122
|
+
function elideTodos(lines, range, budget) {
|
|
123
|
+
const fixedCount = lines.length - (range.last - range.first + 1);
|
|
124
|
+
// Reserve one line for the elision marker itself.
|
|
125
|
+
const allowance = Math.max(0, budget - fixedCount - 1);
|
|
126
|
+
const available = range.last - range.first + 1;
|
|
127
|
+
if (allowance >= available)
|
|
128
|
+
return [...lines];
|
|
129
|
+
const marker = ' - … (todo snapshot elided to fit the line budget; tail kept)';
|
|
130
|
+
if (allowance <= 0) {
|
|
131
|
+
const out = [...lines];
|
|
132
|
+
out.splice(range.first, available, marker);
|
|
133
|
+
return out;
|
|
134
|
+
}
|
|
135
|
+
const head = Math.max(1, Math.floor(allowance / 3)); // head:tail 1:2 (rendering-order precedent)
|
|
136
|
+
const tail = Math.max(0, allowance - head);
|
|
137
|
+
const out = [...lines];
|
|
138
|
+
out.splice(range.first + head, available - head - tail, ` - … (${available - head - tail} earlier todos elided)`);
|
|
139
|
+
return out;
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=brief.js.map
|
package/lib/brief.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brief.js","sourceRoot":"","sources":["../src/brief.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,8CAA8C;AAC9C,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAA;AAEjC,gDAAgD;AAChD,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAG,IAAI,CAAA;AAEvC,uEAAuE;AACvE,MAAM,CAAC,MAAM,gBAAgB,GAC3B,2EAA2E;MACzE,qFAAqF,CAAA;AAEzF,4DAA4D;AAC5D,MAAM,CAAC,MAA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M,MAAM,GAAG,gEAAgE,CAAA;IAC/E,IAAI,SAAS,IAAI,CAAC,EAAE,CAAC;QACnB,MAAM,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC,CAAA;QACtB,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,CAAA;QAC1C,OAAO,GAAG,CAAA;IACZ,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,CAAA,CAAC,4CAA4C;IAChG,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC,CAAA;IAC1C,MAAM,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC,CAAA;IACtB,GAAG,CAAC,MAAM,CACR,KAAK,CAAC,KAAK,GAAG,IAAI,EAClB,SAAS,GAAG,IAAI,GAAG,IAAI,EACvB,UAAU,SAAS,GAAG,IAAI,GAAG,IAAI,wBAAwB,CAC1D,CAAA;IACD,OAAO,GAAG,CAAA;AACZ,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delivery (design docs/plans/2026-10-09-structured-progress-and-post-compact-rebuild.md
|
|
3
|
+
* §3.3 steps 1-4): Listener B (the `compaction/end` trigger with the
|
|
4
|
+
* in-turn / idle path split), Listener C (the `agent/pre-step` splice),
|
|
5
|
+
* the idle deferred inject, and the delivery ACK observer with the
|
|
6
|
+
* `progress-rebuild/injected` measurement append.
|
|
7
|
+
*
|
|
8
|
+
* All paths no-op unless `progress-rebuild.enabled` (§3.3 round-9 gate);
|
|
9
|
+
* every fault degrades to a debug log — delivery failure carries no
|
|
10
|
+
* user-facing error (§3.6).
|
|
11
|
+
*
|
|
12
|
+
* @module @dsh-cc/progress-rebuild/delivery
|
|
13
|
+
*/
|
|
14
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
15
|
+
import type { ProgressRebuildSettings } from './settings.ts';
|
|
16
|
+
/** Delivery path recorded at splice/inject time, looked up by the ACK observer. */
|
|
17
|
+
export type DeliveryPath = 'pre-step' | 'inject';
|
|
18
|
+
/** Bounded path-stash capacity (§3.3 step 4). */
|
|
19
|
+
export declare const PATH_STASH_CAPACITY = 64;
|
|
20
|
+
/**
|
|
21
|
+
* Register the delivery listeners. Plain listeners — never throw into a
|
|
22
|
+
* waterfall or an observer callback.
|
|
23
|
+
* @param ctx - the plug context (needs `agents`, `sessionProjections`, `logger`).
|
|
24
|
+
* @param readSettings - live settings reader (gate for B, C, and measurement).
|
|
25
|
+
*/
|
|
26
|
+
export declare function registerDelivery(ctx: Context, readSettings: () => ProgressRebuildSettings): void;
|
|
27
|
+
/**
|
|
28
|
+
* Count the brief's top-level sections for the measurement event — the same
|
|
29
|
+
* accounting as {@link renderBrief} (goal / verified / todos / last-user).
|
|
30
|
+
*/
|
|
31
|
+
export declare function countSections(text: string): number;
|
|
32
|
+
//# sourceMappingURL=delivery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delivery.d.ts","sourceRoot":"","sources":["../src/delivery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAOlD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAA;AAE5D,mFAAmF;AACnF,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,QAAQ,CAAA;AAEhD,iDAAiD;AACjD,eAAO,MAAM,mBAAmB,KAAK,CAAA;AAcrC;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,OAAO,EACZ,YAAY,EAAE,MAAM,uBAAuB,GAC1C,IAAI,CA2JN;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAOlD"}
|