dsh-manage-session 0.2.3 → 0.3.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 +14 -0
- package/README.ja.md +14 -0
- package/README.ko.md +14 -0
- package/README.md +14 -0
- package/dsh.plugin.json +4 -4
- package/lib/client.js +12 -3
- package/lib/index.d.ts +167 -10
- package/lib/index.js +331 -44
- package/package.json +10 -9
- package/screenshots.json +5 -1
- package/src/client/health-panel.tsx +5 -1
- package/src/client/host-api.ts +6 -1
- package/src/client/locales.ts +7 -2
- package/src/host/health/cache.ts +1 -1
- package/src/host/health/decode.ts +19 -1
- package/src/host/health/gates.ts +91 -3
- package/src/host/health/generation.ts +216 -0
- package/src/host/health/repair.ts +28 -7
- package/src/host/health/scan.ts +84 -27
- package/src/index.ts +27 -7
package/README.en.md
CHANGED
|
@@ -10,6 +10,20 @@ A DSH web plugin for **session history files** and **session health checks**. It
|
|
|
10
10
|
> Naming boundary: **this package ships no search or index features**. Search/indexing belongs to
|
|
11
11
|
> `dsh-search-index`; neither side mentions or re-interprets the other's fields.
|
|
12
12
|
|
|
13
|
+
## Screenshots
|
|
14
|
+
|
|
15
|
+
A **Session Steward** entry sits next to Search and Settings at the bottom of the sidebar:
|
|
16
|
+
|
|
17
|
+

|
|
18
|
+
|
|
19
|
+
**Retirement Home (history files)** — the official archive set, each row carrying its size and whether the on-disk entity still exists; select rows to un-archive or purge:
|
|
20
|
+
|
|
21
|
+

|
|
22
|
+
|
|
23
|
+
**Checkup** — the entry point of the four-gate checkup, which ends in a reversible prescription:
|
|
24
|
+
|
|
25
|
+

|
|
26
|
+
|
|
13
27
|
## Install
|
|
14
28
|
|
|
15
29
|
```bash
|
package/README.ja.md
CHANGED
|
@@ -10,6 +10,20 @@
|
|
|
10
10
|
> 命名の境界:**本パッケージは検索・インデックス機能を一切提供しません**。検索/インデックスは
|
|
11
11
|
> `dsh-search-index` に属し、双方が相手のフィールドに言及したり再解釈したりすることはありません。
|
|
12
12
|
|
|
13
|
+
## スクリーンショット
|
|
14
|
+
|
|
15
|
+
サイドバー下部に **「会话管家」**(セッション・スチュワード)のエントリが追加され、検索・設定と並びます:
|
|
16
|
+
|
|
17
|
+

|
|
18
|
+
|
|
19
|
+
**カルテ室(履歴ファイル)** — 公式アーカイブ集合の一覧。各行にサイズとディスク上の実体の有無を表示し、選択してアーカイブ解除または整理ができます:
|
|
20
|
+
|
|
21
|
+

|
|
22
|
+
|
|
23
|
+
**健診** — 四つのゲートによる健診の入口。スキャン後に可逆的な処方を提示します:
|
|
24
|
+
|
|
25
|
+

|
|
26
|
+
|
|
13
27
|
## インストール
|
|
14
28
|
|
|
15
29
|
```bash
|
package/README.ko.md
CHANGED
|
@@ -9,6 +9,20 @@
|
|
|
9
9
|
> 이름 경계: **이 패키지는 검색이나 인덱스 기능을 제공하지 않습니다**. 검색/인덱싱은
|
|
10
10
|
> `dsh-search-index`에 속하며, 어느 쪽도 상대방의 필드를 언급하거나 재해석하지 않습니다.
|
|
11
11
|
|
|
12
|
+
## 스크린샷
|
|
13
|
+
|
|
14
|
+
사이드바 하단에 **「会话管家」**(세션 스튜어드) 항목이 추가되어 검색, 설정과 나란히 표시됩니다:
|
|
15
|
+
|
|
16
|
+

|
|
17
|
+
|
|
18
|
+
**기록 보관소(히스토리 파일)** — 공식 아카이브 집합 목록. 각 행에 용량과 디스크 실체 존재 여부를 표시하며, 선택하여 아카이브 해제 또는 정리를 할 수 있습니다:
|
|
19
|
+
|
|
20
|
+

|
|
21
|
+
|
|
22
|
+
**점검** — 네 개의 gate 점검 입구이며, 검사 후 되돌릴 수 있는 처방을 제시합니다:
|
|
23
|
+
|
|
24
|
+

|
|
25
|
+
|
|
12
26
|
## 설치
|
|
13
27
|
|
|
14
28
|
```bash
|
package/README.md
CHANGED
|
@@ -28,6 +28,20 @@ DSH Web 插件:**会话历史文件 + 会话健康检查**。
|
|
|
28
28
|
> 命名边界:**本插件不提供搜索与索引**。搜索/独立索引属于另一片(`dsh-search-index`),
|
|
29
29
|
> 两侧互不出现对方的子域字眼,也不互相解释对方字段。
|
|
30
30
|
|
|
31
|
+
## 界面预览
|
|
32
|
+
|
|
33
|
+
侧边栏底部新增 **「会话管家」** 入口,与搜索、设置并列:
|
|
34
|
+
|
|
35
|
+

|
|
36
|
+
|
|
37
|
+
**养老院(会话历史文件)**——官方归档集合一览,每条给出体积与磁盘实体状态;勾选后可取消归档或清理:
|
|
38
|
+
|
|
39
|
+

|
|
40
|
+
|
|
41
|
+
**体检**——四门体检的入口,扫完给出可逆处方:
|
|
42
|
+
|
|
43
|
+

|
|
44
|
+
|
|
31
45
|
## 安装
|
|
32
46
|
|
|
33
47
|
```bash
|
package/dsh.plugin.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "dsh-manage-session",
|
|
3
3
|
"name": "dsh-manage-session",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.3",
|
|
5
5
|
"description": {
|
|
6
|
-
"en": "Session Steward: browse and bulk-prune the official session archive set, and run a four-gate session health checkup that ends in a reversible, backup-first prescription. Never rewrites session logs.",
|
|
7
|
-
"zh": "
|
|
6
|
+
"en": "Session Steward (DSH 0.1.5 line): browse and bulk-prune the official session archive set, and run a four-gate session health checkup that ends in a reversible, backup-first prescription. Never rewrites session logs.",
|
|
7
|
+
"zh": "会话管家(DSH 0.1.5 专线):浏览并批量清理官方会话归档集合,并对会话做四门体检,最终给出可逆、先备份的处方。不改写会话日志。"
|
|
8
8
|
},
|
|
9
9
|
"homepage": "https://github.com/drscrewdriver/dsh-manage-session",
|
|
10
10
|
"repository": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"engines": {
|
|
16
|
-
"dsh": ">=0.1.
|
|
16
|
+
"dsh": ">=0.1.5-rc.1 <0.1.6-0"
|
|
17
17
|
},
|
|
18
18
|
"components": {
|
|
19
19
|
"host": "lib/index.js",
|
package/lib/client.js
CHANGED
|
@@ -64,11 +64,13 @@ window.__ModuleLoader__.load({
|
|
|
64
64
|
"health.scanning": "体检中…",
|
|
65
65
|
"health.progress": "{done}/{total} · 已用 {sec}s",
|
|
66
66
|
"health.empty": "未发现异常会话。",
|
|
67
|
-
"health.clean": "
|
|
67
|
+
"health.clean": "全部检查通过。",
|
|
68
68
|
"health.level.ok": "正常",
|
|
69
69
|
"health.level.warn": "注意",
|
|
70
70
|
"health.level.skipped": "未检查",
|
|
71
71
|
"health.level.fail": "异常",
|
|
72
|
+
"health.priority.high": "优先",
|
|
73
|
+
"health.gate.generation": "代次产物",
|
|
72
74
|
"health.gate.log-integrity": "日志完整性",
|
|
73
75
|
"health.gate.projection-cache": "投影缓存",
|
|
74
76
|
"health.gate.lossless-json": "无损 JSON",
|
|
@@ -142,11 +144,13 @@ window.__ModuleLoader__.load({
|
|
|
142
144
|
"health.scanning": "Running…",
|
|
143
145
|
"health.progress": "{done}/{total} · {sec}s elapsed",
|
|
144
146
|
"health.empty": "No problem session found.",
|
|
145
|
-
"health.clean": "All
|
|
147
|
+
"health.clean": "All checks passed.",
|
|
146
148
|
"health.level.ok": "ok",
|
|
147
149
|
"health.level.warn": "warn",
|
|
148
150
|
"health.level.skipped": "Not checked",
|
|
149
151
|
"health.level.fail": "fail",
|
|
152
|
+
"health.priority.high": "Priority",
|
|
153
|
+
"health.gate.generation": "Generation artifact",
|
|
150
154
|
"health.gate.log-integrity": "Log integrity",
|
|
151
155
|
"health.gate.projection-cache": "Projection cache",
|
|
152
156
|
"health.gate.lossless-json": "Lossless JSON",
|
|
@@ -669,12 +673,13 @@ window.__ModuleLoader__.load({
|
|
|
669
673
|
//#endregion
|
|
670
674
|
//#region src/client/health-panel.tsx
|
|
671
675
|
/**
|
|
672
|
-
*
|
|
676
|
+
* 体检面板:体检(五门)→ 处方(命令清单)→ 出院(可逆处置 + before/after 对照)。
|
|
673
677
|
*
|
|
674
678
|
* 三态流转完全由 host 侧报告驱动,客户端只做展示与触发;重型动作都在 host,
|
|
675
679
|
* 渲染周期内不发同步重活。
|
|
676
680
|
*/
|
|
677
681
|
const GATE_LABEL = {
|
|
682
|
+
"generation": "health.gate.generation",
|
|
678
683
|
"log-integrity": "health.gate.log-integrity",
|
|
679
684
|
"projection-cache": "health.gate.projection-cache",
|
|
680
685
|
"lossless-json": "health.gate.lossless-json",
|
|
@@ -1004,6 +1009,10 @@ window.__ModuleLoader__.load({
|
|
|
1004
1009
|
key: "lv",
|
|
1005
1010
|
className: `dss_levelPill dss_level_${item.level}`
|
|
1006
1011
|
}, translate(t, LEVEL_LABEL[item.level])),
|
|
1012
|
+
item.priority === "high" && (0, react.createElement)("span", {
|
|
1013
|
+
key: "p",
|
|
1014
|
+
className: "dss_meta"
|
|
1015
|
+
}, translate(t, "health.priority.high")),
|
|
1007
1016
|
(0, react.createElement)("span", {
|
|
1008
1017
|
key: "id",
|
|
1009
1018
|
className: "dss_meta dss_uuid"
|
package/lib/index.d.ts
CHANGED
|
@@ -571,6 +571,14 @@ interface SessionLogRead {
|
|
|
571
571
|
turn: number;
|
|
572
572
|
step: number;
|
|
573
573
|
};
|
|
574
|
+
/**
|
|
575
|
+
* 日志首行的 header(`type: 'session'` 记录)。
|
|
576
|
+
*
|
|
577
|
+
* 取它是为了拿到 `version`(格式代次):文件名代次与 header 代次都由宿主的
|
|
578
|
+
* 代次发布路径写入,二者一致是发布不变量。首行不是 JSON 时为 undefined,
|
|
579
|
+
* 由 `log-integrity` 门按解码问题如实报出,不在这里抛。
|
|
580
|
+
*/
|
|
581
|
+
header?: Record<string, unknown>;
|
|
574
582
|
}
|
|
575
583
|
/** 解码后的事件(结构子集)。 */
|
|
576
584
|
interface DecodedEvent {
|
|
@@ -600,7 +608,7 @@ interface OfficialDecoders {
|
|
|
600
608
|
}
|
|
601
609
|
/**
|
|
602
610
|
* 读取一个会话日志文件(zip 帧扫描 + 解包 + seq 连续性)。
|
|
603
|
-
* @param file -
|
|
611
|
+
* @param file - 当前代日志的绝对路径(由代次解析得出,不假定具体文件名)。
|
|
604
612
|
* @param bytes - 文件内容(调用方读取,便于测试注入)。
|
|
605
613
|
* @param decoders - 可选官方解码器(缺省用本地等价实现)。
|
|
606
614
|
* @returns 事件、统计与问题清单。
|
|
@@ -609,6 +617,96 @@ declare function decodeSessionLogBytes(file: string, bytes: Buffer, decoders?: O
|
|
|
609
617
|
/** 从文件读取并解码。 */
|
|
610
618
|
declare function decodeSessionLogFile(file: string, decoders?: OfficialDecoders): SessionLogRead;
|
|
611
619
|
//#endregion
|
|
620
|
+
//#region src/host/health/generation.d.ts
|
|
621
|
+
/** 日志的物理编码(对齐宿主的 `JsonlCompression`)。 */
|
|
622
|
+
type LogCompression = 'zstd' | 'none';
|
|
623
|
+
/** 处置优先级:`high` = 该会话的当前代是从暂存(TMP)发布出来的。 */
|
|
624
|
+
type SessionPriority = 'high' | 'normal';
|
|
625
|
+
/** 一份日志产物在磁盘上的事实。 */
|
|
626
|
+
interface LogArtifact {
|
|
627
|
+
/** 文件名(不含目录)。 */
|
|
628
|
+
name: string;
|
|
629
|
+
/** 绝对路径。 */
|
|
630
|
+
path: string;
|
|
631
|
+
bytes: number;
|
|
632
|
+
/** mtime(epoch ms)。 */
|
|
633
|
+
mtimeMs: number;
|
|
634
|
+
}
|
|
635
|
+
/** 一份规范代次产物。 */
|
|
636
|
+
interface GenerationArtifact extends LogArtifact {
|
|
637
|
+
/** 该文件承载的格式代次;0 为无版本号的历史代。 */
|
|
638
|
+
version: number;
|
|
639
|
+
/** 该文件的物理编码。 */
|
|
640
|
+
compression: LogCompression;
|
|
641
|
+
}
|
|
642
|
+
/** 一个会话目录的代次事实。 */
|
|
643
|
+
interface SessionGenerations {
|
|
644
|
+
/** 目录内全部规范产物,按代次升序(同代次再按 mtime 升序)。 */
|
|
645
|
+
canonical: GenerationArtifact[];
|
|
646
|
+
/** 当前代 = 规范产物中代次最高的一份;目录内没有规范产物时为 undefined。 */
|
|
647
|
+
current?: GenerationArtifact;
|
|
648
|
+
/** 历史代(代次 0);宿主按契约保留已提交的旧代次,不删不改。 */
|
|
649
|
+
legacy?: GenerationArtifact;
|
|
650
|
+
/** 迁移暂存残留(发布源)。 */
|
|
651
|
+
staging: LogArtifact[];
|
|
652
|
+
/** 只有历史代、尚无更高代次:宿主首次写访问才会发布,冷读要全量内存迁移。 */
|
|
653
|
+
legacyOnly: boolean;
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* 某代次的规范日志文件名。
|
|
657
|
+
* @param version - 非负安全整数的格式代次。
|
|
658
|
+
* @param compression - 物理编码(缺省 zstd)。
|
|
659
|
+
* @returns 该代次在会话目录内的文件名。
|
|
660
|
+
*/
|
|
661
|
+
declare function generationLogFilename(version: number, compression?: LogCompression): string;
|
|
662
|
+
/**
|
|
663
|
+
* 把一个规范日志名解析回代次。
|
|
664
|
+
*
|
|
665
|
+
* 与宿主 `parseGenerationLogFilename` 同语义:非规范名(临时、大写、前导零、
|
|
666
|
+
* `.v0`、别的压缩后缀)一律返回 undefined,**不猜**。
|
|
667
|
+
* @param filename - 会话目录里的一个文件名。
|
|
668
|
+
* @param compression - 该目录使用的物理编码(缺省 zstd)。
|
|
669
|
+
* @returns 其格式代次,或名字不构成规范代次时的 undefined。
|
|
670
|
+
*/
|
|
671
|
+
declare function parseGenerationLogFilename(filename: string, compression?: LogCompression): number | undefined;
|
|
672
|
+
/**
|
|
673
|
+
* 两种压缩编码都试一遍,判定该名字是不是某代的规范产物。
|
|
674
|
+
*
|
|
675
|
+
* 发现路径不能假设部署里的 `compression` 配置:配置在 profile 侧,插件读不到,
|
|
676
|
+
* 而日志就在磁盘上。因此按名字本身分类,编码作为结果一并带回。
|
|
677
|
+
* @param filename - 会话目录里的一个文件名。
|
|
678
|
+
* @returns 代次与编码,或该名字不是规范代次时的 undefined。
|
|
679
|
+
*/
|
|
680
|
+
declare function classifyGenerationFilename(filename: string): {
|
|
681
|
+
version: number;
|
|
682
|
+
compression: LogCompression;
|
|
683
|
+
} | undefined;
|
|
684
|
+
/**
|
|
685
|
+
* 该文件名是否是迁移暂存(当前代的发布源)。
|
|
686
|
+
* @param filename - 会话目录里的一个文件名。
|
|
687
|
+
* @returns 是否形如 `session.migration.<token>.jsonl[.zstd].tmp`。
|
|
688
|
+
*/
|
|
689
|
+
declare function isMigrationStagingFilename(filename: string): boolean;
|
|
690
|
+
/**
|
|
691
|
+
* 读取一个会话目录的代次事实(只读,不碰任何文件内容)。
|
|
692
|
+
* @param dir - 会话目录的绝对路径。
|
|
693
|
+
* @returns 规范产物(按代次升序)、当前代、历史代与暂存残留。
|
|
694
|
+
*/
|
|
695
|
+
declare function readSessionGenerations(dir: string): SessionGenerations;
|
|
696
|
+
/** 目录内全部已识别产物的最新 mtime。 */
|
|
697
|
+
declare function latestArtifactMtime(facts: SessionGenerations): number | undefined;
|
|
698
|
+
/**
|
|
699
|
+
* 该会话的处置优先级。
|
|
700
|
+
*
|
|
701
|
+
* `high` 的判据就是「从 TMP 移出来」本身:当前代次非 0(当前代是经
|
|
702
|
+
* `session.migration.*.tmp` 暂存发布出来的),或目录内仍有暂存残留。
|
|
703
|
+
* 代次 0 的历史代是宿主按契约保留的未发布会话,旧发现逻辑读的就是它 —— 这类
|
|
704
|
+
* 会话既没有发布痕迹、也没有被读错,故为 `normal`。
|
|
705
|
+
* @param facts - 会话目录的代次事实。
|
|
706
|
+
* @returns 处置优先级。
|
|
707
|
+
*/
|
|
708
|
+
declare function sessionPriority(facts: SessionGenerations): SessionPriority;
|
|
709
|
+
//#endregion
|
|
612
710
|
//#region src/host/health/gates.d.ts
|
|
613
711
|
/**
|
|
614
712
|
* gate 严重级。
|
|
@@ -636,7 +734,7 @@ interface GateAttribution {
|
|
|
636
734
|
}
|
|
637
735
|
/** 一个 gate 的结果。 */
|
|
638
736
|
interface GateResult {
|
|
639
|
-
id: 'log-integrity' | 'projection-cache' | 'lossless-json' | 'cold-read';
|
|
737
|
+
id: 'generation' | 'log-integrity' | 'projection-cache' | 'lossless-json' | 'cold-read';
|
|
640
738
|
level: GateLevel;
|
|
641
739
|
evidence: string;
|
|
642
740
|
attribution?: GateAttribution;
|
|
@@ -646,6 +744,12 @@ interface GateResult {
|
|
|
646
744
|
interface SessionHealthReport {
|
|
647
745
|
sessionId: string;
|
|
648
746
|
level: GateLevel;
|
|
747
|
+
/**
|
|
748
|
+
* 处置优先级:`high` = 该会话的当前代是从迁移暂存(TMP)发布出来的。
|
|
749
|
+
*
|
|
750
|
+
* 与 `level` 正交:优先级答「先看谁」,档位答「要不要处置」。
|
|
751
|
+
*/
|
|
752
|
+
priority: SessionPriority;
|
|
649
753
|
gates: GateResult[];
|
|
650
754
|
generatedAt: number;
|
|
651
755
|
}
|
|
@@ -658,6 +762,12 @@ interface GateContext {
|
|
|
658
762
|
logPath?: string;
|
|
659
763
|
/** 已解码的日志(复用,避免重复解码)。 */
|
|
660
764
|
log?: SessionLogRead;
|
|
765
|
+
/**
|
|
766
|
+
* 会话目录的代次事实(见 `generation.ts`)。
|
|
767
|
+
*
|
|
768
|
+
* 不提供时 `generation` 门记 `skipped`(无从判定),不猜、也不当作正常。
|
|
769
|
+
*/
|
|
770
|
+
generations?: SessionGenerations;
|
|
661
771
|
/** 热态:宿主 `sessionProjections.checkpoint(session)` 的逐行状态。 */
|
|
662
772
|
projectionState?: Record<string, unknown>;
|
|
663
773
|
/** 归属查询函数(投影 key → 包名)。 */
|
|
@@ -681,6 +791,22 @@ interface TailFacts {
|
|
|
681
791
|
}
|
|
682
792
|
/** 从解码事件推导尾部事实。 */
|
|
683
793
|
declare function readTailFacts(log: SessionLogRead): TailFacts;
|
|
794
|
+
/**
|
|
795
|
+
* gate 0:代次事实(当前代是历史代还是已发布代、有没有暂存残留)。
|
|
796
|
+
*
|
|
797
|
+
* 存在的理由:一个会话目录里可以有多份日志产物,而**读哪一份**决定了后面所有
|
|
798
|
+
* 门的结论。早期版本固定读 `session.jsonl.zstd`,于是对已发布当前代的会话要么
|
|
799
|
+
* 读错(读历史代那份,12MB 全量回放)、要么完全发现不了。本门把这个前提显式化成
|
|
800
|
+
* 可判定的证据,档位判据只取「有据可依」的三条:
|
|
801
|
+
* - 没有任何规范产物(只剩暂存)→ `fail`:当前代尚未发布;
|
|
802
|
+
* - 有暂存残留 → `warn`:发布源仍在原地(发布完成未清,或尚未发布);
|
|
803
|
+
* - 文件名代次与 header 代次不一致 → `warn`:发布不变量被破坏。
|
|
804
|
+
* 历史代与当前代并存是宿主**契约要求**(已提交代次不删不改),故记 `ok` 并写进
|
|
805
|
+
* 证据,不抬档 —— 抬档会把 34 个完全正常的会话变成噪声。
|
|
806
|
+
* @param facts - 会话目录的代次事实;缺省表示无从判定。
|
|
807
|
+
* @param log - 已解码的日志(用于取 header.version 交叉核对)。
|
|
808
|
+
*/
|
|
809
|
+
declare function gateGeneration(facts: SessionGenerations | undefined, log?: SessionLogRead): GateResult;
|
|
684
810
|
/** gate 1:日志完整性(可解码、seq 连续、无撕裂尾帧)。 */
|
|
685
811
|
declare function gateLogIntegrity(log: SessionLogRead): GateResult;
|
|
686
812
|
/** 投影缓存行的体检事实。 */
|
|
@@ -701,7 +827,7 @@ declare function gateProjectionCache(facts: ProjectionCacheFacts): GateResult;
|
|
|
701
827
|
declare function gateLosslessJson(projectionState: Record<string, unknown> | undefined, attribute?: (projection: string) => GateAttribution | undefined): GateResult;
|
|
702
828
|
/** gate 4:冷读成本与可接续性。 */
|
|
703
829
|
declare function gateColdRead(facts: TailFacts): GateResult;
|
|
704
|
-
/**
|
|
830
|
+
/** 聚合全部 gate 结果为一份报告。 */
|
|
705
831
|
declare function buildSessionReport(context: GateContext): SessionHealthReport;
|
|
706
832
|
//#endregion
|
|
707
833
|
//#region src/host/health/cache.d.ts
|
|
@@ -976,7 +1102,7 @@ declare function quarantineProjectionCache(sessionId: string, dshHome?: string,
|
|
|
976
1102
|
declare function prescribe(report: SessionHealthReport, dshHome?: string): string[];
|
|
977
1103
|
/** 处置结果的定性分类。 */
|
|
978
1104
|
type RepairVerdict =
|
|
979
|
-
/**
|
|
1105
|
+
/** 全部检查通过,没有要做的事。 */
|
|
980
1106
|
'nothing-to-do' |
|
|
981
1107
|
/** 处置生效且异常已消除。 */
|
|
982
1108
|
'repaired' |
|
|
@@ -1014,24 +1140,52 @@ declare function assessRepair(input: {
|
|
|
1014
1140
|
}): RepairAssessment;
|
|
1015
1141
|
//#endregion
|
|
1016
1142
|
//#region src/host/health/scan.d.ts
|
|
1017
|
-
/**
|
|
1143
|
+
/** 一个已发现的会话。 */
|
|
1018
1144
|
interface DiscoveredSession {
|
|
1019
1145
|
sessionId: string;
|
|
1020
|
-
|
|
1146
|
+
/** 承载日志的代次目录。 */
|
|
1147
|
+
dir: string;
|
|
1148
|
+
/**
|
|
1149
|
+
* 当前代日志路径。
|
|
1150
|
+
*
|
|
1151
|
+
* 目录内只有迁移暂存(尚未发布当前代)时为 undefined —— 该会话确实存在,
|
|
1152
|
+
* 但没有可读的规范产物,由 `generation` / `log-integrity` 两门如实报出,
|
|
1153
|
+
* 而不是当作「没有这个会话」。
|
|
1154
|
+
*/
|
|
1155
|
+
logPath?: string;
|
|
1156
|
+
/** 代次事实(当前代 / 历史代 / 暂存残留)。 */
|
|
1157
|
+
generations: SessionGenerations;
|
|
1158
|
+
/** 处置优先级:`high` = 当前代是从暂存(TMP)发布出来的。 */
|
|
1159
|
+
priority: SessionPriority;
|
|
1021
1160
|
updatedAt: number;
|
|
1022
1161
|
bytes: number;
|
|
1023
1162
|
}
|
|
1024
|
-
/**
|
|
1163
|
+
/**
|
|
1164
|
+
* 枚举全部会话(按 mtime 倒序),带可选上限。
|
|
1165
|
+
*
|
|
1166
|
+
* 「是会话目录」的判据是**目录里有规范代次产物或迁移暂存**,不要求任何具体文件名。
|
|
1167
|
+
* @param dshHome - DSH home(缺省 ~/.dsh)。
|
|
1168
|
+
* @param limit - 返回上限(缺省 `DISCOVERY_LIMIT`)。
|
|
1169
|
+
*/
|
|
1025
1170
|
declare function discoverSessions(dshHome?: string, limit?: number): DiscoveredSession[];
|
|
1026
1171
|
/**
|
|
1027
1172
|
* 语料总数:只做目录枚举,**不跑体检**。
|
|
1028
1173
|
*
|
|
1029
|
-
* 用于判断缓存是否已过期——枚举很便宜,而重扫要解 zstd
|
|
1174
|
+
* 用于判断缓存是否已过期——枚举很便宜,而重扫要解 zstd、跑门。
|
|
1030
1175
|
* 正因为两者代价差着量级,「对账」才不构成缓存失效策略本身。
|
|
1031
1176
|
* @param dshHome - DSH home(缺省 ~/.dsh)。
|
|
1032
1177
|
*/
|
|
1033
1178
|
declare function countCorpus(dshHome?: string): number;
|
|
1034
|
-
/**
|
|
1179
|
+
/** 按 id 定位一个会话(跨工程目录查找)。 */
|
|
1180
|
+
declare function findSession(sessionId: string, dshHome?: string): DiscoveredSession | undefined;
|
|
1181
|
+
/**
|
|
1182
|
+
* 定位一个会话的**当前代**日志路径(跨工程目录查找)。
|
|
1183
|
+
*
|
|
1184
|
+
* 返回 undefined 有两种含义,调用方必须区分:会话不存在,或会话存在但尚未发布
|
|
1185
|
+
* 当前代(只有迁移暂存)。需要区分时用 `findSession`。
|
|
1186
|
+
* @param sessionId - 会话 id。
|
|
1187
|
+
* @param dshHome - DSH home(缺省 ~/.dsh)。
|
|
1188
|
+
*/
|
|
1035
1189
|
declare function findSessionLog(sessionId: string, dshHome?: string): string | undefined;
|
|
1036
1190
|
/** 扫描结果。 */
|
|
1037
1191
|
interface HealthScanResult {
|
|
@@ -1056,6 +1210,9 @@ interface HealthScanResult {
|
|
|
1056
1210
|
* 语料先整体列出(按 mtime 倒序,≤ DISCOVERY_LIMIT),再按 `[offset, offset+limit)`
|
|
1057
1211
|
* 切片扫描。这样客户端可以用小批次连续调用、自己累计真实进度,而宿主保持无状态
|
|
1058
1212
|
* ——不必把同步循环改成异步,也不必新增进度轮询端点。
|
|
1213
|
+
*
|
|
1214
|
+
* 批内**命中顺序**按处置优先级排(`high` 在前,稳定排序)。分批切片仍按 mtime,
|
|
1215
|
+
* 所以 offset/total 的算术不受影响:只有同一批里的呈现顺序变了。
|
|
1059
1216
|
* @param options - dshHome / 批大小 / 批起点 / 是否只返回非 ok / 归属查询 / 热态状态提供者。
|
|
1060
1217
|
*/
|
|
1061
1218
|
declare function scanSessions(options: {
|
|
@@ -1114,4 +1271,4 @@ declare function handleMethod(method: string, payload: unknown, runtime: Steward
|
|
|
1114
1271
|
*/
|
|
1115
1272
|
declare function apply(ctx: Context): void;
|
|
1116
1273
|
//#endregion
|
|
1117
|
-
export { DEFAULT_CONFIG, HEALTH_METHODS, HISTORY_METHODS, HealthCache, type HealthCacheEntry, type RepairAssessment, type RepairVerdict, STEWARD_API_PREFIX, STEWARD_SETTINGS_NAMESPACE, type StewardConfig, StewardRuntime, apply, assessRepair, buildProjectionOwnerIndex, buildSessionReport, countCorpus, createAttributor, decodeSessionLogBytes, decodeSessionLogFile, dirSize, discoverSessions, editWorkspaceDocument, findSessionLog, firstLosslessViolation, gateColdRead, gateLogIntegrity, gateLosslessJson, gateProjectionCache, handleMethod, indexSessionDirs, inject, isLossless, isSafeChild, listHistory, locateSessionUsage, methodEnabled, prescribe, projCacheRootFor, pruneArchiveFile, pruneHistory, purgeHistory, quarantineProjectionCache, readArchiveSet, readProjectionCache, readTailFacts, scanSessions, scanZstdFrames, sessionsRootFor };
|
|
1274
|
+
export { DEFAULT_CONFIG, type DiscoveredSession, type GenerationArtifact, HEALTH_METHODS, HISTORY_METHODS, HealthCache, type HealthCacheEntry, type LogArtifact, type LogCompression, type RepairAssessment, type RepairVerdict, STEWARD_API_PREFIX, STEWARD_SETTINGS_NAMESPACE, type SessionGenerations, type SessionPriority, type StewardConfig, StewardRuntime, apply, assessRepair, buildProjectionOwnerIndex, buildSessionReport, classifyGenerationFilename, countCorpus, createAttributor, decodeSessionLogBytes, decodeSessionLogFile, dirSize, discoverSessions, editWorkspaceDocument, findSession, findSessionLog, firstLosslessViolation, gateColdRead, gateGeneration, gateLogIntegrity, gateLosslessJson, gateProjectionCache, generationLogFilename, handleMethod, indexSessionDirs, inject, isLossless, isMigrationStagingFilename, isSafeChild, latestArtifactMtime, listHistory, locateSessionUsage, methodEnabled, parseGenerationLogFilename, prescribe, projCacheRootFor, pruneArchiveFile, pruneHistory, purgeHistory, quarantineProjectionCache, readArchiveSet, readProjectionCache, readSessionGenerations, readTailFacts, scanSessions, scanZstdFrames, sessionPriority, sessionsRootFor };
|