dsh-github-copilot 0.4.0-alpha.122 → 0.4.0-alpha.124

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/AGENTS.md CHANGED
@@ -31,7 +31,7 @@ Use native DSH tools for goals, background jobs and scoped subagents. Use local
31
31
 
32
32
  `dsh-github-copilot` currently admits and targets only official DSH and Windows Desktop `0.2.0-rc.2`. Ten earlier DSH pins remain in `deployment-baseline.json` as historical evidence, not current support or CI release gates. It does not own a general Copilot chat adapter. DSH's built-in `llm-pi-ai` mount owns the GitHub Copilot provider, catalog, OAuth method and grant format, token exchange, refresh, and normal model transport.
33
33
 
34
- This repository owns eleven narrow surfaces:
34
+ This repository owns twelve narrow surfaces:
35
35
 
36
36
  1. A conditional authorization-service bootstrap plus Host controller that joins DSH authorization, credentials, and settings.
37
37
  2. A Client Models provider-card contribution with one shared account-state owner, Client-safe Remote descriptors and a nested plugin-owned model-preferences disclosure; embed in an existing configured canonical row, suppress its separate footer controller, and retain footer/old-Core section fallback when no such row is mounted.
@@ -44,6 +44,7 @@ This repository owns eleven narrow surfaces:
44
44
  9. Compatibility-only policy restoration and request recovery for existing dedicated planner/executor Sessions. Model roles UI, settings writes and new dedicated roots are retired (#158); never reintroduce them or migrate histories implicitly.
45
45
  10. Managed-route estimated input/output admission, optional exact-request pressure signalling through official compaction recovery, and supported low summary effort only when no effort is already resolved. See [compaction budgets](./docs/copilot-compaction.md). Preserve truthful capacities, requested output caps, native errors/replay and transaction ownership; no hidden history trimming, wire chunking, competing compaction service or automatic model switch. The separately selected, single-service [recovery engine](./docs/manual-compaction-recovery.md) defaults to automatic segmented recovery for known oversized summaries or one typed native capacity failure through the public subclass hook. Preserve `automaticRecovery: false`, native `auto: false`, scopes and custom engines; at most 16 physical calls including a failed first attempt, no recursive retry or 408/network/auth/quota fallback. Installation alone never selects or migrates an engine.
46
46
  11. Optional account quota reads and a session-scoped composer usage control through public credentials, strict Remotes and additive slots. Keep account billing-cycle credits separate from context tokens and session cost. Missing, pooled, legacy and stale data must retain their real semantics; never infer credits from token estimates or account deltas. A separate plugin-owned historical context projection may diagnose failed-zero readings, never filter shared native usage, replace Core's meter, infer current occupancy/percentages or rewrite history. See [quota boundaries](./docs/copilot-usage.md).
47
+ 12. Default-off local account/Checking/compaction diagnostics through public storage-domain and strict additive Remotes. Keep fixed-dimension Client/Host and logical/physical populations separate, with bounded handles/rows, 14-day retention, explicit loss/uncertainty and native commit evidence. Isolate the home-wide backend by public profile context, never account/Session identity; one writer per profile is required. No content, raw errors, identities/hashes, credential/history reads, ad-hoc files, Settings logs, upload, daily task or automatic repair. Enable/pause uses only the hidden volatile `diagnosticsEnabled` CAS leaf; clear is a separately confirmed epoch fence. Missing/corrupt storage remains unavailable, never healthy empty data. Publication does not enable collection. See [local diagnostics](./docs/plugin-diagnostics.md).
47
48
 
48
49
  ## Session-policy compaction replay consent (#349, #352)
49
50
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.0-alpha.124 (prepared)
4
+
5
+ - Plan compaction from model-facing content and tools instead of serializing native IDs, provenance and opaque replay envelopes, fixing metadata-driven exhaustion of the unchanged 16-call bound (#352).
6
+ - Retain fixed system/tools and balanced tool units when reducing the budget after one typed native capacity failure; reject an indivisible unchanged retry. Preserve actual messages, final native admission, cancellation, account proof, diagnostics and single native checkpoint commit.
7
+ - Add exact-source native admission/transaction regression with synthetic metadata-heavy history. Synthetic tests do not establish live recovery; no automatic Session replay, engine migration or new timeout/network retry.
8
+
9
+ ## 0.4.0-alpha.123 (prepared)
10
+
11
+ - Add default-off local account/Checking/compaction diagnostics with strict fixed-dimension counts, elapsed/unfinished age bins, separate Client/Host populations and explicit cancellation, rejection, interruption and reporting gaps (#347, #356).
12
+ - Persist a 14-day, 4,096-row/2 MiB aggregate snapshot through the public storage-domain service, isolating profiles on the home-wide backend. Add enable/pause, separately confirmed clear and aggregate-only JSON review; preserve restart interruption, control epochs, business ownership and named storage failures.
13
+ - No account/Session identity, content, replay, raw errors or credentials enter aggregates. No automatic uploads, daily tasks, repair, retries, live-profile install or activation; native/custom-engine and other unwrapped paths remain explicit coverage gaps.
14
+
3
15
  ## 0.4.0-alpha.121 (prepared)
4
16
 
5
17
  - Add explicit `/copilot-compact visible-history` consent for one lossy managed Responses summary operation after replay-scope rejection (#349). Preserve visible messages/tool pairs, native directive, route/cap, cancellation, source history and single transactional commit; no automatic retry, hidden settings change or live execution.
package/README.md CHANGED
@@ -25,7 +25,7 @@ Visible Models and Credits resolve missing names for saved accounts without acti
25
25
 
26
26
  Adding an account now keeps the device-authorization link, selectable URL, one-time code, Copy code action and Cancel together while authorization is pending. After GitHub authorizes, identity and model verification are shown as a separate phase. Adding never changes the global default; use the existing explicit **Switch** action when ready. Technical diagnostics are secondary, and account/turn identity fallbacks never expose opaque account IDs or infer historical identity from today's settings.
27
27
 
28
- **Source candidate: `0.4.0-alpha.122` (unreleased). Supported host: official DSH / Windows Desktop `0.2.0-rc.2`.** Earlier DSH pins are historical evidence, not supported installation targets. Publication, profile installation and the version loaded by a running Host are separate states. The versioned commands below are for this candidate after publication, not evidence that its assets exist.
28
+ **Package version: `0.4.0-alpha.124`. Supported host: official DSH / Windows Desktop `0.2.0-rc.2`.** Earlier DSH pins are historical evidence, not supported installation targets. Publication, profile installation and the version loaded by a running Host are separate states. Verify the published Release and assets before using the versioned commands below; these instructions do not prove publication or installation.
29
29
 
30
30
  ## What you can do
31
31
 
@@ -46,6 +46,15 @@ prefers unmarked eligible Lightweight models separately. Advisor calls are not
46
46
  implemented. See [requirements](./docs/auto-high-cost.md) and the
47
47
  [required iteration review](./docs/evidence-driven-iteration.md).
48
48
 
49
+ The [local diagnostics pilot](./docs/plugin-diagnostics.md) records bounded
50
+ account/Checking and compaction aggregates, **default off**. After installing
51
+ and loading the published build, open the plugin detail settings page →
52
+ **Local diagnostics → Read status → Enable local collection**. This enables
53
+ local persistence, not uploads or daily analysis. Pause preserves evidence;
54
+ Clear requires separate confirmation. Client/Host populations, uncovered paths
55
+ and reporting/storage gaps remain explicit. Normal use supplies future evidence,
56
+ not reconstructed history or proof of an improvement.
57
+
49
58
  | Task | Where to start |
50
59
  |---|---|
51
60
  | Sign in and manage account models | **Settings → Models → GitHub Copilot → Sign in** |
@@ -82,10 +91,10 @@ Supply any launcher patches with repeated `--patch /absolute/file`. Require `sup
82
91
  For a **standalone named profile**:
83
92
 
84
93
  ```sh
85
- dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.122/dsh-github-copilot-0.4.0-alpha.122.tgz
94
+ dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.124/dsh-github-copilot-0.4.0-alpha.124.tgz
86
95
  ```
87
96
 
88
- For **Desktop**, its native package manager accepts `dsh-github-copilot@0.4.0-alpha.122` after publication. Official rc.2's **Desktop-bundled CLI** also supports reserved-profile plugin management; a global/generic `dsh` shim is not equivalent. Qualify the installed entry before use. See [Desktop CLI qualification](./docs/npm-distribution.md#desktop-bundled-cli-on-official-rc2) and the distinct [standalone offline procedure](./docs/npm-distribution.md#controlled-offline-cli-maintenance-for-standalone-profiles). Neither path authorizes registry-policy bypass, peer patches or configuration deletion.
97
+ For **Desktop**, its native package manager accepts `dsh-github-copilot@0.4.0-alpha.124` after publication. Official rc.2's **Desktop-bundled CLI** also supports reserved-profile plugin management; a global/generic `dsh` shim is not equivalent. Qualify the installed entry before use. See [Desktop CLI qualification](./docs/npm-distribution.md#desktop-bundled-cli-on-official-rc2) and the distinct [standalone offline procedure](./docs/npm-distribution.md#controlled-offline-cli-maintenance-for-standalone-profiles). Neither path authorizes registry-policy bypass, peer patches or configuration deletion.
89
98
 
90
99
  After an approved reload/restart:
91
100
 
@@ -158,6 +167,8 @@ Native context occupancy and Turn Usage remain Core-owned. The plugin forwards u
158
167
 
159
168
  Owned timeout/replay errors preserve native usage before terminal failure restoration, including nonzero samples. A failed zero can still make the native ring show `0%`; this is not proof of an empty request. Retry-entry times describe backoff, not the failed request's duration. These accounting fixes do not cure supplier HTTP 408 or change retry policy.
160
169
 
170
+ Compaction planning prices model-facing content and tools, not native IDs/provenance or opaque replay envelopes, avoiding metadata-driven exhaustion of the 16-call limit. The original messages/replay remain unchanged; final native admission still checks converted input. A typed capacity fallback keeps fixed prefixes and balanced tool units, never repeats an indivisible rejected input. This is conservative planning, not provider-exact token accounting.
171
+
161
172
  Managed request admission preserves truthful input/output limits and native transactions. Automatic pressure uses the initiating Agent's actual bound compaction service; a preset without an engine cannot borrow global recovery. The separately selected [recovery engine](./docs/manual-compaction-recovery.md) defaults to automatic segmented fallback for oversized summaries or an explicit summary context-limit failure. Fitting summaries stay native; timeout/408/auth/quota failures do not trigger segmentation. Up to 16 calls may add time and charges; cancellation or incomplete recovery never commits a partial summary. `automaticRecovery: false` disables this fallback; native `auto: false` still disables automatic compaction. Installation alone does not select the engine: follow the explicit same-scope configuration migration, preserving preset/custom-engine ownership and existing policies.
162
173
 
163
174
  For continuing steps with a committed managed route and no pending model change, known input pressure is reduced before Core opens the next model attempt. Successful native reduction avoids an unsampled local-pressure attempt that would make whole-turn Usage unavailable. First steps, pending selections, new fixed-prefix growth and final hard-budget refusals retain existing admission; this does not repair historical totals or invent missing usage.
@@ -249,14 +260,14 @@ Commit attribution uses `Assisted-by` with the actual tool, never the model prov
249
260
  GitHub Releases and npm distribute the same original verified tarball. Pin a version; verify Release SHA-256 or npm `dist.integrity`. Never repack an immutable release or move/reuse its tag.
250
261
 
251
262
  ```sh
252
- curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.122/dsh-github-copilot-0.4.0-alpha.122.tgz
253
- curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.122/SHA256SUMS
263
+ curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.124/dsh-github-copilot-0.4.0-alpha.124.tgz
264
+ curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.124/SHA256SUMS
254
265
  sha256sum --check SHA256SUMS
255
266
  ```
256
267
 
257
268
  ```powershell
258
269
  $expected = (Get-Content .\SHA256SUMS).Split()[0]
259
- $actual = (Get-FileHash .\dsh-github-copilot-0.4.0-alpha.122.tgz -Algorithm SHA256).Hash.ToLowerInvariant()
270
+ $actual = (Get-FileHash .\dsh-github-copilot-0.4.0-alpha.124.tgz -Algorithm SHA256).Hash.ToLowerInvariant()
260
271
  if ($actual -cne $expected) { throw 'Release checksum mismatch' }
261
272
  ```
262
273
 
package/README.zh.md CHANGED
@@ -22,7 +22,7 @@ Models 和 Chat 共用不透明、随主题适配的账号下拉层;原生菜
22
22
 
23
23
  添加账号时,设备授权链接、可选择的网址、一次性授权码、复制授权码和取消操作会同时显示。GitHub 授权完成后,会单独显示身份与可用模型验证阶段。添加账号不会更改全局默认;准备好后仍需显式执行现有的**切换**操作。技术诊断收在次级折叠区;账号/历史 turn 缺少身份时不会暴露不透明账号 ID,也不会根据当前设置推断历史身份。
24
24
 
25
- **源码候选版本:`0.4.0-alpha.122`(尚未发布)。支持宿主:官方 DSH / Windows Desktop `0.2.0-rc.2`。** 较早 DSH pin 仅是历史证据,不是当前安装目标。已发布、已安装到 profile、已被运行中的 Host 加载,是三个不同状态。下方带版本的命令适用于候选版本发布后,不代表对应资产已经存在。
25
+ **包版本:`0.4.0-alpha.124`。支持宿主:官方 DSH / Windows Desktop `0.2.0-rc.2`。** 较早 DSH pin 仅是历史证据,不是当前安装目标。已发布、已安装到 profile、已被运行中的 Host 加载,是三个不同状态。执行下方带版本的命令前须核验正式发布与资产;这些说明不证明已发布或已安装。
26
26
 
27
27
  ## 你可以做什么
28
28
 
@@ -38,6 +38,13 @@ Models 和 Chat 共用不透明、随主题适配的账号下拉层;原生菜
38
38
  合格 Lightweight 模型。顾问求助尚未实现。参见[完整需求](./docs/auto-high-cost.md)
39
39
  与[强制迭代评审流程](./docs/evidence-driven-iteration.md)。
40
40
 
41
+ [本地诊断试点](./docs/plugin-diagnostics.md)记录有界的账号/Checking 与压缩
42
+ 汇总,**默认关闭**。安装并加载已发布版本后,进入插件详情设置页 →
43
+ **Local diagnostics → Read status → Enable local collection**,开启本地持久化;
44
+ 不上传,不启用每日分析。暂停保留证据,清除需单独确认。Client/Host 分开统计,
45
+ 未覆盖路径、报告丢失与存储故障明确显示。正常使用产生后续优化所需的证据,
46
+ 不会重建历史错误率,也不表示优化效果已被验证。
47
+
41
48
  | 任务 | 入口 |
42
49
  |---|---|
43
50
  | 登录并管理账号模型 | **设置 → 模型 → GitHub Copilot → Sign in** |
@@ -74,10 +81,10 @@ node package/scripts/check-search-composition.mjs --profile-dir /absolute/profil
74
81
  **独立具名 profile**:
75
82
 
76
83
  ```sh
77
- dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.122/dsh-github-copilot-0.4.0-alpha.122.tgz
84
+ dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.124/dsh-github-copilot-0.4.0-alpha.124.tgz
78
85
  ```
79
86
 
80
- **Desktop** 原生包管理器在发布后接受 `dsh-github-copilot@0.4.0-alpha.122`。官方 rc.2 **Desktop 随附的专属 CLI**也支持管理保留 profile;全局/普通 `dsh` shim 不等价。使用前核验实际安装入口,参见[Desktop CLI 核验](./docs/npm-distribution.md#desktop-bundled-cli-on-official-rc2)及独立的[具名 profile 离线流程](./docs/npm-distribution.md#controlled-offline-cli-maintenance-for-standalone-profiles)。两种路径都不授权绕过包源政策、修改 peer 或删除配置。
87
+ **Desktop** 原生包管理器在发布后接受 `dsh-github-copilot@0.4.0-alpha.124`。官方 rc.2 **Desktop 随附的专属 CLI**也支持管理保留 profile;全局/普通 `dsh` shim 不等价。使用前核验实际安装入口,参见[Desktop CLI 核验](./docs/npm-distribution.md#desktop-bundled-cli-on-official-rc2)及独立的[具名 profile 离线流程](./docs/npm-distribution.md#controlled-offline-cli-maintenance-for-standalone-profiles)。两种路径都不授权绕过包源政策、修改 peer 或删除配置。
81
88
 
82
89
  经批准 reload/restart 后:
83
90
 
@@ -150,6 +157,8 @@ Copilot 搜索要求当前账号/协议证据及能力 proof。固定/fallba
150
157
 
151
158
  插件恢复 timeout/replay 结构化错误前会保留原生 usage,包括非零采样。失败的零采样仍可能让原生圆环显示 `0%`,不代表请求上下文为空。重试条目的耗时表示退避等待,不是失败请求耗时;用量修复不等于解决供应方 HTTP 408,也不改变重试策略。
152
159
 
160
+ 压缩规划只估算模型可见内容和工具,不把原生 ID/来源信息或不透明 replay 信封计入预算,避免元数据导致耗尽 16 次调用。原消息和 replay 保持不变,最终原生准入仍检查转换后的输入。明确容量错误的兜底保留固定前缀和完整工具调用组,不原样重发不可拆分的失败输入。这是保守规划,不是供应商精确 token 计量。
161
+
153
162
  托管请求准入保留真实输入/输出上限和原生事务。自动压力使用发起 Agent 真正绑定的压缩服务;preset 无引擎时不能借用全局恢复。另行选用的[恢复引擎](./docs/manual-compaction-recovery.md)默认对已超限摘要或明确的摘要上下文超限错误启用自动分段兜底。能一次完成的摘要仍走原生流程;超时/408/认证/额度错误不会触发分段。最多 16 次调用可能增加耗时和费用,取消或恢复未完成不会提交半成品摘要。`automaticRecovery: false` 仅关闭自动分段,原生 `auto: false` 仍关闭自动压缩。仅安装插件不会选用该引擎:需按文档显式替换同一作用域的引擎配置,保留 preset/自定义引擎所有权及原有策略。
154
163
 
155
164
  同一轮后续步骤已有托管路由、且没有待切换模型时,已知输入压力会在 Core 开始下次模型尝试之前压缩。原生压缩成功可避免一次无 usage 样本的本地压力拒绝导致整轮 Usage 不可用。首次步骤、待切换模型、新增固定前缀膨胀与最终硬预算拒绝仍保留原有准入;不会修复历史总量或虚构缺失用量。
@@ -241,14 +250,14 @@ Agent 从 `node scripts/agent.mjs describe --json`、`doctor --json`及`plan <ta
241
250
  GitHub Releases 和 npm 分发同一原始已校验 tarball。固定版本并核验 Release SHA-256 或 npm `dist.integrity`;不重打包不可变 Release、不移动/复用 tag。
242
251
 
243
252
  ```sh
244
- curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.122/dsh-github-copilot-0.4.0-alpha.122.tgz
245
- curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.122/SHA256SUMS
253
+ curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.124/dsh-github-copilot-0.4.0-alpha.124.tgz
254
+ curl -LO https://github.com/cloga/dsh-github-copilot/releases/download/v0.4.0-alpha.124/SHA256SUMS
246
255
  sha256sum --check SHA256SUMS
247
256
  ```
248
257
 
249
258
  ```powershell
250
259
  $expected = (Get-Content .\SHA256SUMS).Split()[0]
251
- $actual = (Get-FileHash .\dsh-github-copilot-0.4.0-alpha.122.tgz -Algorithm SHA256).Hash.ToLowerInvariant()
260
+ $actual = (Get-FileHash .\dsh-github-copilot-0.4.0-alpha.124.tgz -Algorithm SHA256).Hash.ToLowerInvariant()
252
261
  if ($actual -cne $expected) { throw 'Release checksum mismatch' }
253
262
  ```
254
263
 
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "package": {
10
10
  "name": "dsh-github-copilot",
11
- "version": "0.4.0-alpha.122"
11
+ "version": "0.4.0-alpha.124"
12
12
  },
13
13
  "evidence": {
14
14
  "kind": "source-and-synthetic-test-inventory",
@@ -252,7 +252,7 @@
252
252
  "piAi": "0.87.1",
253
253
  "runtimeDependencies": {
254
254
  "@earendil-works/pi-ai": "0.87.1",
255
- "zod": "^4.4.3"
255
+ "zod": "4.6.5"
256
256
  },
257
257
  "sharedPeerDependencies": {
258
258
  "@deepseek-ai/dsh-authorization": "0.2.0-rc.2",
@@ -288,6 +288,28 @@
288
288
  ]
289
289
  },
290
290
  "capabilities": [
291
+ {
292
+ "id": "copilot-local-diagnostics",
293
+ "required": true,
294
+ "evidenceScope": "synthetic-collector-ui-native-gateway-storage-and-settings-not-live-reliability",
295
+ "activation": "default-off-explicit-profile-local-enable",
296
+ "sourceMarkers": [
297
+ {"file": "src/diagnostics-types.ts", "marker": "DIAGNOSTICS_MAX_BYTES = 2 * 1024 * 1024"},
298
+ {"file": "src/diagnostics-collector.ts", "marker": "noteClientGaps"},
299
+ {"file": "src/diagnostics-host.ts", "marker": "diagnosticsDomainForProfile"},
300
+ {"file": "src/diagnostics-client.ts", "marker": "createClientDiagnosticsScope"},
301
+ {"file": "src/remote.ts", "marker": "...diagnosticsRemote.descriptors"},
302
+ {"file": "src/config.ts", "marker": "diagnosticsEnabled:"},
303
+ {"file": "AGENTS.md", "marker": "Default-off local account/Checking/compaction diagnostics"}
304
+ ],
305
+ "tests": [
306
+ {"file": "tests/diagnostics-collector.spec.ts", "name": "is disabled until enabled, records success denominators and settles once"},
307
+ {"file": "tests/diagnostics-client.spec.ts", "name": "rejects stale status responses and settles an unmounted Checking operation once"},
308
+ {"file": "tests/diagnostics-card.spec.ts", "name": "requires a confirmed durable enable and a separate destructive clear confirmation"},
309
+ {"file": "tests/fixtures/diagnostics-storage-core.fixture.ts", "name": "isolates profiles on the home-wide backend and preserves memory on a real publish failure"},
310
+ {"file": "tests/fixtures/diagnostics-gateway-core.fixture.ts", "name": "binds diagnostics through actual strict Client and Host gateways with durable enable and clear fences"}
311
+ ]
312
+ },
291
313
  {
292
314
  "id": "copilot-session-accounts",
293
315
  "required": true,
@@ -574,6 +596,8 @@
574
596
  {"file": "src/manual-compaction-recovery.ts", "marker": "extends BasicCompactionEngine"},
575
597
  {"file": "src/manual-compaction-recovery.ts", "marker": "automaticRecovery: z.boolean().default(true)"},
576
598
  {"file": "src/manual-compaction-recovery.ts", "marker": "maxCalls: failedAttempt ? 15 : 16"},
599
+ {"file": "src/manual-compaction-recovery.ts", "marker": "reduceCompactionInputLimit(input, inputLimit)"},
600
+ {"file": "src/compaction-input-estimate.ts", "marker": "export function estimateCompactionInputBytes"},
577
601
  {"file": "src/manual-compaction-recovery.ts", "marker": "COPILOT_MANUAL_RECOVERY_"},
578
602
  {"file": "src/background-compaction.ts", "marker": "copilot-compact"},
579
603
  {"file": "src/compaction-replay.ts", "marker": "request.purpose !== 'compaction'"},
@@ -586,6 +610,7 @@
586
610
  ],
587
611
  "tests": [
588
612
  {"file": "tests/manual-compaction-recovery.spec.ts", "name": "reduces an oversized balanced history with bounded complete calls and an unmarked aggregate audit"},
613
+ {"file": "tests/compaction-input-estimate.spec.ts", "name": "avoids metadata-driven sixteen-call exhaustion without changing dispatched messages"},
589
614
  {"file": "tests/manual-compaction-recovery.spec.ts", "name": "rejects an indivisible span before dispatch and leaves recovery to native failure handling"},
590
615
  {"file": "tests/manual-compaction-recovery.spec.ts", "name": "rejects unmatched tool calls before dispatch instead of splitting a call and result"},
591
616
  {"file": "tests/background-compaction.spec.ts", "name": "acknowledges before completion and outlives a five-minute caller deadline"},
@@ -12,9 +12,11 @@ Recovery must leave the original Session surface intact until a smaller *complet
12
12
 
13
13
  `CopilotManualRecoveryCompactionEngine` is an opt-in alternative to **one** official `BasicCompactionEngine` registration. Operators selecting it must replace (not mount alongside) their existing basic compaction service in the same Host scope; the default plugin registration never changes the service. It subclasses the published engine: Core still owns automatic triggering/retries, manual idle maintenance, a single bracketed durable transaction, balanced range selection, checkpoint framing, source-stability/shrink checks, cancellation, failure classification, flush, and optional native pruning. With an authenticated, current managed Copilot summary model, the same hook handles manual and automatic summaries. All other providers delegate unchanged. A pending model picker is not summary-route evidence: an explicit native summary target wins, then the latest committed header, then Agent options.
14
14
 
15
- `automaticRecovery` defaults to `true` in this engine's config. Set it to `false` to retain stock automatic single-summary behavior while keeping manual segmented recovery. Native `auto: false`, `maxOverflowRetries`, thresholds and model policies retain their meaning; no background command or second transaction is launched by automatic recovery. A fitting summary first uses the unchanged native single call. A known oversized input directly enters segmented recovery. Only an actual native `LlmError` with `CONTEXT_WINDOW_EXCEEDED` from that first single summary permits one fallback, with a conservative bound at most half its original serialized input size. The rejected request is never resubmitted unchanged, and a segment failure is never recursively retried. HTTP 408, timeout, auth, quota, network, cancellation, empty or truncated output do not authorize fallback.
15
+ `automaticRecovery` defaults to `true` in this engine's config. Set it to `false` to retain stock automatic single-summary behavior while keeping manual segmented recovery. Native `auto: false`, `maxOverflowRetries`, thresholds and model policies retain their meaning; no background command or second transaction is launched by automatic recovery. A fitting summary first uses the unchanged native single call. A known oversized input directly enters segmented recovery. Only an actual native `LlmError` with `CONTEXT_WINDOW_EXCEEDED` from that first single summary permits one fallback. Its planning bound halves the partitionable history while retaining the fixed system head/tools and enough space for the largest balanced unit, never exceeding the original bound. If that requires the entire rejected input, fail as indivisible instead of resubmitting it unchanged. A segment failure is never recursively retried. HTTP 408, timeout, auth, quota, network, cancellation, empty or truncated output do not authorize fallback.
16
16
 
17
- The plugin's account service supplies a current descriptor and a revocable proof for the explicit initiating Agent, not another Session or today's global account. Each physical summary uses public initiator scoping; no credential discovery or Client credential reads are added. Account/selection changes revoke the proof. The summary budget uses `min(maxInputTokens, contextWindow - configuredOutputCap) - safetyTokens`; an additional 4096-token allowance covers Core's appended directive and estimation variance, and actual tool-history bytes are reserved separately. Each candidate request is conservatively bounded by serialized UTF-8 size including system, tools, prior intermediate checkpoint and current messages. Native managed-route admission remains the final authority. A segment that still exceeds that guard fails; it is never retried with a hidden wire rewrite.
17
+ The plugin's account service supplies a current descriptor and a revocable proof for the explicit initiating Agent, not another Session or today's global account. Each physical summary uses public initiator scoping; no credential discovery or Client credential reads are added. Account/selection changes revoke the proof. The summary budget uses `min(maxInputTokens, contextWindow - configuredOutputCap) - safetyTokens`; an additional 4096-token allowance covers Core's appended directive and estimation variance, and actual tool-history bytes are reserved separately. Each candidate is planned using conservative serialized UTF-8 **model-content bytes**: role/content, tool-result call ID/error state, tool schemas, the system head and prior intermediate checkpoint. Native message IDs, source/provenance and opaque replay envelopes are not serialized or charged by this planner. They previously inflated segment counts despite not being ordinary prompt content, causing otherwise compressible histories to exhaust 16 calls.
18
+
19
+ This is not provider-exact token accounting or a complete wire-size bound. The original messages, sources and replay are still passed unchanged to the published adapter; existing consent alone controls outgoing replay filtering. The final native managed-route guard prices converted replay, images and the complete request and remains authoritative. A segment that still exceeds that guard fails; it is never recursively retried or rewritten. Excluding metadata from planning neither bypasses admission nor authorizes additional loss.
18
20
 
19
21
  The hook partitions the *original* span only at balanced boundaries, summarizes each part through `super.summarize`, and supplies the previous completed intermediate checkpoint as context for the next call. Thus the last completed summary contains all processed parts in chronological order. The engine allows at most 16 physical summary calls per hook invocation, including any initial capacity failure (the exported helper's hard maximum remains 32). Each carries the native cancellation signal and checks account proof before and after dispatch. The original surface is not modified between calls. Core checks for a smaller replacement and current source after the final result; any failure closes the native marker without a partial summary replacement. Native pruning that already committed remains Core-owned. Native automatic retry/rebuild resumes the task only after a valid durable reduction.
20
22
 
@@ -45,7 +47,7 @@ For a verified `COPILOT_RESPONSES_REPLAY_SCOPE_MISMATCH`, repeating the same sum
45
47
 
46
48
  Consent is local to the native summarizer's exact cancellation signal, Session and summary model, including its bounded segments. It is revoked on completion, failure, cancellation or teardown. No unrelated request, subsequent command or automatic retry inherits it. Unknown or incomplete reasoning fails closed. No replay is decrypted, fabricated or written back; original source events remain unchanged and only Core can commit the final smaller checkpoint. The command adds no retry or model/account switch, and does not repair supplier scope. Missing managed integration or an unsupported summary route fails explicitly.
47
49
 
48
- The original conservative input/segmentation estimate still includes native history before outgoing filtering. Giant indivisible units, fixed prefixes, bounded-work/call limits, truncation and failure to shrink can still prevent recovery. This command is not guaranteed to rescue every history, and summary calls may incur charges. Installation alone neither selects the engine nor runs this command.
50
+ The conservative content estimate still includes visible native history before outgoing filtering, but not source/replay metadata. Giant indivisible units, fixed prefixes, native admission, bounded-work/call limits, truncation and failure to shrink can still prevent recovery. This command is not guaranteed to rescue every history, and summary calls may incur charges. Installation alone neither selects the engine nor runs this command.
49
51
 
50
52
  Background status now exposes only allowlisted fixed failure codes through bounded native Error cause chains, including replay-scope rejection; raw exception text, response bodies and history remain excluded. Unknown failures retain `COPILOT_BACKGROUND_COMPACTION_FAILED` with guidance to the native `compaction/end` record. An admission receipt is not success; check status and the native transaction.
51
53
 
@@ -59,7 +61,7 @@ This aggregate is not per-call attribution: it cannot reconstruct which intermed
59
61
 
60
62
  The exact rc.2 `llm-pi-ai` public adapter converts both plain and replay-backed historical assistant messages with `emptyPiUsage()` and `timestamp: 0` (`replay.ts`); converted user messages, including new intermediate checkpoints, also have timestamp zero (`context.ts`). Therefore creating a checkpoint **does not** invalidate an old SDK usage anchor through a newer timestamp. On this pin, Core does not carry the historical assistant usage into the SDK context in the first place. Recovery neither clears that usage itself nor changes message timestamps, replay state, native conversion, the SDK estimator or the final managed guard. This behavior must be requalified when the Core/pi-ai pin changes.
61
63
 
62
- The unchanged-Core fixture exercises the real managed adapter and its `inspectRequest` guard with a synthetic 27-turn history whose latest provider-reported input is 508,198 tokens. It first proves stock manual compaction fails the 12,000-token input bound without reaching the synthetic wire, then proves the opt-in engine commits one replacement through bounded calls. The captured SDK estimates include the complete native compaction directive, system policy and tool schemas, not a prompt with its final directive removed. Every dispatched estimate fits the hard limit; the 8,192 output cap is preserved, source events remain byte-identical, and every intermediate wire call observes the original surface generation. Estimator instrumentation calls the original SDK utility without altering its result. The fixture verifies zero carried usage anchors, aggregate usage and the deliberately absent single-call marker. Synthetic scaled-down input limits and transport establish native admission/transaction behavior, not provider-exact capacity or live Copilot success.
64
+ The unchanged-Core fixture exercises the real managed adapter and its `inspectRequest` guard with a synthetic 27-turn history whose latest provider-reported input is 508,198 tokens, plus 3.5 KB of synthetic native provenance/replay padding per assistant. The old whole-message planner exhausted exactly 16 calls on this metadata-heavy fixture without replacement. The content planner first proves stock manual compaction fails the 12,000-token input bound without reaching the synthetic wire, then proves the opt-in engine commits one replacement through bounded calls. The captured SDK estimates include the complete native compaction directive, system policy and tool schemas, not a prompt with its final directive removed. Every dispatched estimate fits the hard limit; the 8,192 output cap is preserved, source events remain byte-identical, and every intermediate wire call observes the original surface generation. Estimator instrumentation calls the original SDK utility without altering its result. The fixture verifies zero carried usage anchors, aggregate usage and the deliberately absent single-call marker. Synthetic scaled-down input limits and transport establish native admission/transaction behavior, not provider-exact capacity or live Copilot success.
63
65
 
64
66
  ## Limitations and operational use
65
67