@xrn1997/dsh-session-delete 0.12.0 → 0.13.0
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 -201
- package/README.md +4 -3
- package/cordis.patch.yml +7 -7
- package/docs/DETAIL.md +1 -1
- package/docs/DETAIL.zh.md +1 -1
- package/lib/client.js +2485 -200
- package/lib/index.js +1147 -174
- package/lib/types/api/project-ranks.d.ts +3 -0
- package/lib/types/api/search.d.ts +7 -0
- package/lib/types/api/trash-rows.d.ts +1 -1
- package/lib/types/client/archive-detail.d.ts +7 -2
- package/lib/types/client/archive-pane.d.ts +22 -3
- package/lib/types/client/attachment-view.d.ts +1 -1
- package/lib/types/client/confirm-dialog.d.ts +4 -0
- package/lib/types/client/copy.d.ts +39 -0
- package/lib/types/client/panel-tab.d.ts +25 -3
- package/lib/types/client/remote.d.ts +23 -2
- package/lib/types/client/search-box.d.ts +24 -0
- package/lib/types/client/search-preview.d.ts +46 -0
- package/lib/types/client/search-results.d.ts +62 -0
- package/lib/types/client/search-text.d.ts +13 -0
- package/lib/types/client/session-detail.d.ts +17 -1
- package/lib/types/client/trash-detail.d.ts +7 -2
- package/lib/types/client/trash-tab.d.ts +21 -1
- package/lib/types/client/trash-view.d.ts +5 -4
- package/lib/types/client/ui/Modal.d.ts +4 -3
- package/lib/types/client/ui/Toast.d.ts +13 -3
- package/lib/types/client/ui/anchor-fit.d.ts +42 -0
- package/lib/types/client/ui/icons.d.ts +13 -2
- package/lib/types/client/undo-notices.d.ts +9 -22
- package/lib/types/client/use-archive-panel-controller.d.ts +2 -0
- package/lib/types/client/use-detail-rail.d.ts +2 -0
- package/lib/types/client/use-panel-tab.d.ts +1 -1
- package/lib/types/client/use-search-view.d.ts +59 -0
- package/lib/types/client/use-search.d.ts +62 -0
- package/lib/types/client/use-trash-panel-controller.d.ts +6 -0
- package/lib/types/client/view-switches.d.ts +29 -0
- package/lib/types/ports/agent-handles.d.ts +2 -1
- package/lib/types/ports/host-port.d.ts +6 -1
- package/lib/types/shared/wire.d.ts +133 -1
- package/lib/types/trash/content-text.d.ts +10 -0
- package/lib/types/trash/groups.d.ts +18 -6
- package/lib/types/trash/search-corpus.d.ts +40 -0
- package/lib/types/trash/search-text.d.ts +43 -0
- package/lib/types/trash/shrinking-view.d.ts +6 -4
- package/lib/types/verbs/permanent-removal.d.ts +22 -6
- package/lib/types/verbs/search.d.ts +53 -0
- package/lib/types/verbs/trash-scope.d.ts +5 -1
- package/package.json +1 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 组语义的唯一家(ADR-0001):回收站里「这一组有谁」以及「哪些行在清单里露面」。接得住孩子的只有组根——自己不记 `parentEntryId` 的那一行。
|
|
3
3
|
* 父行不在、或父行自己也是孩子时,孩子必须自己占一行,否则它的字节会被头部合计数两遍,而它自己既看不见也清不掉。
|
|
4
|
-
*
|
|
4
|
+
* 这些函数都是纯函数:`indexGroups` / `visibleGroups` / `rootIdOf` 吃一份快照,`groupOf` / `claimOf` 吃索引;
|
|
5
|
+
* 收缩视图的持有机制住 `src/trash/shrinking-view.ts` 的 `createShrinkingView`。
|
|
5
6
|
*/
|
|
6
7
|
import type { TrashEntry } from './entry.js';
|
|
7
8
|
/** 一条露面的组根,连同它接住的孩子(顺序与清册一致)。 */
|
|
@@ -10,6 +11,14 @@ export interface TrashGroupView {
|
|
|
10
11
|
/** 跟着这条根进来的孩子(`parentEntryId` 指向根的 id)。根自己不在里面。 */
|
|
11
12
|
readonly kids: readonly TrashEntry[];
|
|
12
13
|
}
|
|
14
|
+
/** 一份快照的索引:按 id 认行、按父 id 认孩子。批量面一次建好、多次判组,不再逐次 `filter` 整份快照。 */
|
|
15
|
+
export interface GroupIndex {
|
|
16
|
+
readonly byId: ReadonlyMap<string, TrashEntry>;
|
|
17
|
+
readonly kidsByParent: ReadonlyMap<string, readonly TrashEntry[]>;
|
|
18
|
+
}
|
|
19
|
+
/** 把一份快照索引一次:`byId` 第一行胜(清册是存储域主键 KV,id 应唯一;首行胜与前实现的后者胜只在这类
|
|
20
|
+
* 不可达输入上不同,`visibleGroups` / `rootIdOf` 共用这一份)。 */
|
|
21
|
+
export declare function indexGroups(rows: readonly TrashEntry[]): GroupIndex;
|
|
13
22
|
/**
|
|
14
23
|
* 清单露面的一行 = 组根,按清册原序。孩子折进根那一行(宿主的客户端本来就把 `origin:"subagent"` 的行整排藏了 ⇒ 单列会冒出一堆点不到的行)。
|
|
15
24
|
* 折不进去的那两种孩子(父行不在 / 父行自己也是孩子)**自己站出来占一行**——`visibleGroups` 与 `groupOf` 共用这条判据。
|
|
@@ -19,13 +28,16 @@ export declare function visibleGroups(rows: readonly TrashEntry[]): TrashGroupVi
|
|
|
19
28
|
* 一条 id 所属的整组。三种形状,三个答案:**组根** ⇒ 它自己 + 它接住的孩子(UI 点的是父那一行,删除/恢复/彻底删除都按整组走);
|
|
20
29
|
* **孩子** ⇒ **只回它自己**(清单不单独列它,只有手工/降级路径会点到这里);**清册里没有这一条 id,但还有孩子指向它** ⇒ 那一批孩子;
|
|
21
30
|
* 都没有 ⇒ 空数组,调用方据此报 `trash-empty` / 判"已被同批前一条带走"。
|
|
31
|
+
*
|
|
32
|
+
* `present` 只用于收缩视图:当前视图里已经不在的行不算进组(默认全在)。
|
|
22
33
|
*/
|
|
23
|
-
export declare function groupOf(
|
|
34
|
+
export declare function groupOf(index: GroupIndex, id: string, present?: (id: string) => boolean): TrashEntry[];
|
|
24
35
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
36
|
+
* 一条 id 的**可见组根**:与 {@link visibleGroups} 的折叠判据同一份——能折进根的孩子归它,折不进去的
|
|
37
|
+
* (父不在 / 父自己也是孩子)自己就是根。检索把子会话的命中并到组根、预览报归属都用这一份,
|
|
38
|
+
* 不复刻一遍「沿 parentEntryId 一直上溯」的第二种判据。id 不在快照里回它自己。
|
|
27
39
|
*/
|
|
28
|
-
export declare function
|
|
40
|
+
export declare function rootIdOf(rows: readonly TrashEntry[], id: string): string;
|
|
29
41
|
/** 一条 id 在「原始快照 vs 当前视图」里的三态。判别联合:**只有 `fresh` 带当前这一组**——carried / absent 没有可交的组,调用方无从误用。 */
|
|
30
42
|
export type GroupClaim = {
|
|
31
43
|
readonly verdict: 'fresh';
|
|
@@ -43,4 +55,4 @@ export type IdGroupClaim = {
|
|
|
43
55
|
* 「这条是被**同批前一条**带走的,还是整批开始前就没有,还是仍在?」幂等语义只属于 `carried`:后来者本来就不在清册里(用户点了条幽灵 id、
|
|
44
56
|
* 或对账刚摘掉它)必须照样响亮报 `trash-empty`。**所以判据是快照的原始形状,不是当前形状**:原始快照里认得出而当前视图已空 ⇒ 同批带走的。
|
|
45
57
|
*/
|
|
46
|
-
export declare function claimOf(
|
|
58
|
+
export declare function claimOf(index: GroupIndex, id: string, present: (id: string) => boolean): GroupClaim;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** 日志记录的最小面:回收站的 `SessionRecord` 与归档的 `CorpusEvent` 都是这个形状。 */
|
|
2
|
+
export interface SessionRecordLike {
|
|
3
|
+
readonly type?: string;
|
|
4
|
+
readonly time?: number;
|
|
5
|
+
readonly data?: unknown;
|
|
6
|
+
}
|
|
7
|
+
/** 一条参与检索的消息。`index` 是「第几条可检索消息」,从 0 起;预览按它寻址。 */
|
|
8
|
+
export interface CorpusMessage {
|
|
9
|
+
readonly index: number;
|
|
10
|
+
readonly role: 'user' | 'assistant';
|
|
11
|
+
readonly time: number;
|
|
12
|
+
readonly text: string;
|
|
13
|
+
}
|
|
14
|
+
/** 单条会话的抽取预算:正文总字符数上限,防「压缩包小、解出来巨大」。 */
|
|
15
|
+
export interface ExtractBudget {
|
|
16
|
+
readonly maxChars: number;
|
|
17
|
+
}
|
|
18
|
+
/** 抽取结果:要么正常结束并报条数与字符数,要么超预算整条作废。 */
|
|
19
|
+
export type ExtractResult = {
|
|
20
|
+
readonly ok: true;
|
|
21
|
+
readonly count: number;
|
|
22
|
+
readonly chars: number;
|
|
23
|
+
} | {
|
|
24
|
+
readonly ok: false;
|
|
25
|
+
readonly kind: 'too-large';
|
|
26
|
+
};
|
|
27
|
+
export interface MessageExtractor {
|
|
28
|
+
/** 喂一条日志记录。回调停机后不再产生消息,但**继续计字符**:预算是整条会话的属性,不是一页的属性。 */
|
|
29
|
+
feed(record: SessionRecordLike): void;
|
|
30
|
+
/** 已经确定超出预算(调用方可据此提前停止解码后续记录,省掉白读)。 */
|
|
31
|
+
isExhausted(): boolean;
|
|
32
|
+
/** 收尾:可重复调用,回同一个结果。 */
|
|
33
|
+
finish(): ExtractResult;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* 造一个抽取器。`onMessage` 返回 `false` 表示调用方「够了、不再收命中」(例如本页命中数已满)——
|
|
37
|
+
* 它只停**收集**,不停**计账**:后续消息继续计字符,`finish()` 仍按整条会话报 `ok / too-large`。
|
|
38
|
+
* 这样预算闸属于会话、分页属于传输,任何页都不会出现「先给了命中、后来又说没搜完」的半截结论。
|
|
39
|
+
*/
|
|
40
|
+
export declare function createMessageExtractor(onMessage: (message: CorpusMessage) => void | false, budget: ExtractBudget): MessageExtractor;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 检索的**纯函数层**:查询归一、区间查找、开窗/摘要、游标编解码。零 I/O、不碰 deps——编排在 `src/verbs/search.ts`。
|
|
3
|
+
*
|
|
4
|
+
* 三条口径都不是口味:
|
|
5
|
+
* ① **字面子串,不解析正则**:用户输入 `.*` 就该找那两个字面字符,不能变成模式(也不用正则去实现,省得转义漏一处就成漏洞)。
|
|
6
|
+
* ② **不重叠**:`aaaa` 里找 `aa` 是两处,不是三处——重叠区段会让高亮切出互相吞并的片段,且「N 处」失去基数。
|
|
7
|
+
* ③ **开窗按码点、高亮区间按 UTF-16 码元**:切窗不能切坏代理对(emoji),而 `ranges` 的坐标要在**切好的那一串**上重算,
|
|
8
|
+
* 两套坐标混用就是高亮错位——所以这里从不搬运下标,只重算。
|
|
9
|
+
*/
|
|
10
|
+
/** 检索范围唯一名单住 `shared/wire.ts`;纯函数层只投影,不另写一份字面量。 */
|
|
11
|
+
import { type SearchScopeWire } from '../shared/wire.js';
|
|
12
|
+
/** 一处命中:`[start, end)`,UTF-16 码元下标(JS 字符串下标,客户端可直接 `slice`)。 */
|
|
13
|
+
export type SearchRange = readonly [start: number, end: number];
|
|
14
|
+
/** 一段被切过的文本:内容、在**这段内容上**重算的高亮区间、以及「有没有被切」。 */
|
|
15
|
+
export interface SlicedText {
|
|
16
|
+
readonly text: string;
|
|
17
|
+
readonly ranges: readonly SearchRange[];
|
|
18
|
+
readonly truncated: boolean;
|
|
19
|
+
}
|
|
20
|
+
/** 归一查询串:`trim` 后小写。空串(含全空白)回 `undefined`——那不是一次检索。 */
|
|
21
|
+
export declare function normalizeQuery(raw: string): string | undefined;
|
|
22
|
+
/** 在 `text` 里找 `query` 的全部出现(大小写不敏感、字面、不重叠),按出现序。 */
|
|
23
|
+
export declare function findRanges(text: string, query: string): SearchRange[];
|
|
24
|
+
/** 以命为中心开窗,两端**不补省略号**(命中消息用:省略号会被误读成正文本身有截断标记)。 */
|
|
25
|
+
export declare function windowOf(text: string, query: string, before: number, after: number): SlicedText;
|
|
26
|
+
/** 摘要:与 {@link windowOf} 同一刀,但两端被切时补 `…`;区间先在正文核心上算出再按前缀长度平移,不误高亮合成省略号。 */
|
|
27
|
+
export declare function snippetOf(text: string, query: string, before: number, after: number): SlicedText;
|
|
28
|
+
/** 检索游标:记「扫到哪条会话的第几条消息」,不记语料下标(语料增删不会让整页错位)。 */
|
|
29
|
+
export interface SearchCursor {
|
|
30
|
+
readonly v: 1;
|
|
31
|
+
readonly scope: SearchScopeWire;
|
|
32
|
+
readonly queryHash: string;
|
|
33
|
+
/** 实际命中的行 id(回收站条目 id / 归档 sessionId)——不是组根 id。 */
|
|
34
|
+
readonly rowId: string;
|
|
35
|
+
/** 该行内已经扫到的消息下标;下一页从它的下一条继续。-1 = 从这条会话的第一条消息开始。 */
|
|
36
|
+
readonly messageIndex: number;
|
|
37
|
+
}
|
|
38
|
+
/** 查询串的稳定短哈希(FNV-1a 32 位):游标只认同一次查询,防跨查询串页。 */
|
|
39
|
+
export declare function hashQuery(query: string): string;
|
|
40
|
+
/** 游标 → 不透明串(base64url 的 JSON)。 */
|
|
41
|
+
export declare function encodeCursor(cursor: SearchCursor): string;
|
|
42
|
+
/** 不透明串 → 游标;畸形、版本不符、字段不合法一律 `undefined`,绝不抛(请求面据此回 400)。 */
|
|
43
|
+
export declare function decodeCursor(raw: string): SearchCursor | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 收缩视图的持有机制的唯一家:entry 适配(restore 的同批已带走集)与清册作用域(purge)都接这一份。判据不搬:三态读 `groups.ts` 的
|
|
3
|
-
* `claimOf
|
|
3
|
+
* `claimOf`、按组取行读 `groupOf`——这里只有本批的索引与存活状态,无 I/O。
|
|
4
4
|
*/
|
|
5
5
|
import type { TrashEntry } from './entry.js';
|
|
6
6
|
import { type GroupClaim, type IdGroupClaim } from './groups.js';
|
|
@@ -12,9 +12,11 @@ export interface ShrinkingView {
|
|
|
12
12
|
* **执行视图不动**:`take` / `takeRows` 只在动作成功后调,失败/挂起的组下一轮(第二波)重新认领得到。
|
|
13
13
|
* 每条连自己的 id 交回(`IdGroupClaim`),调用方不靠名单下标配对。 */
|
|
14
14
|
claimAll(ids: readonly string[]): readonly IdGroupClaim[];
|
|
15
|
-
/**
|
|
15
|
+
/** 整批开始时的这一组(不看执行期的收缩):挂起条目的附件扫描要吃“未来会删的整组”,不是预测或执行后剩下的行。 */
|
|
16
|
+
originalGroup(id: string): readonly TrashEntry[];
|
|
17
|
+
/** 收掉一条 id 当前所属的整组。 */
|
|
16
18
|
take(id: string): void;
|
|
17
|
-
/**
|
|
19
|
+
/** 只摘掉这次实际执行成功的条目行(不二次按当前组扩大收缩范围,免得把未删子一并抹掉)。 */
|
|
18
20
|
takeRows(rowIds: readonly string[]): void;
|
|
19
21
|
/** 把当前视图收缩到空。 */
|
|
20
22
|
takeAll(): void;
|
|
@@ -24,6 +26,6 @@ export interface ShrinkingView {
|
|
|
24
26
|
/**
|
|
25
27
|
* 开工时把整批的原始快照捕下来(三态判据的「整批开始前的样子」),当前视图从它出发、按组收缩。
|
|
26
28
|
* 调用纪律:`take` / `takeAll` 都在动作**成功之后**才调——清完才收缩,失败时视图不动、下一次重试还能看见这一组。
|
|
27
|
-
*
|
|
29
|
+
* 什么时候收缩、把实例放在哪里仍归调用方:本函数只记录哪些行仍在,不改清册。
|
|
28
30
|
*/
|
|
29
31
|
export declare function createShrinkingView(rows: readonly TrashEntry[]): ShrinkingView;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 永久删除的测量、计划与执行:先记录目录/字节/账本归属,再按计划动盘。计划函数只读;活体准入在计划阶段、任何写之前完成,
|
|
3
3
|
* 执行器动第一笔写前再查一次(ADR-0027)。
|
|
4
|
-
* 测量与补账本归属**分家**:`/list` 的只读计划只吃 `measureMembers`(零账本读);`workspaceOf`
|
|
4
|
+
* 测量与补账本归属**分家**:`/list` 的只读计划只吃 `measureMembers`(零账本读);`workspaceOf` 只由 purge / orphan-clean
|
|
5
|
+
* 的删除计划与执行器的归属复核付(`/list` 不吃)。
|
|
5
6
|
*
|
|
6
7
|
* **批级扫描 + 尾只带走真删掉的目录**:独占图片的候选与剩余引用扫描提到**批级**(`planBatchImageAttachmentRemoval`,
|
|
7
8
|
* 全批两趟读:计划一趟、复核一趟),逐组计划只吐本组被删目录(`attachmentDirs`);附件尾 `executeAttachmentTail`
|
|
@@ -25,11 +26,14 @@ export interface PlannedMemberRemoval {
|
|
|
25
26
|
readonly bytes: number;
|
|
26
27
|
readonly workspaceId?: string;
|
|
27
28
|
}
|
|
28
|
-
/**
|
|
29
|
+
/** 递归量尺寸撞到 ENOENT 时按调用方的用途处置:读路径折叠成「不在」,写计划必须响亮失败(ADR-0078)。 */
|
|
30
|
+
type DirRacePolicy = 'absent' | 'throw';
|
|
31
|
+
/** 成员的盘上目录与字节(扫描、清单与 purge 共用一条口径);目录缺席回 `undefined`,不拿旧读数冒充盘上残留。
|
|
32
|
+
* `race` 决定递归 ENOENT 的处置(ADR-0078):读路径 `'absent'`,删除计划 `'throw'`。 */
|
|
29
33
|
export declare function measureMemberDir(deps: CoreDeps, member: {
|
|
30
34
|
readonly sessionId: string;
|
|
31
35
|
readonly projectDir: string;
|
|
32
|
-
}): Promise<MeasuredMemberDir | undefined>;
|
|
36
|
+
}, race: DirRacePolicy): Promise<MeasuredMemberDir | undefined>;
|
|
33
37
|
/** 一条成员的**测量**读数:身份两格 + 目录 + 实测字节;没有账本归属格(归属只有 `delete` 动词才读)。 */
|
|
34
38
|
export interface MeasuredMember {
|
|
35
39
|
readonly sessionId: string;
|
|
@@ -42,7 +46,7 @@ export interface MeasuredMember {
|
|
|
42
46
|
export declare function measureMembers(deps: CoreDeps, members: readonly {
|
|
43
47
|
readonly sessionId: string;
|
|
44
48
|
readonly projectDir: string;
|
|
45
|
-
}[]): Promise<MeasuredMember[]>;
|
|
49
|
+
}[], race: DirRacePolicy): Promise<MeasuredMember[]>;
|
|
46
50
|
/** 回收站里的一条要删的行:目录、在不在、实测字节(缺席 = 0)。purge 与 `/list` 都由它量。 */
|
|
47
51
|
export interface PlannedTrashRow {
|
|
48
52
|
readonly entry: TrashEntry;
|
|
@@ -50,6 +54,8 @@ export interface PlannedTrashRow {
|
|
|
50
54
|
readonly present: boolean;
|
|
51
55
|
readonly bytes: number;
|
|
52
56
|
}
|
|
57
|
+
/** 一份清册快照里的会话 id 集(bare 归一)。批量面一次算好、多处复用,避免每个组重建一份 n 行的 Set。 */
|
|
58
|
+
export declare function manifestSessionIds(rows: readonly TrashEntry[]): ReadonlySet<string>;
|
|
53
59
|
/** `/list` 的一行(一组):`releaseBytes` 是这一组**实测**会释放的字节;`members` 是测量读数(无账本归属格)。 */
|
|
54
60
|
export interface VisibleTrashGroup extends TrashGroupView {
|
|
55
61
|
readonly trash: readonly PlannedTrashRow[];
|
|
@@ -89,7 +95,9 @@ export interface RemovalPlan {
|
|
|
89
95
|
* - 活体准入在量目录与任何写之前逐个查 targets 与**全部枚举到的**盘上后代;没有跳过它的开关(执行器首笔写前还会复查)。
|
|
90
96
|
* - `sessionQuery` 缺席 ⇒ members 为空、不抛(盘上残留留给 `GET /orphans` 兜底)。
|
|
91
97
|
*/
|
|
92
|
-
export declare function planTrashRemoval(deps: CoreDeps, rows: readonly TrashEntry[], targets: readonly TrashEntry[]
|
|
98
|
+
export declare function planTrashRemoval(deps: CoreDeps, rows: readonly TrashEntry[], targets: readonly TrashEntry[],
|
|
99
|
+
/** 批量入口一次算好的清册 id 集;单条/直接调用缺省按 `rows` 现算。 */
|
|
100
|
+
manifestIds?: ReadonlySet<string>): Promise<RemovalPlan>;
|
|
93
101
|
/**
|
|
94
102
|
* 第二波补跑面的附件候选目录(ADR-0070 决定 5):一组**未来会删**的目录 = 行目录 + 盘上残离子会话目录。
|
|
95
103
|
* 与 `planTrashRemoval` 的区别只是不过闸、不补账本:计划期被活体准入拒掉的组,它的挂起条目仍可能在第二波
|
|
@@ -98,7 +106,9 @@ export declare function planTrashRemoval(deps: CoreDeps, rows: readonly TrashEnt
|
|
|
98
106
|
* 盘上后代读不出时 `complete: false`、只交行目录:调用方要据此把该组的第二波补跑判失败(留着让人重试),
|
|
99
107
|
* 不能让它删掉一批没进过扫描面的目录——那才是孤儿附件的来源。
|
|
100
108
|
*/
|
|
101
|
-
export declare function plannedAttachmentDirs(deps: CoreDeps, rows: readonly TrashEntry[], targets: readonly TrashEntry[]
|
|
109
|
+
export declare function plannedAttachmentDirs(deps: CoreDeps, rows: readonly TrashEntry[], targets: readonly TrashEntry[],
|
|
110
|
+
/** 同 `planTrashRemoval`:批量入口一次算好传进来。 */
|
|
111
|
+
manifestIds?: ReadonlySet<string>): Promise<{
|
|
102
112
|
readonly dirs: readonly string[];
|
|
103
113
|
readonly complete: boolean;
|
|
104
114
|
}>;
|
|
@@ -132,6 +142,11 @@ export type RemovalExecutor = (plan: RemovalPlan) => Promise<RemovalStats>;
|
|
|
132
142
|
* 目录删掉就没有"退回去"这回事,中途失败**不回滚目录**;已删的由计数器如实交回。附件对象不在这条管线里——
|
|
133
143
|
* 归批级尾(`executeAttachmentTail`),见文件头注的口径。
|
|
134
144
|
*
|
|
145
|
+
* **账本与工作区归属**(ADR-0077):摘账本前对每个计划成员复核一次 `workspaceOf`——执行时已无归属就跳过
|
|
146
|
+
* (同批先手已摘 / 用户解绑 / 工作区已删,`detach` 本就是空转),有归属但与计划不一致则响亮失败等重试。
|
|
147
|
+
* 失败出口按 detach 记录的反向顺序,对目录仍在的成员 `attach(..., 'if-unassigned')` 补回原工作区
|
|
148
|
+
* (已删目录 / 用户已重新归组 / 工作区已删都跳过);回滚失败与归档回滚一样进 `details.rollbackFailures`。
|
|
149
|
+
*
|
|
135
150
|
* **归档态回滚**:`unarchive` 排在所有删除之前,所以失败时目录还在、归档位却已摘。失败出口把**目录还在**的那些按删除前的读数
|
|
136
151
|
* 重新归档(预读 `isArchived`,不按 `wasArchived` 猜),目录不在的跳过——否则会造幽灵 id。回滚失败走 `details.rollbackFailures`(ADR-0040)。
|
|
137
152
|
*
|
|
@@ -169,3 +184,4 @@ export interface AttachmentTailResult {
|
|
|
169
184
|
* `run.skipped` 原样带回计划期与复核两段原因——skipped 原文是 fail-closed 的用户可见落点(ADR-0041),不许丢。
|
|
170
185
|
*/
|
|
171
186
|
export declare function executeAttachmentTail(deps: AttachmentRemovalDeps, batch: BatchAttachmentPlan): Promise<AttachmentTailResult>;
|
|
187
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 检索的**编排层**:把语料扫成「标题命中(首页即给全)+ 正文命中(按游标分页)」。
|
|
3
|
+
*
|
|
4
|
+
* 四条口径:
|
|
5
|
+
* ① **不建索引、不缓存**:回收站每次请求都现解压走帧,归档读宿主 `readSession` 事件流。索引是第二份事实源,会因会话继续写入 / 压缩 / 修复而失效,
|
|
6
|
+
* 而回收站的语义是"永不自动过期、随时可恢复"——维护一份会腐烂的副本比多解几次便宜得多(ADR-0074)。
|
|
7
|
+
* ② **扫描序 = 可见组序**:组根按清册原序、根接住的孩子紧跟其根;服务端不复刻界面的项目分组排序(那是视图语义),
|
|
8
|
+
* 标题区只认组根、正文区按这条扫描序,分页也稳定。游标记「下一条待扫的会话 + 该会话内已扫到的消息」,不记语料下标。
|
|
9
|
+
* ③ **读不出的会话不是"没有"**:解不开、超上限的进 `skipped` 单列,单位是**会话**(与 `scanned/total` 同单位),
|
|
10
|
+
* 界面必须说出来(否则用户以为自己搜全了)。
|
|
11
|
+
* ④ **预算是会话的属性、分页是传输的属性**:字符预算归抽取器(停机只停"收命中"、不停"计字符"),
|
|
12
|
+
* 编排层只负责一页扫多少会话。这样任何页都不会出现「先给了命中、后来又说没搜完」的半截结论。
|
|
13
|
+
*
|
|
14
|
+
* 两档的语料与读面不同,**由段名分开**(`/search` = 回收站、`/archive-search` = 归档):回收站读清册目录里的
|
|
15
|
+
* 日志文件(`readWholeSessionLog`),归档读宿主 `readSession` 的整本事件流;归档档是**平铺**的(一行一条会话、
|
|
16
|
+
* 不折孩子,`groupId` 就是 `sessionId`),且只认归档集成员(ADR-0061 的寻址边界)。分页 / 预算 / 游标的状态机
|
|
17
|
+
* 只写一遍({@link runPagedSearch}),档差异由 {@link SearchSource} 的七格适配器注入。
|
|
18
|
+
*/
|
|
19
|
+
import { type TrashEntry } from '../trash/entry.js';
|
|
20
|
+
import type { CoreDeps } from '../deps.js';
|
|
21
|
+
import type { SearchPageWire, SearchPreviewWire } from '../shared/wire.js';
|
|
22
|
+
/** `/search` 与 `/archive-search` 的请求。 */
|
|
23
|
+
export interface SearchRequest {
|
|
24
|
+
/** 已归一(trim + 小写)的查询串;匹配与哈希都认它。 */
|
|
25
|
+
readonly query: string;
|
|
26
|
+
readonly cursor: string | undefined;
|
|
27
|
+
}
|
|
28
|
+
/** `/search-preview` 与 `/archive-search-preview` 的请求。 */
|
|
29
|
+
export interface SearchPreviewRequest {
|
|
30
|
+
readonly query: string;
|
|
31
|
+
readonly rowId: string;
|
|
32
|
+
readonly messageIndex: number;
|
|
33
|
+
}
|
|
34
|
+
/** 一页最多回多少条正文命中。 */
|
|
35
|
+
export declare const SEARCH_PAGE_HITS = 20;
|
|
36
|
+
/** 一页最多扫多少条会话(防单个请求被一个大回收站拖死)。 */
|
|
37
|
+
export declare const SEARCH_PAGE_SESSIONS = 40;
|
|
38
|
+
/** 一页的软时限:到点先回这一页,剩下的走游标续扫。 */
|
|
39
|
+
export declare const SEARCH_PAGE_MS = 1500;
|
|
40
|
+
/** 归档档一页最多扫多少条会话:`readSession` 是整本事件流(没有字节读数、也没有流式),单页条数压小。 */
|
|
41
|
+
export declare const SEARCH_ARCHIVE_PAGE_SESSIONS = 8;
|
|
42
|
+
/** 单条日志的**压缩字节**上限:超过就不解,直接判超限(与详情的 256 MiB 是两个闸,检索不该为一条巨型日志等几秒)。 */
|
|
43
|
+
export declare const SEARCH_MAX_LOG_BYTES: number;
|
|
44
|
+
/** 单条会话**解压后正文**的上限(UTF-16 码元,与 JS 字符串下标同一把尺):压缩比可以很高,字节闸兜不住解压后的量。 */
|
|
45
|
+
export declare const SEARCH_MAX_TEXT_CHARS = 8000000;
|
|
46
|
+
/** 回收站档的一页检索(段名 `/search`):标题命中首页给全,正文命中按实体游标续扫。 */
|
|
47
|
+
export declare function runSearch(deps: CoreDeps, request: SearchRequest, rows: readonly TrashEntry[]): Promise<SearchPageWire>;
|
|
48
|
+
/** 归档档的一页检索(段名 `/archive-search`):与回收站同一条分页协议,语料换成「归档集 ∩ 语料」。 */
|
|
49
|
+
export declare function runArchiveSearch(deps: CoreDeps, request: SearchRequest): Promise<SearchPageWire>;
|
|
50
|
+
/** 回收站档的命中预览(段名 `/search-preview`):寻址只认清册行(外部输入进不了文件系统)。 */
|
|
51
|
+
export declare function runSearchPreview(deps: CoreDeps, request: SearchPreviewRequest, rows: readonly TrashEntry[]): Promise<SearchPreviewWire>;
|
|
52
|
+
/** 归档档的命中预览(段名 `/archive-search-preview`):只认归档集成员(与 `/archive-detail` 同一条寻址边界,ADR-0061)。 */
|
|
53
|
+
export declare function runArchivePreview(deps: CoreDeps, request: SearchPreviewRequest): Promise<SearchPreviewWire>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TrashEntry } from '../trash/entry.js';
|
|
2
|
-
import { type IdGroupClaim } from '../trash/groups.js';
|
|
2
|
+
import { type GroupClaim, type IdGroupClaim } from '../trash/groups.js';
|
|
3
3
|
import type { RemovalExecutor, RemovalPlan, RemovalStats } from './permanent-removal.js';
|
|
4
4
|
/**
|
|
5
5
|
* **清册作用域**:purge 这条写路径的「拿目标」owner。调用方交进一份清册快照(报告与 orphan-clean 入口不经作用域),
|
|
@@ -20,6 +20,10 @@ import type { RemovalExecutor, RemovalPlan, RemovalStats } from './permanent-rem
|
|
|
20
20
|
export interface TrashScope {
|
|
21
21
|
/** 一批 id 的输入序预裁决:`fresh` 带整组;carried / absent 没有组可交(判别联合不给误用的机会)。 */
|
|
22
22
|
claimAll(ids: readonly string[]): readonly IdGroupClaim[];
|
|
23
|
+
/** 单条按当前视图裁决(第二波补跑用:实况为准,不拿预裁决结果当答案)。 */
|
|
24
|
+
claim(id: string): GroupClaim;
|
|
25
|
+
/** 整批开始时这条 id 所属的组(挂起条目的附件扫描用,不随执行期收缩)。 */
|
|
26
|
+
originalGroup(id: string): readonly TrashEntry[];
|
|
23
27
|
/** 把这一组的计划递交给执行器;**成功才**收缩视图(收缩面 = 计划里真删的行,不二次扩组)。 */
|
|
24
28
|
runGroup(plan: RemovalPlan): Promise<RemovalStats>;
|
|
25
29
|
/** 清空:全部行当一组递进执行器;成功收缩到底(同一作用域再 claimAll 走 carried 幂等)。 */
|