@alexgreensh/token-optimizer 5.13.79 → 5.13.81
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/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/hooks/module_runner.py +1 -1
- package/package.json +1 -1
- package/skills/token-optimizer/scripts/_measure/__init__.py +1 -1
- package/skills/token-optimizer/scripts/_measure/audit.py +5 -6
- package/skills/token-optimizer/scripts/_measure/cache_policy.py +16 -39
- package/skills/token-optimizer/scripts/_measure/nudge_followthrough.py +90 -32
- package/skills/token-optimizer/scripts/_measure/project_md_walk.py +29 -0
- package/skills/token-optimizer/scripts/_measure/selfheal_guard.py +2 -1
- package/skills/token-optimizer/scripts/_measure/transcript_product.py +113 -58
- package/skills/token-optimizer/scripts/_measure/ttl_file_memo.py +109 -0
- package/skills/token-optimizer/scripts/_measure/weekly_activity.py +27 -3
- package/skills/token-optimizer/scripts/antigravity_doctor.py +21 -12
- package/skills/token-optimizer/scripts/antigravity_hook_bridge.py +20 -3
- package/skills/token-optimizer/scripts/cloud_kit.py +1 -1
- package/skills/token-optimizer/scripts/codex_doctor.py +1 -1
- package/skills/token-optimizer/scripts/hermes_doctor.py +1 -1
- package/skills/token-optimizer/scripts/hermes_install.py +1 -1
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"name": "token-optimizer",
|
|
14
14
|
"source": "./",
|
|
15
15
|
"description": "Audit, fix, and monitor Claude Code context window usage. Find the ghost tokens.",
|
|
16
|
-
"version": "5.13.
|
|
16
|
+
"version": "5.13.81",
|
|
17
17
|
"author": {
|
|
18
18
|
"name": "Alex Greenshpun",
|
|
19
19
|
"url": "https://linkedin.com/in/alexgreensh"
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"name": "token-optimizer-cowork",
|
|
56
56
|
"source": "./cowork/token-optimizer",
|
|
57
57
|
"description": "Token Optimizer for Claude Cowork \u2014 full skills + Cowork-native hooks (beta). Install THIS in Cowork; the standard token-optimizer entry is for desktop Claude Code.",
|
|
58
|
-
"version": "5.13.
|
|
58
|
+
"version": "5.13.81",
|
|
59
59
|
"author": {
|
|
60
60
|
"name": "Alex Greenshpun",
|
|
61
61
|
"url": "https://linkedin.com/in/alexgreensh"
|
package/hooks/module_runner.py
CHANGED
|
@@ -134,7 +134,7 @@ _COLD_COMPILE_FAILED = ".token-optimizer-compile.failed"
|
|
|
134
134
|
_COLD_COMPILE_TAG = "token-optimizer-bytecode-warmup"
|
|
135
135
|
|
|
136
136
|
# This closed set matches _measure.RUNTIME_SOURCES. No recursive repo scan.
|
|
137
|
-
_MEASURE_PACKAGE_SOURCES = ('__init__.py', '_compat.py', 'runtime.py', 'pricing.py', 'audit.py', 'dashboard.py', 'lifecycle.py', 'sessions.py', 'trends.py', 'cache_policy.py', 'daemon.py', 'quality_archive.py', 'continuity.py', 'savings.py', 'cli.py', 'dashboard_history.py', 'weekly_activity.py', 'headline.py', 'counted_position.py', 'counted_pricing_v5.py', 'transcript_backfill.py', 'counted_subagents.py', 'lean_resume_threshold.py', 'output_reread.py', 'session_effect.py', 'structural_ledger.py', 'structural_archives.py', 'structural_listing.py', 'structural_report.py', 'structural_seed.py', 'structural_value.py', 'rework_metrics.py', 'session_best.py', 'savings_story.py', 'savings_headline.py', 'counted_orphans.py', 'counted_cap.py', 'archive_void_evidence.py', 'cost_per_message_trend.py', 'lean_resume_receivers.py', 'routing_period.py', 'fixture_context.py', 'transcript_product.py', 'periphery_exposure.py', 'structure_funnel.py', 'setup_attachment_counter.py', 'first_read_outcomes.py', 'setup_budget_monitor.py', 'setup_connector_ledger.py', 'first_call_context.py', 'timestamp_cache.py', 'token_type_split.py', 'evidence_parallel.py', 'ttl_period.py', 'first_read_revive.py', 'mcp_archive_tripwire.py', 'compaction_survival.py', 'archive_void_codex.py', 'compression_fixture_void.py', 'feature_health.py', 'archive_health.py', 'coverage_report.py', 'file_refetch.py', 'holdout_report.py', 'structural_dedupe.py', 'setup_step.py', 'baseline_provenance.py', 'own_price_card.py', 'transcript_stream.py', 'checkpoint_direction.py', 'checkpoint_retention.py', 'keepwarm_safety.py', 'keepwarm_economics.py', 'keepwarm_linux.py', 'mod_action_booking.py', 'mod_action_diagnostics.py', 'mod_action_selftest.py', 'install_baseline.py', 'routing_credit.py', 'mod_compaction_booking.py', 'mod_fresh_booking.py', 'quality_continuity.py', 'quality_checkpoint.py', 'codex_quality.py', 'lease_candidate_cleanup.py', 'session_store_spool.py', 'upgrade_drain_control.py', 'compression_scan_checkpoint.py', 'status_bar_lock.py', 'session_flush_lock.py', 'context_reset_marker.py', 'holdout_fallback.py', 'dashboard_heal_claim.py', 'selfheal_guard.py', 'config_cache.py', 'setup_observation_cache.py', 'status_bar_refresh.py', 'routing_default.py', 'pilot_report.py', 'nudge_followthrough.py', 'runway_all_in.py', 'session_activity.py', 'routing_savings.py', 'pt_resume_cues.py', 'subscription_audits.py', 'limit_units.py', 'local_adapt.py', 'prefix_cost.py', 'poc_commands.py', 'counted_closes.py', 'counted_headline.py', 'apply_safe.py', 'autocompact_advice.py', 'cold_guard.py', 'keepwarm_auto.py', 'keepwarm_rearm.py', 'next_actions.py')
|
|
137
|
+
_MEASURE_PACKAGE_SOURCES = ('__init__.py', '_compat.py', 'runtime.py', 'pricing.py', 'audit.py', 'dashboard.py', 'lifecycle.py', 'sessions.py', 'trends.py', 'cache_policy.py', 'daemon.py', 'quality_archive.py', 'continuity.py', 'savings.py', 'cli.py', 'dashboard_history.py', 'weekly_activity.py', 'headline.py', 'counted_position.py', 'counted_pricing_v5.py', 'transcript_backfill.py', 'counted_subagents.py', 'lean_resume_threshold.py', 'output_reread.py', 'session_effect.py', 'structural_ledger.py', 'structural_archives.py', 'structural_listing.py', 'structural_report.py', 'structural_seed.py', 'structural_value.py', 'rework_metrics.py', 'session_best.py', 'savings_story.py', 'savings_headline.py', 'counted_orphans.py', 'counted_cap.py', 'archive_void_evidence.py', 'cost_per_message_trend.py', 'lean_resume_receivers.py', 'routing_period.py', 'fixture_context.py', 'transcript_product.py', 'periphery_exposure.py', 'structure_funnel.py', 'setup_attachment_counter.py', 'first_read_outcomes.py', 'setup_budget_monitor.py', 'setup_connector_ledger.py', 'first_call_context.py', 'timestamp_cache.py', 'token_type_split.py', 'evidence_parallel.py', 'ttl_period.py', 'first_read_revive.py', 'mcp_archive_tripwire.py', 'compaction_survival.py', 'archive_void_codex.py', 'compression_fixture_void.py', 'feature_health.py', 'archive_health.py', 'coverage_report.py', 'file_refetch.py', 'holdout_report.py', 'structural_dedupe.py', 'setup_step.py', 'baseline_provenance.py', 'own_price_card.py', 'transcript_stream.py', 'checkpoint_direction.py', 'checkpoint_retention.py', 'keepwarm_safety.py', 'keepwarm_economics.py', 'keepwarm_linux.py', 'mod_action_booking.py', 'mod_action_diagnostics.py', 'mod_action_selftest.py', 'install_baseline.py', 'routing_credit.py', 'mod_compaction_booking.py', 'mod_fresh_booking.py', 'quality_continuity.py', 'quality_checkpoint.py', 'codex_quality.py', 'lease_candidate_cleanup.py', 'session_store_spool.py', 'upgrade_drain_control.py', 'compression_scan_checkpoint.py', 'status_bar_lock.py', 'session_flush_lock.py', 'context_reset_marker.py', 'holdout_fallback.py', 'dashboard_heal_claim.py', 'selfheal_guard.py', 'config_cache.py', 'setup_observation_cache.py', 'status_bar_refresh.py', 'routing_default.py', 'pilot_report.py', 'nudge_followthrough.py', 'runway_all_in.py', 'session_activity.py', 'routing_savings.py', 'pt_resume_cues.py', 'subscription_audits.py', 'limit_units.py', 'local_adapt.py', 'prefix_cost.py', 'poc_commands.py', 'counted_closes.py', 'counted_headline.py', 'apply_safe.py', 'autocompact_advice.py', 'cold_guard.py', 'keepwarm_auto.py', 'keepwarm_rearm.py', 'next_actions.py', 'ttl_file_memo.py', 'project_md_walk.py')
|
|
138
138
|
|
|
139
139
|
|
|
140
140
|
def _runtime_sources(measure_src):
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alexgreensh/token-optimizer",
|
|
3
|
-
"version": "5.13.
|
|
3
|
+
"version": "5.13.81",
|
|
4
4
|
"description": "Token Optimizer for Claude Code cloud sessions: the real plugin, installed by your cloud environment's setup script.",
|
|
5
5
|
"license": "PolyForm-Noncommercial-1.0.0",
|
|
6
6
|
"author": "Alex Greenshpun (https://linkedin.com/in/alexgreensh)",
|
|
@@ -13,7 +13,7 @@ DEFERRED_MODULES = ('audit', 'dashboard', 'sessions', 'savings', 'cli')
|
|
|
13
13
|
RUNTIME_SOURCES = ('__init__.py', '_compat.py') + tuple(name + '.py' for name in DOMAIN_MODULES) + ('dashboard_history.py', 'weekly_activity.py', 'headline.py', 'counted_position.py', 'counted_pricing_v5.py', 'transcript_backfill.py', 'counted_subagents.py', 'lean_resume_threshold.py', 'output_reread.py', 'session_effect.py', 'structural_ledger.py', 'structural_archives.py', 'structural_listing.py', 'structural_report.py', 'structural_seed.py', 'structural_value.py', 'rework_metrics.py', 'session_best.py', 'savings_story.py', 'savings_headline.py', 'counted_orphans.py', 'counted_cap.py', 'archive_void_evidence.py', 'cost_per_message_trend.py', 'lean_resume_receivers.py', 'routing_period.py', 'fixture_context.py', 'transcript_product.py', 'periphery_exposure.py', 'structure_funnel.py', 'setup_attachment_counter.py', 'first_read_outcomes.py', 'setup_budget_monitor.py', 'setup_connector_ledger.py', 'first_call_context.py', 'timestamp_cache.py', 'token_type_split.py', 'evidence_parallel.py', 'ttl_period.py', 'first_read_revive.py', 'mcp_archive_tripwire.py', 'compaction_survival.py', 'archive_void_codex.py', 'compression_fixture_void.py', 'feature_health.py', 'archive_health.py', 'coverage_report.py', 'file_refetch.py', 'holdout_report.py', 'structural_dedupe.py', 'setup_step.py', 'baseline_provenance.py', 'own_price_card.py', 'transcript_stream.py', 'checkpoint_direction.py', 'checkpoint_retention.py')
|
|
14
14
|
RUNTIME_SOURCES += ('keepwarm_safety.py', 'keepwarm_economics.py', 'keepwarm_linux.py', 'mod_action_booking.py', 'mod_action_diagnostics.py', 'mod_action_selftest.py', 'install_baseline.py', 'routing_credit.py', 'mod_compaction_booking.py', 'mod_fresh_booking.py', 'quality_continuity.py', 'quality_checkpoint.py', 'codex_quality.py', 'lease_candidate_cleanup.py', 'session_store_spool.py', 'upgrade_drain_control.py', 'compression_scan_checkpoint.py', 'status_bar_lock.py', 'session_flush_lock.py', 'context_reset_marker.py', 'holdout_fallback.py', 'dashboard_heal_claim.py', 'selfheal_guard.py', 'config_cache.py', 'setup_observation_cache.py', 'status_bar_refresh.py', 'routing_default.py', 'pilot_report.py',)
|
|
15
15
|
RUNTIME_SOURCES += ('nudge_followthrough.py', 'runway_all_in.py',)
|
|
16
|
-
RUNTIME_SOURCES += ('session_activity.py', 'routing_savings.py', 'pt_resume_cues.py', 'subscription_audits.py', 'limit_units.py', 'local_adapt.py', 'prefix_cost.py', 'poc_commands.py', 'counted_closes.py', 'counted_headline.py', 'apply_safe.py', 'autocompact_advice.py', 'cold_guard.py', 'keepwarm_auto.py', 'keepwarm_rearm.py', 'next_actions.py',)
|
|
16
|
+
RUNTIME_SOURCES += ('session_activity.py', 'routing_savings.py', 'pt_resume_cues.py', 'subscription_audits.py', 'limit_units.py', 'local_adapt.py', 'prefix_cost.py', 'poc_commands.py', 'counted_closes.py', 'counted_headline.py', 'apply_safe.py', 'autocompact_advice.py', 'cold_guard.py', 'keepwarm_auto.py', 'keepwarm_rearm.py', 'next_actions.py', 'ttl_file_memo.py', 'project_md_walk.py',)
|
|
17
17
|
# Set True by hooks/userpromptsubmit_runner.py right before `import measure`,
|
|
18
18
|
# which consumes it. That process never patches or enumerates the facade.
|
|
19
19
|
HOOK_IMPORT = False
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""Definition-only implementations; mutable state belongs to measure."""
|
|
2
2
|
from __future__ import annotations
|
|
3
|
-
from . import _compat
|
|
3
|
+
from . import _compat, project_md_walk
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
def _read_codex_config() -> dict:
|
|
@@ -709,12 +709,11 @@ def measure_components():
|
|
|
709
709
|
"lines": _measure_facade.count_lines(path),
|
|
710
710
|
}
|
|
711
711
|
|
|
712
|
-
#
|
|
713
|
-
|
|
714
|
-
cwd = _measure_facade.Path.cwd()
|
|
712
|
+
# Project CLAUDE.md files in cwd and parents: <project>/CLAUDE.md and <project>/.claude/CLAUDE.md
|
|
713
|
+
cwd, homes = _measure_facade.Path.cwd(), project_md_walk.homes(_measure_facade)
|
|
715
714
|
for parent in [cwd] + list(cwd.parents)[:3]:
|
|
716
|
-
if parent
|
|
717
|
-
continue #
|
|
715
|
+
if project_md_walk.is_home(_measure_facade, parent, homes):
|
|
716
|
+
continue # ~/CLAUDE.md is checked above; the real home is never walked
|
|
718
717
|
candidates = [
|
|
719
718
|
(f"claude_md_project_{parent.name}", parent / "CLAUDE.md"),
|
|
720
719
|
(f"claude_md_project_{parent.name}_dotclaude", parent / ".claude" / "CLAUDE.md"),
|
|
@@ -174,61 +174,38 @@ def _get_cache_ttl_waste(days=None, collect_sessions=None):
|
|
|
174
174
|
rebuild_ttl = {} # provider key -> profile TTL, used when no split is logged
|
|
175
175
|
candidate_floor = 300 # scan at the shortest TTL; the observed boundary filters later
|
|
176
176
|
|
|
177
|
+
from . import ttl_file_memo
|
|
177
178
|
for filepath in files:
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
except Exception:
|
|
181
|
-
continue
|
|
182
|
-
if not turns:
|
|
179
|
+
facts = ttl_file_memo.summary(_measure_facade, filepath, parse_fn, runtime, tier_data, candidate_floor)
|
|
180
|
+
if facts is None:
|
|
183
181
|
continue
|
|
184
182
|
scanned_sessions += 1
|
|
185
|
-
|
|
186
|
-
# Resolve the session's dominant model -> cache profile.
|
|
187
|
-
model = _measure_facade._dominant_turn_model(turns)
|
|
188
|
-
prof_key, profile = _measure_facade._resolve_cache_profile(model, runtime=runtime)
|
|
189
|
-
kind = profile["cache_kind"]
|
|
183
|
+
prof_key, profile, kind = facts["prof_key"], facts["profile"], facts["kind"]
|
|
190
184
|
prov = _prov(prof_key, profile)
|
|
191
185
|
prov["sessions"] += 1
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
cr = int(turn.get("cache_read", 0) or 0)
|
|
196
|
-
cc = int(turn.get("cache_creation", 0) or 0)
|
|
197
|
-
total_cache_read += cr
|
|
198
|
-
total_full_input += cr + cc + int(turn.get("input_tokens", 0) or 0)
|
|
199
|
-
|
|
186
|
+
# Overall hit-rate across all scanned sessions (every cache_kind).
|
|
187
|
+
total_cache_read += facts["cache_read"]
|
|
188
|
+
total_full_input += facts["full_input"]
|
|
200
189
|
if kind == "none":
|
|
201
190
|
no_cache_sessions += 1
|
|
202
191
|
continue
|
|
203
|
-
|
|
204
|
-
detail_out = {} if collect_sessions else None
|
|
205
192
|
if kind == "explicit_ttl":
|
|
206
193
|
split = ttl_split.setdefault(prof_key, [0, 0])
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
split[1] += int(turn.get("cache_creation_5m", 0) or 0)
|
|
214
|
-
# W5: pass the already-resolved dominant model. Candidates are kept
|
|
215
|
-
# at the shortest TTL; the user's observed TTL filters them below.
|
|
216
|
-
found = []
|
|
217
|
-
_measure_facade._detect_explicit_ttl(
|
|
218
|
-
turns, tier_data, profile, dominant_model=model,
|
|
219
|
-
boundary=min(candidate_floor, profile.get("effective_ttl_seconds") or candidate_floor),
|
|
220
|
-
cutoff_ts=cutoff_ts, events_out=found)
|
|
194
|
+
h1, m5 = ttl_file_memo.split_in_window(facts, cutoff_ts)
|
|
195
|
+
split[0] += h1
|
|
196
|
+
split[1] += m5
|
|
197
|
+
# Candidates are kept at the shortest TTL; the user's observed TTL
|
|
198
|
+
# filters them below.
|
|
199
|
+
found = ttl_file_memo.events_in_window(facts, cutoff_ts)
|
|
221
200
|
rebuild_ttl.setdefault(prof_key, profile.get("effective_ttl_seconds") or 3600)
|
|
222
201
|
for event in found:
|
|
223
202
|
event["session"] = str(filepath)
|
|
224
203
|
event["recoverable_kind"] = profile.get("recoverable_kind", "avoidable_behavioral")
|
|
225
204
|
rebuild_events.setdefault(prof_key, []).extend(found)
|
|
226
205
|
continue
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
sw_tokens, sw_cost, recoverable, had = _measure_facade._detect_automatic_collapse(
|
|
231
|
-
turns, profile, dominant_model=model, detail_out=detail_out)
|
|
206
|
+
# automatic_discount or explicit_storage
|
|
207
|
+
sw_tokens, sw_cost, recoverable, had = facts["collapse"]
|
|
208
|
+
detail_out = {"max_gap": facts["max_gap"]}
|
|
232
209
|
|
|
233
210
|
if had:
|
|
234
211
|
prov["affected_sessions"] += 1
|
|
@@ -159,35 +159,73 @@ def classify(rows, emitted, new_rows=None):
|
|
|
159
159
|
return 'pending', None, []
|
|
160
160
|
|
|
161
161
|
|
|
162
|
-
def
|
|
163
|
-
"""
|
|
164
|
-
|
|
162
|
+
def _start(path):
|
|
163
|
+
"""First timestamp of an append-only transcript, without reading the rest."""
|
|
164
|
+
with Path(path).open(encoding='utf-8', errors='replace') as stream:
|
|
165
|
+
for line in stream:
|
|
166
|
+
try:
|
|
167
|
+
row = json.loads(line)
|
|
168
|
+
except ValueError:
|
|
169
|
+
continue
|
|
170
|
+
if isinstance(row, dict) and not row.get('isSidechain'):
|
|
171
|
+
stamp = _epoch(row.get('timestamp'))
|
|
172
|
+
if stamp is not None:
|
|
173
|
+
return stamp
|
|
174
|
+
return None
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def _project_index(directory, since):
|
|
178
|
+
"""Start times of transcripts written after `since`.
|
|
179
|
+
|
|
180
|
+
Only these can follow a nudged session. Reading every transcript in full
|
|
181
|
+
held a whole project history in memory: 17 GB of logs grew past 11 GB.
|
|
182
|
+
"""
|
|
183
|
+
starts, failures = {}, []
|
|
165
184
|
for path in Path(directory).glob('*.jsonl'):
|
|
166
185
|
if path.is_symlink():
|
|
167
186
|
continue
|
|
168
187
|
try:
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
if
|
|
173
|
-
|
|
188
|
+
if path.stat().st_mtime < since:
|
|
189
|
+
continue
|
|
190
|
+
start = _start(path)
|
|
191
|
+
if start is not None:
|
|
192
|
+
starts[path] = start
|
|
174
193
|
except Exception as exc:
|
|
175
194
|
failures.append(exc)
|
|
176
|
-
return
|
|
195
|
+
return starts, failures
|
|
177
196
|
|
|
178
197
|
|
|
179
|
-
def
|
|
198
|
+
def _nudged_rows(path, stamp):
|
|
199
|
+
"""Rows from the nudge on, plus the newest row, and the session's last timestamp."""
|
|
200
|
+
kept, end, newest = [], None, None
|
|
201
|
+
for row in _rows(Path(path)):
|
|
202
|
+
ts = _epoch(row.get('timestamp'))
|
|
203
|
+
if ts is None:
|
|
204
|
+
continue
|
|
205
|
+
if end is None or ts > end:
|
|
206
|
+
end, newest = ts, row
|
|
207
|
+
if ts >= stamp:
|
|
208
|
+
kept.append(row)
|
|
209
|
+
if newest is not None and (_epoch(newest.get('timestamp')) or 0) < stamp:
|
|
210
|
+
kept.append(newest)
|
|
211
|
+
return kept, end
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
def _successor_rows(path):
|
|
215
|
+
"""The opening rows of the next session, up to the requests classify prices."""
|
|
216
|
+
rows = []
|
|
217
|
+
for row in _rows(Path(path)):
|
|
218
|
+
rows.append(row)
|
|
219
|
+
if row.get('type') == 'assistant' and len(_requests(rows)) >= 50:
|
|
220
|
+
break
|
|
221
|
+
return rows
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
def _next_session(path, stamp, end, starts):
|
|
180
225
|
current = Path(path)
|
|
181
|
-
|
|
182
|
-
if not entry:
|
|
183
|
-
return None
|
|
184
|
-
end = entry[1]
|
|
185
|
-
choices = [(start, str(candidate), rows) for candidate, (start, _, rows) in index.items()
|
|
226
|
+
choices = [(start, str(candidate)) for candidate, start in starts.items()
|
|
186
227
|
if candidate != current and start > end and start > stamp]
|
|
187
|
-
if
|
|
188
|
-
return None, None
|
|
189
|
-
_, candidate, rows = min(choices)
|
|
190
|
-
return candidate, rows
|
|
228
|
+
return str(min(choices)[1]) if choices else None
|
|
191
229
|
|
|
192
230
|
|
|
193
231
|
def _session_ended(facade, sid, last_ts):
|
|
@@ -216,31 +254,51 @@ def resolve(facade, conn=None):
|
|
|
216
254
|
return
|
|
217
255
|
_schema(conn)
|
|
218
256
|
conn.commit()
|
|
219
|
-
events = conn.execute(
|
|
220
|
-
|
|
257
|
+
events = conn.execute("SELECT id,session_uuid,ts,context_tokens,transcript_path,savings_event_id FROM nudge_events WHERE status='pending' AND savings_event_id IS NULL").fetchall()
|
|
258
|
+
events = [event for event in events if event[4] and _epoch(event[2]) is not None]
|
|
259
|
+
first_stamp = {}
|
|
260
|
+
for _, _, ts, _, path, _ in events:
|
|
261
|
+
first_stamp[path] = min(first_stamp.get(path, float('inf')), _epoch(ts))
|
|
262
|
+
nudged = {}
|
|
263
|
+
for path, stamp in first_stamp.items():
|
|
264
|
+
try:
|
|
265
|
+
rows, end = _nudged_rows(path, stamp)
|
|
266
|
+
if end is not None:
|
|
267
|
+
nudged[path] = rows, end
|
|
268
|
+
except Exception as exc:
|
|
269
|
+
_diagnostic(facade, exc)
|
|
221
270
|
indexes = {}
|
|
222
|
-
for project in
|
|
271
|
+
for project in {Path(path).parent for path in first_stamp}:
|
|
272
|
+
ends = [end for path, (_, end) in nudged.items() if Path(path).parent == project]
|
|
223
273
|
try:
|
|
224
|
-
|
|
274
|
+
# A successor is written after the nudged session ends; allow clock skew.
|
|
275
|
+
starts, failures = _project_index(project, min(ends, default=float('inf')) - 300)
|
|
225
276
|
except Exception as exc:
|
|
226
|
-
|
|
277
|
+
starts, failures = {}, [exc]
|
|
227
278
|
for failure in failures:
|
|
228
279
|
_diagnostic(facade, failure)
|
|
229
|
-
indexes[project] =
|
|
280
|
+
indexes[project] = starts
|
|
281
|
+
successors = {}
|
|
230
282
|
prepared = {}
|
|
231
283
|
claimed_sessions = set()
|
|
232
284
|
events.sort(key=lambda event: (_epoch(event[2]) or 0, event[0]), reverse=True)
|
|
233
285
|
for ident, sid, ts, before, path, event_id in events:
|
|
234
|
-
if not
|
|
235
|
-
continue
|
|
236
|
-
entry = indexes[Path(path).parent].get(Path(path))
|
|
237
|
-
if not entry:
|
|
286
|
+
if path not in nudged:
|
|
238
287
|
continue
|
|
239
|
-
rows =
|
|
288
|
+
rows, end = nudged[path]
|
|
240
289
|
status, action, requests = classify(rows, ts)
|
|
241
290
|
if status == 'pending':
|
|
242
|
-
next_path
|
|
243
|
-
|
|
291
|
+
next_path = _next_session(path, _epoch(ts), end, indexes[Path(path).parent])
|
|
292
|
+
next_rows = None
|
|
293
|
+
if next_path and _session_ended(facade, sid, end):
|
|
294
|
+
if next_path not in successors:
|
|
295
|
+
try:
|
|
296
|
+
successors[next_path] = _successor_rows(next_path)
|
|
297
|
+
except Exception as exc:
|
|
298
|
+
_diagnostic(facade, exc)
|
|
299
|
+
successors[next_path] = None
|
|
300
|
+
next_rows = successors[next_path]
|
|
301
|
+
if next_rows:
|
|
244
302
|
status, action, requests = classify(rows, ts, next_rows)
|
|
245
303
|
if status == 'followed':
|
|
246
304
|
if next_path in claimed_sessions:
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""Which directories the project CLAUDE.md walk must skip.
|
|
2
|
+
|
|
3
|
+
The walk climbs from cwd looking for project CLAUDE.md files. The home
|
|
4
|
+
directory is skipped because ~/CLAUDE.md and the global CLAUDE.md are counted
|
|
5
|
+
separately. When HOME points somewhere else (a test sandbox, a scratch run),
|
|
6
|
+
the account's real home must be skipped too, or the walk reads the user's
|
|
7
|
+
own instruction files into a run that was meant to be isolated.
|
|
8
|
+
"""
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def homes(facade):
|
|
13
|
+
"""HOME as this process sees it, plus the OS account's own home."""
|
|
14
|
+
found = [facade.HOME]
|
|
15
|
+
try:
|
|
16
|
+
real = facade._real_account_home()
|
|
17
|
+
except Exception:
|
|
18
|
+
real = None
|
|
19
|
+
if real is not None:
|
|
20
|
+
found.append(real)
|
|
21
|
+
return found
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def is_home(facade, parent, known=None):
|
|
25
|
+
"""True when ``parent`` is HOME or the account's real home."""
|
|
26
|
+
for home in (known if known is not None else homes(facade)):
|
|
27
|
+
if parent == home or facade._same_path(parent, home):
|
|
28
|
+
return True
|
|
29
|
+
return False
|
|
@@ -57,7 +57,8 @@ def backoff_active(snapshot_dir, now=None):
|
|
|
57
57
|
age = (time.time() if now is None else now) - marker.stat().st_mtime
|
|
58
58
|
except OSError:
|
|
59
59
|
return False
|
|
60
|
-
|
|
60
|
+
# File clocks can run a moment ahead of time.time() (seen on Windows).
|
|
61
|
+
return -60 <= age < backoff_seconds()
|
|
61
62
|
|
|
62
63
|
|
|
63
64
|
def clear_backoff(snapshot_dir):
|
|
@@ -32,74 +32,129 @@ def _time(value):
|
|
|
32
32
|
return None
|
|
33
33
|
|
|
34
34
|
|
|
35
|
+
# Per-file events keyed by (path, mtime_ns, size). A dashboard build asks for
|
|
36
|
+
# this check more than once; an unchanged transcript is read only the first
|
|
37
|
+
# time, and a file that grew is read again on its own. Entries hold only the
|
|
38
|
+
# small records the check needs (sizes, stamps, call ids), never transcript text.
|
|
39
|
+
_EVENTS = {}
|
|
40
|
+
_EVENTS_MAX = 20000
|
|
41
|
+
_TAGS = ('"tool_use"', '"skill_listing"', '"deferred_tools_delta"', '"mcp_instructions_delta"')
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def _delta(kind, a):
|
|
45
|
+
"""What one tools/instructions delta adds, as (error type, mismatch, adds)."""
|
|
46
|
+
names = a.get('addedNames') or []
|
|
47
|
+
values = a.get('addedLines' if kind == 'deferred_tools_delta' else 'addedBlocks') or []
|
|
48
|
+
try:
|
|
49
|
+
if kind == 'deferred_tools_delta':
|
|
50
|
+
adds = []
|
|
51
|
+
for value in values:
|
|
52
|
+
if isinstance(value, str):
|
|
53
|
+
name = value.split(None, 1)[0] if value.strip() else ''
|
|
54
|
+
if _server(name):
|
|
55
|
+
adds.append((name, len(value)))
|
|
56
|
+
return None, False, adds
|
|
57
|
+
if len(names) == len(values):
|
|
58
|
+
return None, False, [(n, len(v)) for n, v in zip(names, values)
|
|
59
|
+
if isinstance(n, str) and isinstance(v, str)]
|
|
60
|
+
return None, True, []
|
|
61
|
+
except Exception as exc: # replayed only when the delta is in the window
|
|
62
|
+
return type(exc), False, []
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def _read_events(source):
|
|
66
|
+
"""One pass over a transcript: the records scan() weighs against `now`."""
|
|
67
|
+
ev = {'bad': False, 'error': False, 'listings': [], 'ops': [], 'calls': []}
|
|
68
|
+
try:
|
|
69
|
+
with source.open(encoding='utf-8', errors='replace') as stream:
|
|
70
|
+
for line in stream:
|
|
71
|
+
if not any(tag in line for tag in _TAGS):
|
|
72
|
+
continue
|
|
73
|
+
try:
|
|
74
|
+
record = json.loads(line)
|
|
75
|
+
except (ValueError, TypeError):
|
|
76
|
+
ev['bad'] = True
|
|
77
|
+
continue
|
|
78
|
+
if not isinstance(record, dict):
|
|
79
|
+
continue
|
|
80
|
+
a = record.get('attachment') or {}
|
|
81
|
+
if not isinstance(a, dict):
|
|
82
|
+
continue
|
|
83
|
+
kind = a.get('type')
|
|
84
|
+
stamp = _time(record.get('timestamp'))
|
|
85
|
+
if kind == 'skill_listing' and a.get('isInitial') and isinstance(a.get('content'), str):
|
|
86
|
+
ev['listings'].append((stamp, len(a['content']), a.get('skillCount')))
|
|
87
|
+
if kind in ('deferred_tools_delta', 'mcp_instructions_delta'):
|
|
88
|
+
ev['ops'].append((stamp, kind, a.get('removedNames') or []) + _delta(kind, a))
|
|
89
|
+
if record.get('type') != 'assistant':
|
|
90
|
+
continue
|
|
91
|
+
message = record.get('message') or {}
|
|
92
|
+
content = message.get('content') if isinstance(message, dict) else []
|
|
93
|
+
if not isinstance(content, list):
|
|
94
|
+
continue
|
|
95
|
+
for item in content:
|
|
96
|
+
if not isinstance(item, dict) or item.get('type') != 'tool_use':
|
|
97
|
+
continue
|
|
98
|
+
server = _server(item.get('name'))
|
|
99
|
+
if server:
|
|
100
|
+
ev['calls'].append((stamp, item.get('id'), _normalize(server)))
|
|
101
|
+
except OSError:
|
|
102
|
+
ev['error'] = True
|
|
103
|
+
return ev
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def _events(source):
|
|
107
|
+
try:
|
|
108
|
+
st = os.stat(source)
|
|
109
|
+
key = (str(source), st.st_mtime_ns, st.st_size)
|
|
110
|
+
except OSError:
|
|
111
|
+
key = None
|
|
112
|
+
if key is not None and key in _EVENTS:
|
|
113
|
+
return _EVENTS[key]
|
|
114
|
+
ev = _read_events(source)
|
|
115
|
+
if key is not None and not ev['error']:
|
|
116
|
+
if len(_EVENTS) >= _EVENTS_MAX:
|
|
117
|
+
_EVENTS.clear()
|
|
118
|
+
_EVENTS[key] = ev
|
|
119
|
+
return ev
|
|
120
|
+
|
|
121
|
+
|
|
35
122
|
def scan(paths, budget=None, now=None, days=30):
|
|
36
123
|
now = now or datetime.now(timezone.utc)
|
|
37
124
|
cutoff = now - timedelta(days=days)
|
|
125
|
+
week = now - timedelta(days=7)
|
|
38
126
|
listing, samples, used, seen_calls = [], {}, set(), set()
|
|
39
127
|
incomplete = False
|
|
40
128
|
for path in paths:
|
|
41
129
|
path = Path(path)
|
|
42
130
|
tools, instructions = {}, {}
|
|
43
|
-
have_listing = False
|
|
44
131
|
files = [path] + sorted((path.parent / path.stem / 'subagents').glob('*.jsonl'))
|
|
45
132
|
for source in files:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
for name in a.get('removedNames') or []:
|
|
72
|
-
target.pop(name, None)
|
|
73
|
-
if kind == 'deferred_tools_delta':
|
|
74
|
-
for value in values:
|
|
75
|
-
if isinstance(value, str):
|
|
76
|
-
name = value.split(None, 1)[0] if value.strip() else ''
|
|
77
|
-
if _server(name):
|
|
78
|
-
target[name] = len(value)
|
|
79
|
-
elif len(names) == len(values):
|
|
80
|
-
for name, value in zip(names, values):
|
|
81
|
-
if isinstance(name, str) and isinstance(value, str):
|
|
82
|
-
target[name] = len(value)
|
|
83
|
-
else:
|
|
84
|
-
incomplete = True
|
|
85
|
-
if record.get('type') != 'assistant':
|
|
86
|
-
continue
|
|
87
|
-
message = record.get('message') or {}
|
|
88
|
-
content = message.get('content') if isinstance(message, dict) else []
|
|
89
|
-
if not isinstance(content, list):
|
|
90
|
-
continue
|
|
91
|
-
for item in content:
|
|
92
|
-
if not isinstance(item, dict) or item.get('type') != 'tool_use':
|
|
93
|
-
continue
|
|
94
|
-
server = _server(item.get('name'))
|
|
95
|
-
call_id = item.get('id')
|
|
96
|
-
if server and (stamp is None or cutoff <= stamp <= now):
|
|
97
|
-
if not call_id or call_id not in seen_calls:
|
|
98
|
-
used.add(_normalize(server))
|
|
99
|
-
if call_id:
|
|
100
|
-
seen_calls.add(call_id)
|
|
101
|
-
except OSError:
|
|
102
|
-
incomplete = True
|
|
133
|
+
ev = _events(source)
|
|
134
|
+
incomplete = incomplete or ev['bad'] or ev['error']
|
|
135
|
+
if source == path:
|
|
136
|
+
for stamp, size, count in ev['listings']:
|
|
137
|
+
if stamp is not None and week <= stamp <= now:
|
|
138
|
+
listing.append((size, count))
|
|
139
|
+
break
|
|
140
|
+
for stamp, kind, removed, error, mismatch, adds in ev['ops']:
|
|
141
|
+
if stamp is None or not week <= stamp <= now:
|
|
142
|
+
continue
|
|
143
|
+
target = tools if kind == 'deferred_tools_delta' else instructions
|
|
144
|
+
for name in removed:
|
|
145
|
+
target.pop(name, None)
|
|
146
|
+
if error is not None:
|
|
147
|
+
raise error()
|
|
148
|
+
if mismatch:
|
|
149
|
+
incomplete = True
|
|
150
|
+
for name, size in adds:
|
|
151
|
+
target[name] = size
|
|
152
|
+
for stamp, call_id, server in ev['calls']:
|
|
153
|
+
if stamp is None or cutoff <= stamp <= now:
|
|
154
|
+
if not call_id or call_id not in seen_calls:
|
|
155
|
+
used.add(server)
|
|
156
|
+
if call_id:
|
|
157
|
+
seen_calls.add(call_id)
|
|
103
158
|
session = {}
|
|
104
159
|
for name, size in tools.items():
|
|
105
160
|
server = _server(name)
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"""Per-transcript facts for the cache TTL waste report, read once per file.
|
|
2
|
+
|
|
3
|
+
One dashboard build asks for the report over more than one window (30 days and
|
|
4
|
+
the dashboard's own history length). Every fact taken from a transcript here
|
|
5
|
+
is the same for any window, except the turn timestamps the window filters on,
|
|
6
|
+
so each file is parsed once and summarized by (path, mtime_ns, size). A file
|
|
7
|
+
that changed is parsed again on its own. Entries keep only token counts,
|
|
8
|
+
timestamps and rebuild events, never the parsed turns.
|
|
9
|
+
"""
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
import os
|
|
13
|
+
from datetime import datetime
|
|
14
|
+
|
|
15
|
+
_MAX = 20000
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _memo(f):
|
|
19
|
+
memo = f.__dict__.get('_ttl_file_memo')
|
|
20
|
+
if memo is None:
|
|
21
|
+
memo = {}
|
|
22
|
+
setattr(f, '_ttl_file_memo', memo)
|
|
23
|
+
return memo
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _stamp(raw):
|
|
27
|
+
"""Epoch seconds the explicit-TTL detector derives from a turn timestamp."""
|
|
28
|
+
if not raw:
|
|
29
|
+
return None
|
|
30
|
+
try:
|
|
31
|
+
return datetime.fromisoformat(str(raw).replace('Z', '+00:00')).timestamp()
|
|
32
|
+
except (ValueError, TypeError):
|
|
33
|
+
return None
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _summarize(f, filepath, parse_fn, runtime, tier_data, candidate_floor):
|
|
37
|
+
try:
|
|
38
|
+
turns = parse_fn(filepath)
|
|
39
|
+
except Exception:
|
|
40
|
+
return None, False
|
|
41
|
+
if not turns:
|
|
42
|
+
return None, True
|
|
43
|
+
model = f._dominant_turn_model(turns)
|
|
44
|
+
prof_key, profile = f._resolve_cache_profile(model, runtime=runtime)
|
|
45
|
+
kind = profile['cache_kind']
|
|
46
|
+
cache_read = full_input = 0
|
|
47
|
+
for turn in turns:
|
|
48
|
+
cr = int(turn.get('cache_read', 0) or 0)
|
|
49
|
+
cc = int(turn.get('cache_creation', 0) or 0)
|
|
50
|
+
cache_read += cr
|
|
51
|
+
full_input += cr + cc + int(turn.get('input_tokens', 0) or 0)
|
|
52
|
+
s = {'prof_key': prof_key, 'profile': profile, 'kind': kind,
|
|
53
|
+
'cache_read': cache_read, 'full_input': full_input}
|
|
54
|
+
if kind == 'explicit_ttl':
|
|
55
|
+
split = []
|
|
56
|
+
for turn in turns:
|
|
57
|
+
h1 = int(turn.get('cache_creation_1h', 0) or 0)
|
|
58
|
+
m5 = int(turn.get('cache_creation_5m', 0) or 0)
|
|
59
|
+
if h1 or m5:
|
|
60
|
+
split.append((f._keepwarm_iso_to_epoch(turn.get('timestamp')), h1, m5))
|
|
61
|
+
events = []
|
|
62
|
+
f._detect_explicit_ttl(
|
|
63
|
+
turns, tier_data, profile, dominant_model=model,
|
|
64
|
+
boundary=min(candidate_floor, profile.get('effective_ttl_seconds') or candidate_floor),
|
|
65
|
+
cutoff_ts=None, events_out=events)
|
|
66
|
+
s['split'] = split
|
|
67
|
+
s['events'] = [(_stamp(e.get('timestamp')), e) for e in events]
|
|
68
|
+
elif kind != 'none':
|
|
69
|
+
detail = {}
|
|
70
|
+
s['collapse'] = f._detect_automatic_collapse(turns, profile, dominant_model=model, detail_out=detail)
|
|
71
|
+
s['max_gap'] = detail.get('max_gap', 0)
|
|
72
|
+
return s, True
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def summary(f, filepath, parse_fn, runtime, tier_data, candidate_floor):
|
|
76
|
+
"""The file's window-independent facts, or None when it has no turns."""
|
|
77
|
+
try:
|
|
78
|
+
st = os.stat(filepath)
|
|
79
|
+
key = (str(filepath), st.st_mtime_ns, st.st_size, runtime, id(tier_data), candidate_floor,
|
|
80
|
+
id(parse_fn), id(f._resolve_cache_profile), id(f._detect_explicit_ttl),
|
|
81
|
+
id(f._detect_automatic_collapse), id(f._dominant_turn_model))
|
|
82
|
+
except OSError:
|
|
83
|
+
key = None
|
|
84
|
+
memo = _memo(f)
|
|
85
|
+
if key is not None and key in memo:
|
|
86
|
+
return memo[key]
|
|
87
|
+
s, cacheable = _summarize(f, filepath, parse_fn, runtime, tier_data, candidate_floor)
|
|
88
|
+
if key is not None and cacheable:
|
|
89
|
+
if len(memo) >= _MAX:
|
|
90
|
+
memo.clear()
|
|
91
|
+
memo[key] = s
|
|
92
|
+
return s
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def split_in_window(s, cutoff_ts):
|
|
96
|
+
"""1h and 5m cache-write tokens on turns inside the window."""
|
|
97
|
+
h1 = m5 = 0
|
|
98
|
+
for ts, a, b in s['split']:
|
|
99
|
+
if cutoff_ts is not None and (ts is None or ts < cutoff_ts):
|
|
100
|
+
continue
|
|
101
|
+
h1 += a
|
|
102
|
+
m5 += b
|
|
103
|
+
return h1, m5
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def events_in_window(s, cutoff_ts):
|
|
107
|
+
"""Fresh copies of the rebuilds whose resume turn is inside the window."""
|
|
108
|
+
return [dict(e) for ts, e in s['events']
|
|
109
|
+
if cutoff_ts is None or (ts is not None and ts >= cutoff_ts)]
|
|
@@ -1,15 +1,37 @@
|
|
|
1
1
|
"""Price a weekly activity window while reporting missing transcript coverage."""
|
|
2
2
|
|
|
3
|
+
import os
|
|
4
|
+
|
|
5
|
+
# Transcripts are append-only, so a file last modified before the window opened
|
|
6
|
+
# holds no record stamped inside it. One day of slack covers clock adjustments.
|
|
7
|
+
_SETTLED_SLACK_SECONDS = 86400
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def _settled_before(paths, start):
|
|
11
|
+
"""True when every file was last written well before ``start``.
|
|
12
|
+
|
|
13
|
+
Such a transcript contributes nothing to the window, so it is not parsed.
|
|
14
|
+
Any stat failure answers False and the file is parsed as before.
|
|
15
|
+
"""
|
|
16
|
+
cutoff = start.timestamp() - _SETTLED_SLACK_SECONDS
|
|
17
|
+
try:
|
|
18
|
+
return all(os.stat(p).st_mtime < cutoff for p in paths)
|
|
19
|
+
except (OSError, ValueError, OverflowError):
|
|
20
|
+
return False
|
|
21
|
+
|
|
3
22
|
|
|
4
23
|
def price(facade, conn, start, end, tier):
|
|
5
24
|
paths = conn.execute(
|
|
6
25
|
"SELECT jsonl_path, date, last_activity_day, cost_usd FROM session_log "
|
|
7
26
|
"WHERE input_tokens IS NOT NULL AND COALESCE(is_sidechain,0)=0").fetchall()
|
|
8
|
-
|
|
27
|
+
# Compare resolved paths: a file discovered under another spelling of a
|
|
28
|
+
# logged path (a symlinked config dir) is the same transcript.
|
|
29
|
+
known = {os.path.realpath(str(row[0])) for row in paths}
|
|
9
30
|
for path, _mtime, _ in facade._find_all_jsonl_files(None):
|
|
10
|
-
|
|
31
|
+
real = os.path.realpath(str(path))
|
|
32
|
+
if real not in known:
|
|
11
33
|
paths.append((str(path), '', None, None))
|
|
12
|
-
known.add(
|
|
34
|
+
known.add(real)
|
|
13
35
|
rows, missing = [], 0
|
|
14
36
|
costs, missing_cost, cost_complete = 0.0, 0.0, True
|
|
15
37
|
request_ledger = {}
|
|
@@ -25,6 +47,8 @@ def price(facade, conn, start, end, tier):
|
|
|
25
47
|
missing_cost += max(0.0, float(recorded_cost))
|
|
26
48
|
continue
|
|
27
49
|
children = facade._find_subagent_jsonl_files(path)
|
|
50
|
+
if _settled_before([path, *children], start):
|
|
51
|
+
continue
|
|
28
52
|
parsed = facade._parse_session_jsonl(path, window_start=start, window_end=end)
|
|
29
53
|
if parsed and parsed.get('is_sidechain'):
|
|
30
54
|
continue
|
|
@@ -492,18 +492,27 @@ def _bridge_selftest_check() -> dict:
|
|
|
492
492
|
_hint("Re-run `python3 measure.py antigravity-install` to refresh the payload."),
|
|
493
493
|
)
|
|
494
494
|
out = (proc.stdout or "").strip()
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
495
|
+
try:
|
|
496
|
+
reply = json.loads(out) if out else None
|
|
497
|
+
except (json.JSONDecodeError, ValueError):
|
|
498
|
+
return _check(
|
|
499
|
+
"fail",
|
|
500
|
+
"bridge self-test",
|
|
501
|
+
f"stdout is not valid JSON; the host would read the hook as "
|
|
502
|
+
f"malformed (stdout: {out[:200]!r}).",
|
|
503
|
+
_hint("Re-run `python3 measure.py antigravity-install` to refresh the payload."),
|
|
504
|
+
)
|
|
505
|
+
# agy denies a PreToolUse reply that has no "decision", so a bare {} or
|
|
506
|
+
# empty stdout blocks every shell command even though it is valid JSON.
|
|
507
|
+
if not (isinstance(reply, dict) and reply.get("decision")):
|
|
508
|
+
return _check(
|
|
509
|
+
"fail",
|
|
510
|
+
"bridge self-test",
|
|
511
|
+
f"PreToolUse reply has no decision; agy treats that as deny and "
|
|
512
|
+
f"blocks every run_command (stdout: {out[:200]!r}).",
|
|
513
|
+
_hint("Re-run `python3 measure.py antigravity-install` to refresh the payload."),
|
|
514
|
+
)
|
|
515
|
+
return _check("ok", "bridge self-test", "exit 0, PreToolUse reply carries a decision")
|
|
507
516
|
|
|
508
517
|
|
|
509
518
|
def run_checks() -> list:
|
|
@@ -98,6 +98,18 @@ def _read_payload() -> dict | None:
|
|
|
98
98
|
return obj if isinstance(obj, dict) else None
|
|
99
99
|
|
|
100
100
|
|
|
101
|
+
# agy requires a PreToolUse reply to carry "decision" and treats a reply
|
|
102
|
+
# without one as deny, which blocked every run_command. "ask" defers to the
|
|
103
|
+
# user's own permission mode, so a no-op stays a no-op.
|
|
104
|
+
_PRE_TOOL_PASS = {"decision": "ask"}
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def _pre_tool_reply(out) -> dict:
|
|
108
|
+
if isinstance(out, dict) and out.get("decision"):
|
|
109
|
+
return out
|
|
110
|
+
return dict(_PRE_TOOL_PASS)
|
|
111
|
+
|
|
112
|
+
|
|
101
113
|
def _emit(obj: dict) -> None:
|
|
102
114
|
"""Write exactly one JSON object to stdout."""
|
|
103
115
|
try:
|
|
@@ -485,21 +497,24 @@ def main(argv=None) -> int:
|
|
|
485
497
|
event = sys.argv[1]
|
|
486
498
|
|
|
487
499
|
payload = _read_payload() or {}
|
|
500
|
+
pre_tool = event == "pre-tool-use"
|
|
488
501
|
|
|
489
502
|
try:
|
|
490
503
|
from runtime_env import antigravity_home
|
|
491
504
|
except Exception:
|
|
505
|
+
if pre_tool:
|
|
506
|
+
_emit(_pre_tool_reply({}))
|
|
492
507
|
return 0
|
|
493
508
|
|
|
494
509
|
try:
|
|
495
510
|
if not _consent_ok(antigravity_home()):
|
|
496
|
-
_emit({})
|
|
511
|
+
_emit(_pre_tool_reply({}) if pre_tool else {})
|
|
497
512
|
return 0
|
|
498
513
|
|
|
499
514
|
if event == "pre-invocation":
|
|
500
515
|
out = handle_pre_invocation(payload)
|
|
501
|
-
elif
|
|
502
|
-
out = handle_pre_tool_use(payload)
|
|
516
|
+
elif pre_tool:
|
|
517
|
+
out = _pre_tool_reply(handle_pre_tool_use(payload))
|
|
503
518
|
elif event == "stop":
|
|
504
519
|
out = handle_stop(payload)
|
|
505
520
|
else:
|
|
@@ -515,6 +530,8 @@ def main(argv=None) -> int:
|
|
|
515
530
|
traceback.print_exc(file=sys.stderr)
|
|
516
531
|
except Exception:
|
|
517
532
|
pass
|
|
533
|
+
if pre_tool:
|
|
534
|
+
_emit(_pre_tool_reply({}))
|
|
518
535
|
return 0
|
|
519
536
|
return 0
|
|
520
537
|
|
|
@@ -483,7 +483,7 @@ def render_run_sh(root: Path, pycache: Path, version: str) -> str:
|
|
|
483
483
|
# Required files for a usable install; the extracted package carries the rest.
|
|
484
484
|
_REQUIRED = ("hooks/hooks.json", "hooks/python-launcher.sh", "hooks/run.py",
|
|
485
485
|
"skills/token-optimizer/scripts/measure.py", "skills/token-optimizer/scripts/session_store.py", "skills/token-optimizer/scripts/session_store_guard.py") + tuple(
|
|
486
|
-
"skills/token-optimizer/scripts/_measure/" + name for name in ('__init__.py', '_compat.py', 'runtime.py', 'pricing.py', 'audit.py', 'dashboard.py', 'lifecycle.py', 'sessions.py', 'trends.py', 'cache_policy.py', 'daemon.py', 'quality_archive.py', 'continuity.py', 'savings.py', 'cli.py', 'dashboard_history.py', 'weekly_activity.py', 'headline.py', 'counted_position.py', 'counted_pricing_v5.py', 'transcript_backfill.py', 'counted_subagents.py', 'lean_resume_threshold.py', 'output_reread.py', 'session_effect.py', 'structural_ledger.py', 'structural_archives.py', 'structural_listing.py', 'structural_report.py', 'structural_seed.py', 'structural_value.py', 'rework_metrics.py', 'session_best.py', 'savings_story.py', 'savings_headline.py', 'counted_orphans.py', 'counted_cap.py', 'archive_void_evidence.py', 'cost_per_message_trend.py', 'lean_resume_receivers.py', 'routing_period.py', 'fixture_context.py', 'transcript_product.py', 'periphery_exposure.py', 'structure_funnel.py', 'setup_attachment_counter.py', 'first_read_outcomes.py', 'setup_budget_monitor.py', 'setup_connector_ledger.py', 'first_call_context.py', 'timestamp_cache.py', 'token_type_split.py', 'evidence_parallel.py', 'ttl_period.py', 'first_read_revive.py', 'mcp_archive_tripwire.py', 'compaction_survival.py', 'archive_void_codex.py', 'compression_fixture_void.py', 'feature_health.py', 'archive_health.py', 'coverage_report.py', 'file_refetch.py', 'holdout_report.py', 'structural_dedupe.py', 'setup_step.py', 'baseline_provenance.py', 'own_price_card.py', 'transcript_stream.py', 'checkpoint_direction.py', 'checkpoint_retention.py', 'keepwarm_safety.py', 'keepwarm_economics.py', 'keepwarm_linux.py', 'mod_action_booking.py', 'mod_action_diagnostics.py', 'mod_action_selftest.py', 'install_baseline.py', 'routing_credit.py', 'mod_compaction_booking.py', 'mod_fresh_booking.py', 'quality_continuity.py', 'quality_checkpoint.py', 'codex_quality.py', 'lease_candidate_cleanup.py', 'session_store_spool.py', 'upgrade_drain_control.py', 'compression_scan_checkpoint.py', 'status_bar_lock.py', 'session_flush_lock.py', 'context_reset_marker.py', 'holdout_fallback.py', 'dashboard_heal_claim.py', 'selfheal_guard.py', 'config_cache.py', 'setup_observation_cache.py', 'status_bar_refresh.py', 'routing_default.py', 'pilot_report.py', 'nudge_followthrough.py', 'runway_all_in.py', 'session_activity.py', 'routing_savings.py', 'pt_resume_cues.py', 'subscription_audits.py', 'limit_units.py', 'local_adapt.py', 'prefix_cost.py', 'poc_commands.py', 'counted_closes.py', 'counted_headline.py', 'apply_safe.py', 'autocompact_advice.py', 'cold_guard.py', 'keepwarm_auto.py', 'keepwarm_rearm.py', 'next_actions.py')
|
|
486
|
+
"skills/token-optimizer/scripts/_measure/" + name for name in ('__init__.py', '_compat.py', 'runtime.py', 'pricing.py', 'audit.py', 'dashboard.py', 'lifecycle.py', 'sessions.py', 'trends.py', 'cache_policy.py', 'daemon.py', 'quality_archive.py', 'continuity.py', 'savings.py', 'cli.py', 'dashboard_history.py', 'weekly_activity.py', 'headline.py', 'counted_position.py', 'counted_pricing_v5.py', 'transcript_backfill.py', 'counted_subagents.py', 'lean_resume_threshold.py', 'output_reread.py', 'session_effect.py', 'structural_ledger.py', 'structural_archives.py', 'structural_listing.py', 'structural_report.py', 'structural_seed.py', 'structural_value.py', 'rework_metrics.py', 'session_best.py', 'savings_story.py', 'savings_headline.py', 'counted_orphans.py', 'counted_cap.py', 'archive_void_evidence.py', 'cost_per_message_trend.py', 'lean_resume_receivers.py', 'routing_period.py', 'fixture_context.py', 'transcript_product.py', 'periphery_exposure.py', 'structure_funnel.py', 'setup_attachment_counter.py', 'first_read_outcomes.py', 'setup_budget_monitor.py', 'setup_connector_ledger.py', 'first_call_context.py', 'timestamp_cache.py', 'token_type_split.py', 'evidence_parallel.py', 'ttl_period.py', 'first_read_revive.py', 'mcp_archive_tripwire.py', 'compaction_survival.py', 'archive_void_codex.py', 'compression_fixture_void.py', 'feature_health.py', 'archive_health.py', 'coverage_report.py', 'file_refetch.py', 'holdout_report.py', 'structural_dedupe.py', 'setup_step.py', 'baseline_provenance.py', 'own_price_card.py', 'transcript_stream.py', 'checkpoint_direction.py', 'checkpoint_retention.py', 'keepwarm_safety.py', 'keepwarm_economics.py', 'keepwarm_linux.py', 'mod_action_booking.py', 'mod_action_diagnostics.py', 'mod_action_selftest.py', 'install_baseline.py', 'routing_credit.py', 'mod_compaction_booking.py', 'mod_fresh_booking.py', 'quality_continuity.py', 'quality_checkpoint.py', 'codex_quality.py', 'lease_candidate_cleanup.py', 'session_store_spool.py', 'upgrade_drain_control.py', 'compression_scan_checkpoint.py', 'status_bar_lock.py', 'session_flush_lock.py', 'context_reset_marker.py', 'holdout_fallback.py', 'dashboard_heal_claim.py', 'selfheal_guard.py', 'config_cache.py', 'setup_observation_cache.py', 'status_bar_refresh.py', 'routing_default.py', 'pilot_report.py', 'nudge_followthrough.py', 'runway_all_in.py', 'session_activity.py', 'routing_savings.py', 'pt_resume_cues.py', 'subscription_audits.py', 'limit_units.py', 'local_adapt.py', 'prefix_cost.py', 'poc_commands.py', 'counted_closes.py', 'counted_headline.py', 'apply_safe.py', 'autocompact_advice.py', 'cold_guard.py', 'keepwarm_auto.py', 'keepwarm_rearm.py', 'next_actions.py', 'ttl_file_memo.py', 'project_md_walk.py')
|
|
487
487
|
)
|
|
488
488
|
|
|
489
489
|
# Written into the cache dir on install. Uninstall only removes the shared
|
|
@@ -64,7 +64,7 @@ SKILL_INSTALL_FILES = (
|
|
|
64
64
|
|
|
65
65
|
|
|
66
66
|
# Completeness is separate from the legacy healthy-output counts.
|
|
67
|
-
_MEASURE_PACKAGE_FILES = ('_measure/__init__.py', '_measure/_compat.py', '_measure/runtime.py', '_measure/pricing.py', '_measure/audit.py', '_measure/dashboard.py', '_measure/lifecycle.py', '_measure/sessions.py', '_measure/trends.py', '_measure/cache_policy.py', '_measure/daemon.py', '_measure/quality_archive.py', '_measure/continuity.py', '_measure/savings.py', '_measure/cli.py', '_measure/dashboard_history.py', '_measure/weekly_activity.py', '_measure/headline.py', '_measure/counted_position.py', '_measure/counted_pricing_v5.py', '_measure/transcript_backfill.py', '_measure/counted_subagents.py', '_measure/lean_resume_threshold.py', '_measure/output_reread.py', '_measure/session_effect.py', '_measure/structural_ledger.py', '_measure/structural_archives.py', '_measure/structural_listing.py', '_measure/structural_report.py', '_measure/structural_seed.py', '_measure/structural_value.py', '_measure/rework_metrics.py', '_measure/session_best.py', '_measure/savings_story.py', '_measure/savings_headline.py', '_measure/counted_orphans.py', '_measure/counted_cap.py', '_measure/archive_void_evidence.py', '_measure/cost_per_message_trend.py', '_measure/lean_resume_receivers.py', '_measure/routing_period.py', '_measure/fixture_context.py', '_measure/transcript_product.py', '_measure/periphery_exposure.py', '_measure/structure_funnel.py', '_measure/setup_attachment_counter.py', '_measure/first_read_outcomes.py', '_measure/setup_budget_monitor.py', '_measure/setup_connector_ledger.py', '_measure/first_call_context.py', '_measure/timestamp_cache.py', '_measure/token_type_split.py', '_measure/evidence_parallel.py', '_measure/ttl_period.py', '_measure/first_read_revive.py', '_measure/mcp_archive_tripwire.py', '_measure/compaction_survival.py', '_measure/archive_void_codex.py', '_measure/compression_fixture_void.py', '_measure/feature_health.py', '_measure/archive_health.py', '_measure/coverage_report.py', '_measure/file_refetch.py', '_measure/holdout_report.py', '_measure/structural_dedupe.py', '_measure/setup_step.py', '_measure/baseline_provenance.py', '_measure/own_price_card.py', '_measure/transcript_stream.py', '_measure/checkpoint_direction.py', '_measure/checkpoint_retention.py', '_measure/keepwarm_safety.py', '_measure/keepwarm_economics.py', '_measure/keepwarm_linux.py', '_measure/mod_action_booking.py', '_measure/mod_action_diagnostics.py', '_measure/mod_action_selftest.py', '_measure/install_baseline.py', '_measure/routing_credit.py', '_measure/mod_compaction_booking.py', '_measure/mod_fresh_booking.py', '_measure/quality_continuity.py', '_measure/quality_checkpoint.py', '_measure/codex_quality.py', '_measure/lease_candidate_cleanup.py', '_measure/session_store_spool.py', '_measure/upgrade_drain_control.py', '_measure/compression_scan_checkpoint.py', '_measure/status_bar_lock.py', '_measure/session_flush_lock.py', '_measure/context_reset_marker.py', '_measure/holdout_fallback.py', '_measure/dashboard_heal_claim.py', '_measure/selfheal_guard.py', '_measure/config_cache.py', '_measure/setup_observation_cache.py', '_measure/status_bar_refresh.py', '_measure/routing_default.py', '_measure/pilot_report.py', '_measure/nudge_followthrough.py', '_measure/runway_all_in.py', '_measure/session_activity.py', '_measure/routing_savings.py', '_measure/pt_resume_cues.py', '_measure/subscription_audits.py', '_measure/limit_units.py', '_measure/local_adapt.py', '_measure/prefix_cost.py', '_measure/poc_commands.py', '_measure/counted_closes.py', '_measure/counted_headline.py', '_measure/apply_safe.py', '_measure/autocompact_advice.py', '_measure/cold_guard.py', '_measure/keepwarm_auto.py', '_measure/keepwarm_rearm.py', '_measure/next_actions.py')
|
|
67
|
+
_MEASURE_PACKAGE_FILES = ('_measure/__init__.py', '_measure/_compat.py', '_measure/runtime.py', '_measure/pricing.py', '_measure/audit.py', '_measure/dashboard.py', '_measure/lifecycle.py', '_measure/sessions.py', '_measure/trends.py', '_measure/cache_policy.py', '_measure/daemon.py', '_measure/quality_archive.py', '_measure/continuity.py', '_measure/savings.py', '_measure/cli.py', '_measure/dashboard_history.py', '_measure/weekly_activity.py', '_measure/headline.py', '_measure/counted_position.py', '_measure/counted_pricing_v5.py', '_measure/transcript_backfill.py', '_measure/counted_subagents.py', '_measure/lean_resume_threshold.py', '_measure/output_reread.py', '_measure/session_effect.py', '_measure/structural_ledger.py', '_measure/structural_archives.py', '_measure/structural_listing.py', '_measure/structural_report.py', '_measure/structural_seed.py', '_measure/structural_value.py', '_measure/rework_metrics.py', '_measure/session_best.py', '_measure/savings_story.py', '_measure/savings_headline.py', '_measure/counted_orphans.py', '_measure/counted_cap.py', '_measure/archive_void_evidence.py', '_measure/cost_per_message_trend.py', '_measure/lean_resume_receivers.py', '_measure/routing_period.py', '_measure/fixture_context.py', '_measure/transcript_product.py', '_measure/periphery_exposure.py', '_measure/structure_funnel.py', '_measure/setup_attachment_counter.py', '_measure/first_read_outcomes.py', '_measure/setup_budget_monitor.py', '_measure/setup_connector_ledger.py', '_measure/first_call_context.py', '_measure/timestamp_cache.py', '_measure/token_type_split.py', '_measure/evidence_parallel.py', '_measure/ttl_period.py', '_measure/first_read_revive.py', '_measure/mcp_archive_tripwire.py', '_measure/compaction_survival.py', '_measure/archive_void_codex.py', '_measure/compression_fixture_void.py', '_measure/feature_health.py', '_measure/archive_health.py', '_measure/coverage_report.py', '_measure/file_refetch.py', '_measure/holdout_report.py', '_measure/structural_dedupe.py', '_measure/setup_step.py', '_measure/baseline_provenance.py', '_measure/own_price_card.py', '_measure/transcript_stream.py', '_measure/checkpoint_direction.py', '_measure/checkpoint_retention.py', '_measure/keepwarm_safety.py', '_measure/keepwarm_economics.py', '_measure/keepwarm_linux.py', '_measure/mod_action_booking.py', '_measure/mod_action_diagnostics.py', '_measure/mod_action_selftest.py', '_measure/install_baseline.py', '_measure/routing_credit.py', '_measure/mod_compaction_booking.py', '_measure/mod_fresh_booking.py', '_measure/quality_continuity.py', '_measure/quality_checkpoint.py', '_measure/codex_quality.py', '_measure/lease_candidate_cleanup.py', '_measure/session_store_spool.py', '_measure/upgrade_drain_control.py', '_measure/compression_scan_checkpoint.py', '_measure/status_bar_lock.py', '_measure/session_flush_lock.py', '_measure/context_reset_marker.py', '_measure/holdout_fallback.py', '_measure/dashboard_heal_claim.py', '_measure/selfheal_guard.py', '_measure/config_cache.py', '_measure/setup_observation_cache.py', '_measure/status_bar_refresh.py', '_measure/routing_default.py', '_measure/pilot_report.py', '_measure/nudge_followthrough.py', '_measure/runway_all_in.py', '_measure/session_activity.py', '_measure/routing_savings.py', '_measure/pt_resume_cues.py', '_measure/subscription_audits.py', '_measure/limit_units.py', '_measure/local_adapt.py', '_measure/prefix_cost.py', '_measure/poc_commands.py', '_measure/counted_closes.py', '_measure/counted_headline.py', '_measure/apply_safe.py', '_measure/autocompact_advice.py', '_measure/cold_guard.py', '_measure/keepwarm_auto.py', '_measure/keepwarm_rearm.py', '_measure/next_actions.py', '_measure/ttl_file_memo.py', '_measure/project_md_walk.py')
|
|
68
68
|
|
|
69
69
|
|
|
70
70
|
def _repo_root() -> Path:
|
|
@@ -357,7 +357,7 @@ def _registration_checks() -> list[dict[str, str]]:
|
|
|
357
357
|
|
|
358
358
|
|
|
359
359
|
# Completeness is separate from the legacy healthy-output counts.
|
|
360
|
-
_MEASURE_PACKAGE_FILES = ('_measure/__init__.py', '_measure/_compat.py', '_measure/runtime.py', '_measure/pricing.py', '_measure/audit.py', '_measure/dashboard.py', '_measure/lifecycle.py', '_measure/sessions.py', '_measure/trends.py', '_measure/cache_policy.py', '_measure/daemon.py', '_measure/quality_archive.py', '_measure/continuity.py', '_measure/savings.py', '_measure/cli.py', '_measure/dashboard_history.py', '_measure/weekly_activity.py', '_measure/headline.py', '_measure/counted_position.py', '_measure/counted_pricing_v5.py', '_measure/transcript_backfill.py', '_measure/counted_subagents.py', '_measure/lean_resume_threshold.py', '_measure/output_reread.py', '_measure/session_effect.py', '_measure/structural_ledger.py', '_measure/structural_archives.py', '_measure/structural_listing.py', '_measure/structural_report.py', '_measure/structural_seed.py', '_measure/structural_value.py', '_measure/rework_metrics.py', '_measure/session_best.py', '_measure/savings_story.py', '_measure/savings_headline.py', '_measure/counted_orphans.py', '_measure/counted_cap.py', '_measure/archive_void_evidence.py', '_measure/cost_per_message_trend.py', '_measure/lean_resume_receivers.py', '_measure/routing_period.py', '_measure/fixture_context.py', '_measure/transcript_product.py', '_measure/periphery_exposure.py', '_measure/structure_funnel.py', '_measure/setup_attachment_counter.py', '_measure/first_read_outcomes.py', '_measure/setup_budget_monitor.py', '_measure/setup_connector_ledger.py', '_measure/first_call_context.py', '_measure/timestamp_cache.py', '_measure/token_type_split.py', '_measure/evidence_parallel.py', '_measure/ttl_period.py', '_measure/first_read_revive.py', '_measure/mcp_archive_tripwire.py', '_measure/compaction_survival.py', '_measure/archive_void_codex.py', '_measure/compression_fixture_void.py', '_measure/feature_health.py', '_measure/archive_health.py', '_measure/coverage_report.py', '_measure/file_refetch.py', '_measure/holdout_report.py', '_measure/structural_dedupe.py', '_measure/setup_step.py', '_measure/baseline_provenance.py', '_measure/own_price_card.py', '_measure/transcript_stream.py', '_measure/checkpoint_direction.py', '_measure/checkpoint_retention.py', '_measure/keepwarm_safety.py', '_measure/keepwarm_economics.py', '_measure/keepwarm_linux.py', '_measure/mod_action_booking.py', '_measure/mod_action_diagnostics.py', '_measure/mod_action_selftest.py', '_measure/install_baseline.py', '_measure/routing_credit.py', '_measure/mod_compaction_booking.py', '_measure/mod_fresh_booking.py', '_measure/quality_continuity.py', '_measure/quality_checkpoint.py', '_measure/codex_quality.py', '_measure/lease_candidate_cleanup.py', '_measure/session_store_spool.py', '_measure/upgrade_drain_control.py', '_measure/compression_scan_checkpoint.py', '_measure/status_bar_lock.py', '_measure/session_flush_lock.py', '_measure/context_reset_marker.py', '_measure/holdout_fallback.py', '_measure/dashboard_heal_claim.py', '_measure/selfheal_guard.py', '_measure/config_cache.py', '_measure/setup_observation_cache.py', '_measure/status_bar_refresh.py', '_measure/routing_default.py', '_measure/pilot_report.py', '_measure/nudge_followthrough.py', '_measure/runway_all_in.py', '_measure/session_activity.py', '_measure/routing_savings.py', '_measure/pt_resume_cues.py', '_measure/subscription_audits.py', '_measure/limit_units.py', '_measure/local_adapt.py', '_measure/prefix_cost.py', '_measure/poc_commands.py', '_measure/counted_closes.py', '_measure/counted_headline.py', '_measure/apply_safe.py', '_measure/autocompact_advice.py', '_measure/cold_guard.py', '_measure/keepwarm_auto.py', '_measure/keepwarm_rearm.py', '_measure/next_actions.py')
|
|
360
|
+
_MEASURE_PACKAGE_FILES = ('_measure/__init__.py', '_measure/_compat.py', '_measure/runtime.py', '_measure/pricing.py', '_measure/audit.py', '_measure/dashboard.py', '_measure/lifecycle.py', '_measure/sessions.py', '_measure/trends.py', '_measure/cache_policy.py', '_measure/daemon.py', '_measure/quality_archive.py', '_measure/continuity.py', '_measure/savings.py', '_measure/cli.py', '_measure/dashboard_history.py', '_measure/weekly_activity.py', '_measure/headline.py', '_measure/counted_position.py', '_measure/counted_pricing_v5.py', '_measure/transcript_backfill.py', '_measure/counted_subagents.py', '_measure/lean_resume_threshold.py', '_measure/output_reread.py', '_measure/session_effect.py', '_measure/structural_ledger.py', '_measure/structural_archives.py', '_measure/structural_listing.py', '_measure/structural_report.py', '_measure/structural_seed.py', '_measure/structural_value.py', '_measure/rework_metrics.py', '_measure/session_best.py', '_measure/savings_story.py', '_measure/savings_headline.py', '_measure/counted_orphans.py', '_measure/counted_cap.py', '_measure/archive_void_evidence.py', '_measure/cost_per_message_trend.py', '_measure/lean_resume_receivers.py', '_measure/routing_period.py', '_measure/fixture_context.py', '_measure/transcript_product.py', '_measure/periphery_exposure.py', '_measure/structure_funnel.py', '_measure/setup_attachment_counter.py', '_measure/first_read_outcomes.py', '_measure/setup_budget_monitor.py', '_measure/setup_connector_ledger.py', '_measure/first_call_context.py', '_measure/timestamp_cache.py', '_measure/token_type_split.py', '_measure/evidence_parallel.py', '_measure/ttl_period.py', '_measure/first_read_revive.py', '_measure/mcp_archive_tripwire.py', '_measure/compaction_survival.py', '_measure/archive_void_codex.py', '_measure/compression_fixture_void.py', '_measure/feature_health.py', '_measure/archive_health.py', '_measure/coverage_report.py', '_measure/file_refetch.py', '_measure/holdout_report.py', '_measure/structural_dedupe.py', '_measure/setup_step.py', '_measure/baseline_provenance.py', '_measure/own_price_card.py', '_measure/transcript_stream.py', '_measure/checkpoint_direction.py', '_measure/checkpoint_retention.py', '_measure/keepwarm_safety.py', '_measure/keepwarm_economics.py', '_measure/keepwarm_linux.py', '_measure/mod_action_booking.py', '_measure/mod_action_diagnostics.py', '_measure/mod_action_selftest.py', '_measure/install_baseline.py', '_measure/routing_credit.py', '_measure/mod_compaction_booking.py', '_measure/mod_fresh_booking.py', '_measure/quality_continuity.py', '_measure/quality_checkpoint.py', '_measure/codex_quality.py', '_measure/lease_candidate_cleanup.py', '_measure/session_store_spool.py', '_measure/upgrade_drain_control.py', '_measure/compression_scan_checkpoint.py', '_measure/status_bar_lock.py', '_measure/session_flush_lock.py', '_measure/context_reset_marker.py', '_measure/holdout_fallback.py', '_measure/dashboard_heal_claim.py', '_measure/selfheal_guard.py', '_measure/config_cache.py', '_measure/setup_observation_cache.py', '_measure/status_bar_refresh.py', '_measure/routing_default.py', '_measure/pilot_report.py', '_measure/nudge_followthrough.py', '_measure/runway_all_in.py', '_measure/session_activity.py', '_measure/routing_savings.py', '_measure/pt_resume_cues.py', '_measure/subscription_audits.py', '_measure/limit_units.py', '_measure/local_adapt.py', '_measure/prefix_cost.py', '_measure/poc_commands.py', '_measure/counted_closes.py', '_measure/counted_headline.py', '_measure/apply_safe.py', '_measure/autocompact_advice.py', '_measure/cold_guard.py', '_measure/keepwarm_auto.py', '_measure/keepwarm_rearm.py', '_measure/next_actions.py', '_measure/ttl_file_memo.py', '_measure/project_md_walk.py')
|
|
361
361
|
|
|
362
362
|
|
|
363
363
|
def _engine_checks() -> list[dict[str, str]]:
|
|
@@ -106,7 +106,7 @@ _ENABLE_SNIPPET = "plugins:\n enabled:\n - token-optimizer\n"
|
|
|
106
106
|
|
|
107
107
|
|
|
108
108
|
# Completeness is separate from the legacy healthy-output counts.
|
|
109
|
-
_MEASURE_PACKAGE_FILES = ('_measure/__init__.py', '_measure/_compat.py', '_measure/runtime.py', '_measure/pricing.py', '_measure/audit.py', '_measure/dashboard.py', '_measure/lifecycle.py', '_measure/sessions.py', '_measure/trends.py', '_measure/cache_policy.py', '_measure/daemon.py', '_measure/quality_archive.py', '_measure/continuity.py', '_measure/savings.py', '_measure/cli.py', '_measure/dashboard_history.py', '_measure/weekly_activity.py', '_measure/headline.py', '_measure/counted_position.py', '_measure/counted_pricing_v5.py', '_measure/transcript_backfill.py', '_measure/counted_subagents.py', '_measure/lean_resume_threshold.py', '_measure/output_reread.py', '_measure/session_effect.py', '_measure/structural_ledger.py', '_measure/structural_archives.py', '_measure/structural_listing.py', '_measure/structural_report.py', '_measure/structural_seed.py', '_measure/structural_value.py', '_measure/rework_metrics.py', '_measure/session_best.py', '_measure/savings_story.py', '_measure/savings_headline.py', '_measure/counted_orphans.py', '_measure/counted_cap.py', '_measure/archive_void_evidence.py', '_measure/cost_per_message_trend.py', '_measure/lean_resume_receivers.py', '_measure/routing_period.py', '_measure/fixture_context.py', '_measure/transcript_product.py', '_measure/periphery_exposure.py', '_measure/structure_funnel.py', '_measure/setup_attachment_counter.py', '_measure/first_read_outcomes.py', '_measure/setup_budget_monitor.py', '_measure/setup_connector_ledger.py', '_measure/first_call_context.py', '_measure/timestamp_cache.py', '_measure/token_type_split.py', '_measure/evidence_parallel.py', '_measure/ttl_period.py', '_measure/first_read_revive.py', '_measure/mcp_archive_tripwire.py', '_measure/compaction_survival.py', '_measure/archive_void_codex.py', '_measure/compression_fixture_void.py', '_measure/feature_health.py', '_measure/archive_health.py', '_measure/coverage_report.py', '_measure/file_refetch.py', '_measure/holdout_report.py', '_measure/structural_dedupe.py', '_measure/setup_step.py', '_measure/baseline_provenance.py', '_measure/own_price_card.py', '_measure/transcript_stream.py', '_measure/checkpoint_direction.py', '_measure/checkpoint_retention.py', '_measure/keepwarm_safety.py', '_measure/keepwarm_economics.py', '_measure/keepwarm_linux.py', '_measure/mod_action_booking.py', '_measure/mod_action_diagnostics.py', '_measure/mod_action_selftest.py', '_measure/install_baseline.py', '_measure/routing_credit.py', '_measure/mod_compaction_booking.py', '_measure/mod_fresh_booking.py', '_measure/quality_continuity.py', '_measure/quality_checkpoint.py', '_measure/codex_quality.py', '_measure/lease_candidate_cleanup.py', '_measure/session_store_spool.py', '_measure/upgrade_drain_control.py', '_measure/compression_scan_checkpoint.py', '_measure/status_bar_lock.py', '_measure/session_flush_lock.py', '_measure/context_reset_marker.py', '_measure/holdout_fallback.py', '_measure/dashboard_heal_claim.py', '_measure/selfheal_guard.py', '_measure/config_cache.py', '_measure/setup_observation_cache.py', '_measure/status_bar_refresh.py', '_measure/routing_default.py', '_measure/pilot_report.py', '_measure/nudge_followthrough.py', '_measure/runway_all_in.py', '_measure/session_activity.py', '_measure/routing_savings.py', '_measure/pt_resume_cues.py', '_measure/subscription_audits.py', '_measure/limit_units.py', '_measure/local_adapt.py', '_measure/prefix_cost.py', '_measure/poc_commands.py', '_measure/counted_closes.py', '_measure/counted_headline.py', '_measure/apply_safe.py', '_measure/autocompact_advice.py', '_measure/cold_guard.py', '_measure/keepwarm_auto.py', '_measure/keepwarm_rearm.py', '_measure/next_actions.py')
|
|
109
|
+
_MEASURE_PACKAGE_FILES = ('_measure/__init__.py', '_measure/_compat.py', '_measure/runtime.py', '_measure/pricing.py', '_measure/audit.py', '_measure/dashboard.py', '_measure/lifecycle.py', '_measure/sessions.py', '_measure/trends.py', '_measure/cache_policy.py', '_measure/daemon.py', '_measure/quality_archive.py', '_measure/continuity.py', '_measure/savings.py', '_measure/cli.py', '_measure/dashboard_history.py', '_measure/weekly_activity.py', '_measure/headline.py', '_measure/counted_position.py', '_measure/counted_pricing_v5.py', '_measure/transcript_backfill.py', '_measure/counted_subagents.py', '_measure/lean_resume_threshold.py', '_measure/output_reread.py', '_measure/session_effect.py', '_measure/structural_ledger.py', '_measure/structural_archives.py', '_measure/structural_listing.py', '_measure/structural_report.py', '_measure/structural_seed.py', '_measure/structural_value.py', '_measure/rework_metrics.py', '_measure/session_best.py', '_measure/savings_story.py', '_measure/savings_headline.py', '_measure/counted_orphans.py', '_measure/counted_cap.py', '_measure/archive_void_evidence.py', '_measure/cost_per_message_trend.py', '_measure/lean_resume_receivers.py', '_measure/routing_period.py', '_measure/fixture_context.py', '_measure/transcript_product.py', '_measure/periphery_exposure.py', '_measure/structure_funnel.py', '_measure/setup_attachment_counter.py', '_measure/first_read_outcomes.py', '_measure/setup_budget_monitor.py', '_measure/setup_connector_ledger.py', '_measure/first_call_context.py', '_measure/timestamp_cache.py', '_measure/token_type_split.py', '_measure/evidence_parallel.py', '_measure/ttl_period.py', '_measure/first_read_revive.py', '_measure/mcp_archive_tripwire.py', '_measure/compaction_survival.py', '_measure/archive_void_codex.py', '_measure/compression_fixture_void.py', '_measure/feature_health.py', '_measure/archive_health.py', '_measure/coverage_report.py', '_measure/file_refetch.py', '_measure/holdout_report.py', '_measure/structural_dedupe.py', '_measure/setup_step.py', '_measure/baseline_provenance.py', '_measure/own_price_card.py', '_measure/transcript_stream.py', '_measure/checkpoint_direction.py', '_measure/checkpoint_retention.py', '_measure/keepwarm_safety.py', '_measure/keepwarm_economics.py', '_measure/keepwarm_linux.py', '_measure/mod_action_booking.py', '_measure/mod_action_diagnostics.py', '_measure/mod_action_selftest.py', '_measure/install_baseline.py', '_measure/routing_credit.py', '_measure/mod_compaction_booking.py', '_measure/mod_fresh_booking.py', '_measure/quality_continuity.py', '_measure/quality_checkpoint.py', '_measure/codex_quality.py', '_measure/lease_candidate_cleanup.py', '_measure/session_store_spool.py', '_measure/upgrade_drain_control.py', '_measure/compression_scan_checkpoint.py', '_measure/status_bar_lock.py', '_measure/session_flush_lock.py', '_measure/context_reset_marker.py', '_measure/holdout_fallback.py', '_measure/dashboard_heal_claim.py', '_measure/selfheal_guard.py', '_measure/config_cache.py', '_measure/setup_observation_cache.py', '_measure/status_bar_refresh.py', '_measure/routing_default.py', '_measure/pilot_report.py', '_measure/nudge_followthrough.py', '_measure/runway_all_in.py', '_measure/session_activity.py', '_measure/routing_savings.py', '_measure/pt_resume_cues.py', '_measure/subscription_audits.py', '_measure/limit_units.py', '_measure/local_adapt.py', '_measure/prefix_cost.py', '_measure/poc_commands.py', '_measure/counted_closes.py', '_measure/counted_headline.py', '_measure/apply_safe.py', '_measure/autocompact_advice.py', '_measure/cold_guard.py', '_measure/keepwarm_auto.py', '_measure/keepwarm_rearm.py', '_measure/next_actions.py', '_measure/ttl_file_memo.py', '_measure/project_md_walk.py')
|
|
110
110
|
|
|
111
111
|
|
|
112
112
|
def _scripts_dir() -> Path:
|