@foliox/transparent-compact-pi 0.9.3 → 0.10.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/CHANGELOG.md CHANGED
@@ -1,5 +1,66 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.10.0
4
+
5
+ - Clarify the context readout: label delta as net, show measured tail inclusion,
6
+ and show combined notice-cost changes after the tail as `+~N scaffolding`,
7
+ without a separate row or breakdown. Keep the last completed readout visible
8
+ during recalculation to avoid loading/color flashes on each selection.
9
+ Remove the `reply/framing` label.
10
+ Replace `cap warn` labels with plain-language size-limit information only when
11
+ the preview was actually shortened. Add small-turn/adjacent-user regressions
12
+ reconciling content savings with generated-notice overhead.
13
+
14
+ - Add a live whole-context size readout to turn selection and review: estimated
15
+ input tokens/window usage, delta from saved context, and reserve-aware headroom.
16
+ Preview the actual capped checkpoint and native expansions with current
17
+ system/tool overhead, without dialogs, writes or model calls. Discard stale
18
+ estimates and label unavailable sizes rather than inventing zero-token counts.
19
+
20
+ - Simplify `/compact-filtered` to ordinary compaction followed by the shared
21
+ `/filter-turns` editor. The checkpoint is committed before selection; cancelling
22
+ the picker leaves that compaction intact. With nothing new to compact, edit the
23
+ existing checkpoint instead. Failed/cancelled compactions never open controls.
24
+ Remove the special interactive compaction-hook path and its request sentinel.
25
+
26
+ - Add whole-turn context modes: `[X] PRUNED`, `[ ] PROSE`, `[○] PROSE+TOOLS`, and
27
+ `[■] FULL`; preserve `[-] LOCKED`. Space retains the prune/restore shortcut;
28
+ `f` cycles modes, including from agent/tool subentries. Preview native content,
29
+ explicit mode transitions and estimated token growth.
30
+ - Reinsert selected original messages at their chronological positions without
31
+ compacted/startup-read duplicates. PROSE+TOOLS retains complete recorded tools
32
+ with thinking markers; FULL retains recorded thinking/signatures and images.
33
+ Persist reversible branch-local choices through reload and later compactions,
34
+ respect explicit context edits, protect native turns from trimming, and reject
35
+ oversized selections rather than silently losing fidelity. Normal provider
36
+ compatibility transformations still apply.
37
+
38
+ - Clarify the filtering TUI with framed selection/review steps, a highlighted
39
+ focused row, numbered turns, semantic action labels and fixed keyboard controls.
40
+ Separate preview instructions from turn content and show a change summary.
41
+
42
+ - Add `/filter-turns` to immediately filter or restore an existing checkpoint,
43
+ without compacting additional history, moving the boundary or starting an agent
44
+ turn. Persist branch-local revisions, refresh reorientation for each revision,
45
+ and carry choices into later verbatim or summary compaction. Recent messages
46
+ remain untouched; pending pre-flags can still be cancelled.
47
+
48
+ - Add `/filter-later <message>` (alias `/fl`) to submit a normal user turn pre-flagged for future
49
+ filtering. Add branch-local `/filter-auto on|off` (default off) to apply eligible
50
+ user pre-flags during verbatim threshold/overflow compaction without a picker.
51
+ - Allow previously filtered turns to be unchecked and restored using `/filter-turns`
52
+ or manual filtered compaction. Preview restorations and pending-flag cancellations; preserve
53
+ canonical startup-read and file-operation metadata for reversible checkpoints.
54
+ Explicit keep/restore decisions prevent automatic re-filtering of the same aside.
55
+
56
+ - Add `/compact-filtered` for optional manual whole-turn filtering in the terminal:
57
+ ordinary compaction followed by tree-like selection and scrollable confirmation.
58
+ Cancelling turn edits leaves the completed compaction and original history intact. Replace excluded groups with `[Turn manually filtered]`, remove their
59
+ retained startup-read copies and exclusive file-list paths, and explain the
60
+ marker conditionally in the checkpoint and reorientation. Exclusions persist
61
+ through later verbatim compactions and follow the active branch; original
62
+ history remains recoverable. Recent-tail turns cannot be partially filtered.
63
+
3
64
  ## 0.9.3
4
65
 
5
66
  - Restore the `706b04b` advertisements for lookup, listing, and grep, including the
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # transparent-compact
2
2
 
3
3
  Deterministic context compaction for [Pi](https://pi.dev/), with session-backed
4
- recovery. By default, replaces Pi's model-generated compaction summary with a verbatim
4
+ recovery. Replaces Pi's model-generated compaction summary with a verbatim
5
5
  compaction, with a checkpoint built mechanically from conversation text. Thinking and most tool outputs are removed
6
6
  from the active model context, while user inputs, assistant text and selected startup reads are retained verbatim.
7
7
  Tool calls and custom messages are reduced to short stubs; custom-message bodies remain recoverable from the session.
@@ -9,8 +9,9 @@ Verbatim compaction itself makes no model call. When a missing detail is needed,
9
9
  full raw branch and returns only relevant findings.
10
10
  The goal is to let the agent withstand many (but finite) rounds of compaction without the copy-of-a-copy degradation of model-summary compaction, which is exacerbated in sub-frontier models.
11
11
 
12
- The method is functionally similar to pi-vcc, but is specifically aimed at lighter weight models
13
- such as **Qwen 3.8 27B** or **GPT-6 Luna**. The design principle is that:
12
+ Additionally, a manual filtering tool is provided to allow the user to selectively include or exclude full turns in the context checkpoint, at varying degrees of fidelity.
13
+
14
+ The design principle is that:
14
15
 
15
16
  - All algorithmic or model-based manipulation of prose has the potential to confound the model later, and should be avoided for as long as possible.
16
17
  - History retrieval should be parsimonious, explicitly clear to the agent, and agnostic to the task and session structure.
@@ -19,8 +20,8 @@ such as **Qwen 3.8 27B** or **GPT-6 Luna**. The design principle is that:
19
20
  this outperforms more complicated techniques with lightweight models, and is at least as effective with frontier models too.
20
21
  It helps weaker models to avoid confabulating the historical context and to more carefully verify what it does and does not know.
21
22
 
22
- The primary intended use case is on a strong local LLM with a reasonably large context window (>128k) : for example, through
23
- **Qwen 3.8 27B llama.cpp on an RTX 5090**.
23
+ The advantages over other methods are most apparent in a strong local LLM with a reasonably large context window (>128k) : for example, through **Qwen 3.8 27B llama.cpp on an RTX 5090**.
24
+ However it is also very practical for use with stronger models and larger context windows.
24
25
 
25
26
  ## Install
26
27
 
@@ -45,9 +46,6 @@ or from a downloaded or cloned checkout:
45
46
  pi install /absolute/path/to/transparent-compact
46
47
  ```
47
48
 
48
- The extension entry point is `extensions/index.ts`, so Pi's compact extension list
49
- shows `@foliox/transparent-compact-pi` without a filename suffix for npm installs.
50
-
51
49
  ## Usage
52
50
 
53
51
  Pi's compaction uses transparent-compact by default once the extension is loaded.
@@ -60,36 +58,113 @@ To compact manually:
60
58
  The checkpoint begins with an explanation and full recovery instructions, and
61
59
  ends with an evidence-boundary warning. Task-relevant recovery reminders and a
62
60
  brief recovery recap follow **the retained recent history and any pending new
63
- user input**. They are saved in the session and remain available on later turns.
64
- After another compaction, only the current checklist is presented: older generated
65
- checklists are excluded from compacted spans and the retained tail. This is
66
- instruction delivery, not a guarantee of model compliance.
61
+ user input**. This is instruction delivery, not a guarantee of model compliance.
67
62
 
68
63
  Compaction hides earlier details from the model's view; recorded history remains
69
64
  retrievable. Recovery guidance explicitly names uncertain provenance (where a
70
65
  finding came from or why a conclusion was reached) and contradictions between
71
- earlier notes and new evidence. Prefer lookup for historical observations or to
72
- avoid repeating costly research; inspect project files for current contents.
73
- Cheap local rereads and recomputations remain reasonable.
74
-
75
- Tool lines use compact signatures and head-only bash previews: the first 160
76
- encoded characters, followed by an ellipsis when truncated. Selected historical
77
- output observations (such as failing-test counts) replace misleading `[ok]` labels;
78
- an unlabelled call is not proof of success. Most output and detailed payloads are
79
- omitted. When you need details hidden by compaction, ask `context_lookup` a specific
80
- historical question. Recovery results supply ENTRY ids for targeted follow-up;
81
- `context_show_entry` can read a specific passage at a known ENTRY id. Start small
82
- and continue only if the detail is missing, incomplete, or needs more context to
83
- resolve ambiguity; stop once the question is answered. Do not expand surrounding
84
- history by default. See [the rendering contract](docs/DESIGN.md#deterministic-checkpoint).
85
-
86
- File lists now distinguish source output retained in the recent tail, partial
87
- reads, and reads followed by tracked changes. Modified paths without retained
88
- read/write evidence are marked `no read-tool output in tail`; these annotations
89
- are checkpoint-time evidence, not guarantees of current filesystem state.
90
- Before replacing an existing file with `write`, the agent is told to reread it
91
- unless current contents are already visible, rather than reconstruct unchanged
92
- sections from memory. Small exact-match edits have no blanket reread requirement.
66
+ earlier notes and new evidence.
67
+
68
+ ### Choose checkpoint turn fidelity
69
+
70
+ ```text
71
+ /filter-turns # edit the existing checkpoint; no compaction
72
+ /compact-filtered # ordinary compaction first, then open the same editor
73
+ ```
74
+
75
+ `/compact-filtered` completes an ordinary verbatim compaction, preserving existing
76
+ turn settings, **before** opening the `/filter-turns` editor. Cancelling that editor
77
+ leaves the completed compaction intact. If Pi has nothing new to compact, the command
78
+ opens the existing checkpoint instead. Cancelling compaction itself (including its
79
+ size-cap dialog), or a compaction failure, does not open the editor. No special
80
+ filtering step runs inside the compaction hook.
81
+
82
+ In the interactive terminal, the editor opens a framed checklist of user turns, with
83
+ a highlighted cursor, action labels and a separate fixed controls area. The review
84
+ step summarizes mode changes; a live estimated context readout stays visible on
85
+ both selection and review screens.
86
+ Each choice applies to a user message and everything following it until the next
87
+ user message, including turns spanning multiple compactions.
88
+
89
+ | Symbol | Mode | Active context |
90
+ | --- | --- | --- |
91
+ | `[X]` | **PRUNED** | A positioned filtering marker only |
92
+ | `[ ]` | **PROSE** | Our standard mechanical compaction, including compact tool stubs |
93
+ | `[○]` | **PROSE+TOOLS** | Original conversation text and complete recorded tool arguments/results; thinking markers only |
94
+ | `[■]` | **FULL** | Original conversation content, including all recorded thinking and image attachments |
95
+ | `[-]` | **LOCKED** | Unavailable; not a fifth fidelity mode |
96
+
97
+ The readout updates as you change modes, for example:
98
+
99
+ ```text
100
+ Estimated context: ~29,365 / 272,000 tokens (10.8%) · incl. ~20,000 tail · +~160 scaffolding
101
+ Net Δ −20 · free 222,155 · reserve 20,480
102
+ ```
103
+
104
+ Counts use Pi's rough characters/4 heuristic plus message-framing allowances, not
105
+ provider tokenization.
106
+
107
+ Use **↑/↓** to navigate and **←/→** to collapse/expand details for the selected
108
+ mode. **Space** prunes any kept mode, or restores a pruned turn as PROSE. **f** cycles
109
+ PRUNED → PROSE → PROSE+TOOLS → FULL → PRUNED. Both keys act on the owning whole turn
110
+ when an agent/tool subentry is focused. **Enter** opens a complete, scrollable
111
+ change preview; **Enter** again confirms, **Esc** goes back or cancels.
112
+
113
+ Filtering requires verbatim mode and an idle agent. Turns overlapping Pi's retained
114
+ recent tail cannot be removed yet: filtering never removes only half a turn or
115
+ changes Pi's retention boundary. Content inside an opaque inherited summary cannot be
116
+ selected individually.
117
+
118
+
119
+ `/filter-turns` requires an existing verbatim checkpoint
120
+ and works even when there is no new history to compact. It saves a reversible,
121
+ branch-local checkpoint revision without moving the retained boundary or starting
122
+ an agent turn. PROSE restoration uses the canonical spans, startup reads and file
123
+ operations and remains subject to the size cap. PROSE+TOOLS/FULL instead reinsert
124
+ original messages at their chronological positions, replacing their compacted
125
+ copies and any duplicate startup-read copies. Explicit context omissions and
126
+ replacements remain respected. Complete tool-call/result groups are required.
127
+ Before the first checkpoint, use `/compact-filtered`.
128
+
129
+ Full-fidelity choices persist through later verbatim compactions and reload/resume.
130
+ Their content is **never silently shortened by the prose cap**. Estimated native
131
+ message cost is treated as fixed overhead; only PROSE can be trimmed. The extension
132
+ checks the model context budget before saving and on actual requests, reserving
133
+ output/framing headroom. Oversized selections are rejected; if later context growth
134
+ or a model change makes existing choices too large, the request is aborted with
135
+ instructions to downgrade turns through `/filter-turns`. Large full-fidelity turns
136
+ can therefore prevent automatic compaction from freeing enough space. Token counts
137
+ are estimates, not provider tokenization guarantees.
138
+
139
+ FULL means all content actually recorded, not unavailable internal reasoning or
140
+ unrecorded nested-tool outputs. Pi's normal model/provider transformations still
141
+ apply: changing models can convert/drop signed or encrypted thinking, and non-vision
142
+ models cannot receive images. Switching to summary compaction still weakens the
143
+ verbatim guarantee; its summarizer receives the expanded recorded text.
144
+
145
+ Each excluded group becomes `[Turn manually filtered]`. Its retained startup reads
146
+ and file-list paths used only in excluded turns are removed too. The checkpoint
147
+ and post-compaction reorientation explain the marker only when filtering is present.
148
+ Exclusions follow the active branch through later verbatim compactions, reload and
149
+ resume. Original session entries remain unchanged and recoverable; filtering does
150
+ not undo file changes. Ordinary `/compact` never applies new pre-flags or opens the
151
+ picker. Automatic compactions apply new pre-flags only when explicitly enabled below.
152
+
153
+ ### Pre-flag an aside and optionally apply flags automatically
154
+
155
+ ```text
156
+ /filter-later <message> # normal user turn, pre-checked in either filtering command
157
+ /fl <message> # short alias for /filter-later
158
+ /filter-auto # report current policy (default off)
159
+ /filter-auto on # apply pre-flags during threshold/overflow compaction
160
+ /filter-auto off # stop applying new pre-flags automatically
161
+ ```
162
+
163
+ `/filter-later` (or `/fl`) requires an idle agent in verbatim mode. The message and its following
164
+ agent/tool activity remain in normal context until the entire group is eligible
165
+ for filtering. It is not an isolated `/btw` conversation. In `/filter-turns` or
166
+ `/compact-filtered`, you can uncheck the aside before exclusion, or restore it afterward.
167
+
93
168
 
94
169
  ### Automatic startup-read retention
95
170
 
@@ -103,25 +178,6 @@ continues until that prompt arrives.
103
178
 
104
179
  This is a literal filename-matching heuristic, not an interpretation of required
105
180
  reading. It does not capture every possible reference or fill in incomplete reads.
106
- The agent is no longer given a required-document reread checklist; recovery is for
107
- missing task-relevant evidence. See [selection details](docs/DESIGN.md#retained-startup-reads).
108
-
109
- ### Select the compaction method
110
-
111
- ```text
112
- /compaction-method
113
- /compaction-method verbatim
114
- /compaction-method summary
115
- ```
116
-
117
- `/compaction-method` is available to opt-in to Pi's builtin summary compaction for the current session.
118
-
119
- The choice applies to manual `/compact`, automatic threshold compaction, and context-overflow recovery.
120
- With no argument, the command reports the current method.
121
-
122
- The choice persists in the existing session, follows branch history through
123
- reload, resume, fork, and tree navigation, and needs no extra configuration file.
124
- New sessions default to verbatim.
125
181
 
126
182
  ### Control the compaction cap
127
183
 
@@ -175,7 +231,6 @@ for unattended operation. If a percentage cannot be resolved because the model's
175
231
  context window is unavailable, compaction is cancelled: choose a character/token
176
232
  budget or turn the cap off.
177
233
 
178
-
179
234
  ## Configuration
180
235
 
181
236
  No separate configuration file is required. Set environment variables before
@@ -222,6 +277,24 @@ Instructions and file lists sit outside the budget; an inherited base and retain
222
277
  startup reads are uncapped, and the line budget has a 500-character minimum. Tune it
223
278
  alongside the model's context window and Pi's `compaction.keepRecentTokens`.
224
279
 
280
+ ### Select the compaction method
281
+
282
+ ```text
283
+ /compaction-method
284
+ /compaction-method verbatim
285
+ /compaction-method summary
286
+ ```
287
+
288
+ `/compaction-method` is available to opt-in to Pi's builtin summary compaction for the current session.
289
+
290
+ The choice applies to manual `/compact`, automatic threshold compaction, and context-overflow recovery.
291
+ With no argument, the command reports the current method.
292
+
293
+ The choice persists in the existing session, follows branch history through
294
+ reload, resume, fork, and tree navigation, and needs no extra configuration file.
295
+ New sessions default to verbatim.
296
+
297
+
225
298
  ### Local inference engines
226
299
 
227
300
  When lookups use the session model on a local server, they share its KV cache with the main session.
package/docs/DESIGN.md CHANGED
@@ -76,6 +76,188 @@ extension, display setting, or content format. Long type names are abbreviated
76
76
  like tool-call arguments. This applies even with the cap disabled. Previously
77
77
  saved canonical spans are not rewritten; older custom-message bodies may remain in them.
78
78
 
79
+ ### User-controlled turn filtering
80
+
81
+ `/compact-filtered` sequences ordinary verbatim manual compaction and the shared
82
+ `/filter-turns` editor. It waits for Pi's completion callback, so the new checkpoint
83
+ is already saved and the host is idle before the picker opens. There is no special
84
+ custom-instruction sentinel or interactive filtering path in `session_before_compact`.
85
+ The first phase inherits all existing choices like ordinary `/compact`; the second
86
+ phase proposes a separate reversible revision. Escape in the picker leaves the
87
+ completed compaction intact. A failed or cancelled first phase never opens it.
88
+ Pi's current no-op outcomes (`Already compacted` and `Nothing to compact (session too
89
+ small)`) open an existing checkpoint only if the session/branch is unchanged. A
90
+ session/branch change or unexpected checkpoint result cancels the workflow; the
91
+ shared editor rechecks idle/UI/method state before opening.
92
+
93
+ Only turns wholly before the saved boundary can be excluded; pre-flagged turns
94
+ still overlapping the retained tail remain pending and their flags can be cancelled
95
+ in the picker. Other recent turns stay locked. Agent/tool subentries are inspection
96
+ views of their owning user turn. Previously pruned turns start checked; unchecking
97
+ restores their compacted representation. Confirmation distinguishes pruning,
98
+ restoration, fidelity and pending-flag changes. Escape goes back from confirmation,
99
+ or cancels only the proposed revision. No filtering UI runs in ordinary manual,
100
+ threshold or overflow compaction itself.
101
+
102
+ `/filter-turns` uses the same selection/confirmation UI against the existing
103
+ checkpoint only. It does not invoke Pi's compaction preparation, append a compaction,
104
+ add a span, move `firstKeptEntryId`, or start an agent turn. It therefore also works
105
+ immediately after compaction when Pi has nothing more to compact. An existing
106
+ verbatim checkpoint and an idle interactive session are required; recent messages
107
+ remain untouched, though pending aside flags can be cancelled.
108
+
109
+ Canonical span lines carry parallel `turnIds`, anchored to raw user entry IDs
110
+ through Pi's source-preserving projection (including explicit context replacements).
111
+ A group includes all activity until the next raw user message, even across multiple
112
+ compaction spans. Confirmed exclusions are stored as the current `filteredTurnIds`
113
+ snapshot on the compaction entry or its standalone revision, not an append-only
114
+ union. Later verbatim checkpoints apply that branch-local selection to the original canonical spans before size
115
+ trimming, reindexing tool display records without changing stored history. File
116
+ operation lists and startup-read snapshots in compaction details remain canonical
117
+ and unfiltered; only the rendered checkpoint masks them. Restoring a turn therefore
118
+ also restores its retained-read copies and file-list membership without re-reading
119
+ files or reselecting startup evidence. There is no migration or reconstruction of
120
+ saved spans without turn ownership; opaque content is not individually selectable.
121
+
122
+ One `[Turn manually filtered]` marker replaces each excluded group at its original
123
+ position, even across spans. Markers survive the size cap. Startup-read copies owned
124
+ by the group are excluded; file-list paths used only by excluded turns are removed.
125
+ Filtering does not undo filesystem mutations. The checkpoint introduction and
126
+ persistent reorientation conditionally explain that the user excluded low-value
127
+ context, which remains retrievable from the full raw history. Recovery tools are
128
+ unchanged. Cancelling or failing a turn edit saves no revision. Mechanical compaction
129
+ with existing pruning or fidelity choices cancels on build failure rather than
130
+ falling through to a model summary that would lose those choices.
131
+
132
+ Standalone updates append a non-context `transparent-compact:filter-revision`
133
+ entry containing the source compaction ID, rendered checkpoint, exclusions and
134
+ keep overrides. The latest revision for the active compaction wins. At request
135
+ time, `context_with_system` replaces Pi's projected `compactionSummary` with the
136
+ revised text and any selected native turn segments, and refreshes the managed
137
+ reminder for that revision. Original compaction entries and
138
+ the raw recent tail are never edited. Host views/estimates based solely on Pi's
139
+ saved projection can still reflect the original summary; actual provider requests
140
+ receive the revision. The checkpoint size guard applies before a revision is saved.
141
+
142
+ Reload/resume and tree navigation select revisions from the raw active branch.
143
+ The next real verbatim compaction inherits their choices and supersedes the old
144
+ revision; model-summary compaction is also given the revised previous summary and
145
+ file lists rather than stale saved checkpoint content. Cancelling the picker or
146
+ size-cap decision saves no filtering revision. No-op confirmation writes nothing.
147
+
148
+ `/filter-later <message>` (alias `/fl`) submits an ordinary user message through Pi's user-message API.
149
+ A short-lived bridge from that submission's input event writes a non-context
150
+ `transparent-compact:aside-turn` entry just before its user message is persisted.
151
+ The next raw user entry consumes the flag, guarded by that message's timestamp.
152
+ A failed/handled input is cleared by the next input, and session changes clear the
153
+ bridge; no content heuristic is used to flag historical messages. Asides remain
154
+ visible until eligible and are pre-checked by manual filtering.
155
+
156
+ `/filter-auto on|off` persists a branch-local
157
+ `transparent-compact:auto-filter` policy (default off). When enabled, threshold
158
+ and overflow compaction apply eligible user pre-flags without opening a picker.
159
+ Ordinary `/compact` does not apply new pre-flags; summary mode is unchanged.
160
+ The compaction's `keptAsideTurnIds` snapshot records explicit manual keep/restore
161
+ overrides, so future auto compactions do not re-exclude those asides. Turning off
162
+ auto filtering affects new applications, not existing exclusions. No automatic
163
+ relevance judgment, model call or filesystem mutation is introduced.
164
+
165
+ ### Selective full-fidelity turns
166
+
167
+ The same picker has four modes: `[X] PRUNED`, `[ ] PROSE`, `[○] PROSE+TOOLS`, and
168
+ `[■] FULL`. `[-] LOCKED` is an independent availability state and remains unchanged.
169
+ Space switches any kept mode to PRUNED, or PRUNED to PROSE. `f` cycles all four modes;
170
+ for pending recent-tail pre-flags it only toggles PRUNED/PROSE. Both controls always
171
+ act on the whole owning user turn. Expansion and confirmation preview show the
172
+ chosen representation; preview also estimates token growth.
173
+
174
+ The compaction/revision stores a `fidelity` map of raw user IDs to `tools`/`full`
175
+ and generated `slots`, never another copy of raw payloads. PRUNED continues to use
176
+ `filteredTurnIds`; absent fidelity means PROSE. Before capping, every compacted copy
177
+ of a selected native turn is replaced by a single generated slot, even across
178
+ multiple canonical spans. Slots are structurally protected from trimming. Generated
179
+ random markers are resolved to checked UTF-16 offsets in the final checkpoint;
180
+ request projection never interprets historical text as a managed placeholder.
181
+
182
+ At request time, the checkpoint is split at those offsets into chronological
183
+ compacted segments interleaved with original user/assistant/tool messages. The raw
184
+ projection disables compaction while preserving branch topology and Pi's explicit
185
+ context edits and custom-message conversion. Historical system configuration and
186
+ obsolete managed reorientation messages are not replayed. Tool-call/result groups
187
+ must be complete and unambiguous. PROSE+TOOLS replaces each thinking block with a
188
+ text marker in place; FULL retains stored blocks/signatures/images. Request-local
189
+ copies prevent later transforms from mutating canonical session records. Provider
190
+ compatibility transformations still apply, including cross-model reasoning and
191
+ non-vision image handling; no unavailable reasoning or nested outputs are invented.
192
+
193
+ Native turns replace their compacted prose and startup-read duplicates, not the
194
+ canonical source data. File paths remain listed and successful read outputs in
195
+ native turns get a conservative historical-evidence annotation. PROSE restoration
196
+ can recover its canonical retained reads again. Mode choices inherit through
197
+ reload/resume, tree navigation and later verbatim compactions; explicit fidelity
198
+ choices also override aside pre-flags. An empty revision clears old fidelity rather
199
+ than falling back to the source checkpoint's map. Explicit summary compaction gets
200
+ expanded historical text as its previous summary and may summarize it normally.
201
+
202
+ Native message token estimates count as fixed overhead in the character cap; only
203
+ PROSE is trimmable. Independent context-window checks run before saving and after
204
+ system restoration on each actual request, with output/framing headroom. They use
205
+ Pi's token estimates, not a provider tokenizer. Oversized updates save no revision;
206
+ subsequent budget/projection failures explicitly abort the active operation (a hook
207
+ exception alone is not a cancellation gate). Existing full-fidelity content is never
208
+ silently dropped or downgraded to make room. The user can remove/downgrade a pin,
209
+ even if later context edits made its original tool group unreplayable. Host views
210
+ and compaction-boundary selection still use Pi's saved checkpoint; provider requests
211
+ include native expansions and are checked separately.
212
+
213
+ ### Live context size preview
214
+
215
+ Selection and review share a live whole-context estimate: input tokens/context
216
+ window, percentage, net delta from saved input, and headroom after the same output
217
+ and framing reserve used by the context guard. The total explicitly includes the
218
+ measured tail size, not the configured retention target. Short terminals show the
219
+ total only.
220
+ The editor supplies a read-only estimator to the picker. It renders proposed
221
+ selections through the same checkpoint builder as saving, with passive cap
222
+ resolution and no notifications/dialogs/persistence. Warn assumes applying the
223
+ current budget on changes; unchanged selections use the actual saved checkpoint,
224
+ not a hypothetical rebuild under a newly changed cap policy. A presentation result
225
+ from the real cap renderer records actual trimming/tightening; only then does the UI
226
+ mention the size limit, in plain language, including whether saving asks first.
227
+ Raw `cap warn` policy/debug labels are not shown.
228
+
229
+ Notice accounting separately measures generated pruning guidance, checkpoint
230
+ revision notices and full-fidelity guidance using counterfactual messages through
231
+ the real estimator. Only the generated introduction before `SECTION_HEADER` and
232
+ the generated reminder are edited in these counterfactuals; quoted historical text
233
+ is untouched. Costs therefore follow the actual text/estimator, with no fixed token
234
+ allowance. Activation/removal changes are summed into one inline `+~N scaffolding`
235
+ (or `−~N scaffolding`) indicator after the tail on the estimated-context row,
236
+ already included in the total and net delta.
237
+ No notice breakdown or extra notice row is shown; unchanged context has no added
238
+ scaffolding indicator. Existing notice rounding is not presented as fresh overhead
239
+ on every checkbox.
240
+ The first prune and first checkpoint update can therefore add noticeable one-time
241
+ cost even when little prose is removed. The delta still includes marker replacements
242
+ and size-limit effects; it is not a raw selected-text token count.
243
+
244
+ The estimator expands generated native slots, removes retained-read duplicates,
245
+ and respects explicit context edits. It counts the untouched live tail (excluding
246
+ old system configuration, obsolete managed checklists and context-excluded bash
247
+ output), plus the current prompt/active tool schemas and one current reminder.
248
+ These are Pi estimates before provider-specific transformations; future input and
249
+ other extensions' future request transformations cannot be predicted. A failed
250
+ baseline leaves delta unknown, while repaired proposed context can still get an
251
+ honest total. Failed estimates are shown as unavailable, never zero.
252
+
253
+ Estimation is asynchronous and coalesced per mode change; navigation, resize and
254
+ theme changes reuse the last result. Pending recalculations retain the completed
255
+ readout, its styling and row count, replacing values only when a new estimate is
256
+ ready. Loading text appears only before any successful estimate (or when retrying
257
+ a failed estimate), not on every toggle. Generation checks reject stale results, and
258
+ closing/disposing the dialog invalidates pending work. No estimated sizes are
259
+ persisted in checkpoint metadata, and no model calls are introduced.
260
+
79
261
  ### File-list evidence annotations
80
262
 
81
263
  The lists record reads and modifications in compacted history, not an exhaustive
@@ -352,7 +534,8 @@ There is no blanket edit-target reread. Before replacing an existing file with
352
534
  view, and forbids reconstructing unchanged sections from memory. Small exact-match
353
535
  edits and newly created files do not acquire a blanket reread requirement.
354
536
  It is a saved
355
- custom message tagged with the current compaction entry ID, not a temporary nudge:
537
+ custom message tagged with the current compaction entry ID and, after standalone
538
+ filtering, its revision ID, not a temporary nudge:
356
539
  subsequent responses and user turns retain it in history before the work that
357
540
  followed it. `before_agent_start` adds it on normal starts/resume when missing;
358
541
  `session_compact` steers it into automatic mid-run and overflow continuations.