38 38 Bound learned exact values and restorable placeholder mappings to 8192 each.
39 39 Bound deep traversal by object identity and depth 64.
40 40 On learned-value cap overflow, stop learning new dotenv/env exact values and warn once.
41 -Phase 1 retains the volatile HMAC12 mapping format.
42 -Durable V1 mappings are deferred to Phase 2.
43 -Until Phase 2 lands, mapping-cap behavior remains unchanged.
41 +Every emitted placeholder must have an authenticated active-generation mapping appended before provider use.
42 +Mapping, collision, capacity, encryption, or append failure leaves the original value visible and warns.
45 44 `leaks` must tolerate faulty user input.
46 45 The only planned user input is the `regex` setting.
65 64 Provider sees placeholders.
66 -Local Pi keeps placeholder mappings in memory only.
67 -Mappings must never be persisted to session files, logs, settings, or disk.
68 -Reload, new session, process exit, and `/leaks clear` may make old placeholders unrestorable.
65 +Pi persists a random generation root key and AES-256-GCM encrypted mapping records as custom session entries.
66 +The root key and ciphertext are co-located obfuscation and context isolation, not encryption at rest.
67 +State reconstruction uses only the active branch from `getBranch()`.
69 68 Local restoration may happen for tool args and final assistant messages.
69 +Unknown placeholders block every tool.
70 70 Placeholders are local capabilities.
71 71 Normal Pi workflows must keep working locally when placeholders are copied or moved exactly.
73 73 Placeholder format:
76 -__LEAK_<TAG>[_<TAG>...]_<HMAC12>[_N]__
76 +__LEAK_V1_<TAG>[_<TAG>...]_<HMAC32>__
79 -`HMAC12` is the first 12 lowercase hex chars of an HMAC over the secret value.
80 -The HMAC key is random, in-memory, and never persisted.
81 -`_N` is used only to resolve an actual placeholder collision inside the current mapping table.
79 +`HMAC32` is the first 16 HMAC-SHA-256 bytes encoded as 32 lowercase hexadecimal characters.
80 +The generation root key derives separate HMAC and AES-GCM keys with HKDF.
81 +Collisions never gain suffixes; the colliding value remains visible and warns.
83 83 Tags preserve metadata.
84 84 Secret values stay hidden.
96 96 The same secret value must keep one stable placeholder once first seen and stored.
97 97 Tags do not evolve after first mapping.
98 98 This avoids confusing the model with multiple placeholders for one secret.
99 -Non-restorable overflow placeholders are exempt from stability.
100 99 When multiple tags are available for the same secret span on first mapping, order them by semantic priority:
102 101 1. dotenv key name or `ENV_KEY`
124 -__LEAK_STRIPE_LIVE_SECRET_KEY_STRIPE_TOKEN_8f31aa77c901__
125 -__LEAK_OPENROUTER_API_KEY_OPENROUTER_TOKEN_41c0e9aa1204__
126 -__LEAK_DATABASE_URL_DB_PASSWORD_POSTGRES_URL_ba29d4ff8810__
123 +__LEAK_V1_STRIPE_LIVE_SECRET_KEY_STRIPE_TOKEN_8f31aa77c90129a76d253a748660f5b7__
124 +__LEAK_V1_OPENROUTER_API_KEY_OPENROUTER_TOKEN_41c0e9aa1204a7342836516dc01b9490__
125 +__LEAK_V1_DATABASE_URL_DB_PASSWORD_POSTGRES_URL_ba29d4ff8810c412e1341ef2839572aa__
129 128 Do not encode secret length, alphabet, prefix bytes, suffix bytes, entropy, or shape.
137 136 Use these Pi hooks:
139 -- `session_start`: initialize settings, dotenv/env learning, status
138 +- `session_start`: rebuild the active generation, initialize settings and learning, update status
139 +- `session_tree`: rebuild from the newly active branch
140 140 - `context`: redact message copies opportunistically
141 -- `before_provider_request`: redact final provider payload authoritatively
142 -- `tool_call`: restore placeholders in tool args before local execution
141 +- `before_provider_request`: persist mappings, then redact final provider payload authoritatively
142 +- `tool_call`: hydrate known placeholders and block unknown or incompletely inspected input
143 143 - `message_end`: restore placeholders in finalized local assistant messages
145 -Do not persist mappings with `appendEntry`.
145 +Persist generations and encrypted mappings with `appendEntry`.
146 146 Do not register tools.
147 147 Use one slash command: `/leaks`.