@alexgreensh/token-optimizer 5.13.81 → 5.13.83
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/assets/savings_story.js +6 -4
- package/skills/token-optimizer/scripts/_measure/__init__.py +1 -1
- package/skills/token-optimizer/scripts/_measure/continuity.py +30 -3
- package/skills/token-optimizer/scripts/_measure/cost_per_message_trend.py +32 -15
- package/skills/token-optimizer/scripts/_measure/daemon.py +25 -2
- package/skills/token-optimizer/scripts/_measure/dashboard.py +2 -1
- package/skills/token-optimizer/scripts/_measure/feature_health.py +14 -5
- package/skills/token-optimizer/scripts/_measure/install_baseline.py +2 -1
- package/skills/token-optimizer/scripts/_measure/like_for_like.py +329 -0
- package/skills/token-optimizer/scripts/_measure/limit_units.py +39 -0
- package/skills/token-optimizer/scripts/_measure/model_families.py +133 -0
- package/skills/token-optimizer/scripts/_measure/own_price_card.py +38 -14
- package/skills/token-optimizer/scripts/_measure/pilot_report.py +197 -48
- package/skills/token-optimizer/scripts/_measure/pricing.py +7 -2
- package/skills/token-optimizer/scripts/_measure/quality_archive.py +41 -19
- package/skills/token-optimizer/scripts/_measure/quality_continuity.py +2 -0
- package/skills/token-optimizer/scripts/_measure/savings.py +155 -80
- package/skills/token-optimizer/scripts/_measure/sessions.py +7 -2
- package/skills/token-optimizer/scripts/_measure/trends.py +20 -2
- package/skills/token-optimizer/scripts/_measure/weekly_activity.py +37 -4
- package/skills/token-optimizer/scripts/antigravity_doctor.py +42 -6
- package/skills/token-optimizer/scripts/antigravity_install.py +18 -9
- 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/cursor_coach.py +5 -4
- package/skills/token-optimizer/scripts/cursor_install.py +1 -0
- package/skills/token-optimizer/scripts/delta_serve.py +174 -0
- package/skills/token-optimizer/scripts/devin_source.py +1 -1
- package/skills/token-optimizer/scripts/hermes_doctor.py +2 -1
- package/skills/token-optimizer/scripts/hermes_install.py +2 -1
- package/skills/token-optimizer/scripts/measure.py +14 -21
- package/skills/token-optimizer/scripts/read_cache.py +19 -76
- package/skills/token-optimizer/scripts/reset_epoch.py +5 -3
- package/skills/token-optimizer/scripts/session_activity.py +1 -1
- package/skills/token-optimizer/scripts/session_store.py +5 -6
|
@@ -7,6 +7,32 @@ import os
|
|
|
7
7
|
_SETTLED_SLACK_SECONDS = 86400
|
|
8
8
|
|
|
9
9
|
|
|
10
|
+
def _merge_model_usage(into, extra):
|
|
11
|
+
for model, tokens in (extra or {}).items():
|
|
12
|
+
try:
|
|
13
|
+
value = float(tokens or 0)
|
|
14
|
+
except (TypeError, ValueError):
|
|
15
|
+
continue
|
|
16
|
+
if value > 0:
|
|
17
|
+
into[model] = into.get(model, 0) + value
|
|
18
|
+
return into
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _merge_breakdown(into, extra):
|
|
22
|
+
for model, parts in (extra or {}).items():
|
|
23
|
+
if not isinstance(parts, dict):
|
|
24
|
+
continue
|
|
25
|
+
target = into.setdefault(model, {})
|
|
26
|
+
for key, value in parts.items():
|
|
27
|
+
if isinstance(value, (int, float)) and not isinstance(value, bool):
|
|
28
|
+
target[key] = target.get(key, 0) + value
|
|
29
|
+
elif key == "requests" and isinstance(value, list):
|
|
30
|
+
target[key] = list(target.get(key) or []) + list(value)
|
|
31
|
+
elif key not in target:
|
|
32
|
+
target[key] = value
|
|
33
|
+
return into
|
|
34
|
+
|
|
35
|
+
|
|
10
36
|
def _settled_before(paths, start):
|
|
11
37
|
"""True when every file was last written well before ``start``.
|
|
12
38
|
|
|
@@ -62,6 +88,8 @@ def price(facade, conn, start, end, tier):
|
|
|
62
88
|
inp, out = parsed['total_input_tokens'], parsed['total_output_tokens']
|
|
63
89
|
cw1, cw5 = parsed['total_cache_create_1h'], parsed['total_cache_create_5m']
|
|
64
90
|
child_cache_read = 0
|
|
91
|
+
combined_usage = _merge_model_usage({}, parsed.get('model_usage'))
|
|
92
|
+
combined_breakdown = _merge_breakdown({}, parsed.get('model_usage_breakdown'))
|
|
65
93
|
for child in children:
|
|
66
94
|
cp = facade._parse_session_jsonl(child, window_start=start, window_end=end)
|
|
67
95
|
if cp:
|
|
@@ -71,16 +99,21 @@ def price(facade, conn, start, end, tier):
|
|
|
71
99
|
cw1 += cp['total_cache_create_1h']
|
|
72
100
|
cw5 += cp['total_cache_create_5m']
|
|
73
101
|
child_cache_read += cp['total_cache_read']
|
|
102
|
+
_merge_model_usage(combined_usage, cp.get('model_usage'))
|
|
103
|
+
_merge_breakdown(combined_breakdown, cp.get('model_usage_breakdown'))
|
|
74
104
|
if not parsed['api_calls'] and inp + out == 0:
|
|
75
105
|
continue
|
|
76
106
|
if recorded_cost is None:
|
|
77
107
|
cost_complete = False
|
|
78
108
|
else:
|
|
79
109
|
costs += max(0.0, float(recorded_cost))
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
110
|
+
parent_usage = facade.json.dumps(parsed['model_usage'])
|
|
111
|
+
usage = facade.json.dumps(combined_usage)
|
|
112
|
+
cache_read = float(parsed.get('total_cache_read') or 0) + child_cache_read
|
|
113
|
+
hit = cache_read / inp if inp else 0
|
|
114
|
+
rows.append((inp, out, cw5, cw1, hit, parent_usage, usage,
|
|
115
|
+
parsed['api_calls'], parsed['message_count'],
|
|
116
|
+
facade.json.dumps(combined_breakdown)))
|
|
84
117
|
total = len(rows) + missing
|
|
85
118
|
cost_share = missing_cost / (costs + missing_cost) if cost_complete and costs + missing_cost > 0 else None
|
|
86
119
|
# Beyond 5% missing, a partial workload is too incomplete to headline.
|
|
@@ -40,6 +40,10 @@ DAEMON_PORT = 24847
|
|
|
40
40
|
_VERSION_TIMEOUT_SECONDS = 5
|
|
41
41
|
|
|
42
42
|
|
|
43
|
+
def _is_windows() -> bool:
|
|
44
|
+
return os.name == "nt"
|
|
45
|
+
|
|
46
|
+
|
|
43
47
|
def _check(status: str, name: str, detail: str, hint: str = "") -> dict:
|
|
44
48
|
out = {"status": status, "name": name, "detail": detail}
|
|
45
49
|
if hint:
|
|
@@ -47,6 +51,15 @@ def _check(status: str, name: str, detail: str, hint: str = "") -> dict:
|
|
|
47
51
|
return out
|
|
48
52
|
|
|
49
53
|
|
|
54
|
+
def _measure_cli_current_python(*args: str) -> str:
|
|
55
|
+
command = _measure_cli(*args)
|
|
56
|
+
generic, sep, rest = command.partition(" ")
|
|
57
|
+
interpreter = os.path.basename(sys.executable)
|
|
58
|
+
if sep and interpreter and generic in {"python", "python3"}:
|
|
59
|
+
return f"{interpreter} {rest}"
|
|
60
|
+
return command
|
|
61
|
+
|
|
62
|
+
|
|
50
63
|
def _binary_checks() -> list:
|
|
51
64
|
checks = []
|
|
52
65
|
override = os.environ.get("TOKEN_OPTIMIZER_ANTIGRAVITY_BIN", "").strip()
|
|
@@ -194,7 +207,13 @@ def _plugin_checks() -> list:
|
|
|
194
207
|
config = json.loads(hooks_path.read_text(encoding="utf-8"))
|
|
195
208
|
group = config.get("token-optimizer") if isinstance(config, dict) else None
|
|
196
209
|
events = sorted(group.keys()) if isinstance(group, dict) else []
|
|
197
|
-
|
|
210
|
+
# PreToolUse is POSIX-only (the bash rewrite never runs on
|
|
211
|
+
# Windows). A Windows install that still carries it keeps working
|
|
212
|
+
# but is reported below so a reinstall removes it.
|
|
213
|
+
stale_windows_pre_tool = _is_windows() and "PreToolUse" in events
|
|
214
|
+
expected = {"PreInvocation", "Stop"} | (set() if _is_windows() else {"PreToolUse"})
|
|
215
|
+
if stale_windows_pre_tool:
|
|
216
|
+
expected.add("PreToolUse")
|
|
198
217
|
if not expected <= set(events):
|
|
199
218
|
raise ValueError(f"missing events: {sorted(expected - set(events))}")
|
|
200
219
|
# Every hook must call the bridge inside this plugin dir. Installs
|
|
@@ -208,11 +227,23 @@ def _plugin_checks() -> list:
|
|
|
208
227
|
cmds = [h.get("command", "") for h in handlers if isinstance(h, dict)]
|
|
209
228
|
if not any(isinstance(c, str) and any(s in c for s in spellings) for c in cmds):
|
|
210
229
|
raise ValueError(f"{name} hook does not call {bridge}")
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
230
|
+
if stale_windows_pre_tool:
|
|
231
|
+
reinstall = _measure_cli_current_python("antigravity-install")
|
|
232
|
+
checks.append(
|
|
233
|
+
_check(
|
|
234
|
+
"warn",
|
|
235
|
+
"plugin hooks",
|
|
236
|
+
f"{hooks_path} still registers PreToolUse, which is no "
|
|
237
|
+
"longer installed on Windows.",
|
|
238
|
+
_hint(f"Re-run `{reinstall}` to remove it."),
|
|
239
|
+
)
|
|
240
|
+
)
|
|
241
|
+
else:
|
|
242
|
+
checks.append(
|
|
243
|
+
_check(
|
|
244
|
+
"ok", "plugin hooks", f"{hooks_path} (events: {', '.join(events)})"
|
|
245
|
+
)
|
|
214
246
|
)
|
|
215
|
-
)
|
|
216
247
|
except (OSError, json.JSONDecodeError, ValueError) as exc:
|
|
217
248
|
checks.append(
|
|
218
249
|
_check(
|
|
@@ -512,7 +543,12 @@ def _bridge_selftest_check() -> dict:
|
|
|
512
543
|
f"blocks every run_command (stdout: {out[:200]!r}).",
|
|
513
544
|
_hint("Re-run `python3 measure.py antigravity-install` to refresh the payload."),
|
|
514
545
|
)
|
|
515
|
-
|
|
546
|
+
detail = (
|
|
547
|
+
"exit 0, bridge probe carries a decision"
|
|
548
|
+
if _is_windows()
|
|
549
|
+
else "exit 0, PreToolUse reply carries a decision"
|
|
550
|
+
)
|
|
551
|
+
return _check("ok", "bridge self-test", detail)
|
|
516
552
|
|
|
517
553
|
|
|
518
554
|
def run_checks() -> list:
|
|
@@ -139,6 +139,10 @@ def data_dir(home: Path) -> Path:
|
|
|
139
139
|
return home / "token-optimizer"
|
|
140
140
|
|
|
141
141
|
|
|
142
|
+
def _is_windows() -> bool:
|
|
143
|
+
return os.name == "nt"
|
|
144
|
+
|
|
145
|
+
|
|
142
146
|
def _hooks_config(bridge_path: Path) -> dict:
|
|
143
147
|
"""hooks.json per the Antigravity hooks contract (builtin agy-customizations
|
|
144
148
|
docs): a JSON object keyed by hook NAME; PreToolUse uses a matcher group,
|
|
@@ -157,18 +161,23 @@ def _hooks_config(bridge_path: Path) -> dict:
|
|
|
157
161
|
"timeout": timeout,
|
|
158
162
|
}
|
|
159
163
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
164
|
+
hooks = {
|
|
165
|
+
"PreInvocation": [cmd("pre-invocation", PRE_TIMEOUT_SEC)],
|
|
166
|
+
"Stop": [cmd("stop", STOP_TIMEOUT_SEC)],
|
|
167
|
+
}
|
|
168
|
+
if not _is_windows():
|
|
169
|
+
# Only the run_command tool is rewritten; the matcher keeps every
|
|
170
|
+
# other tool call out of the bridge's hot path entirely. Windows is
|
|
171
|
+
# not registered at all: the bridge never rewrites there, so the hook
|
|
172
|
+
# would only add a Python launch (and a chance to fail) to every
|
|
173
|
+
# shell command for nothing.
|
|
174
|
+
hooks = {
|
|
163
175
|
"PreToolUse": [
|
|
164
|
-
|
|
165
|
-
# other tool call out of the bridge's hot path entirely.
|
|
166
|
-
{"matcher": "run_command", "hooks": [pre_tool]},
|
|
176
|
+
{"matcher": "run_command", "hooks": [cmd("pre-tool-use", PRE_TIMEOUT_SEC)]},
|
|
167
177
|
],
|
|
168
|
-
|
|
169
|
-
"Stop": [cmd("stop", STOP_TIMEOUT_SEC)],
|
|
178
|
+
**hooks,
|
|
170
179
|
}
|
|
171
|
-
}
|
|
180
|
+
return {HOOK_NAME: hooks}
|
|
172
181
|
|
|
173
182
|
|
|
174
183
|
def _ensure_config_dir_permissions(path: Path) -> None:
|
|
@@ -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', 'ttl_file_memo.py', 'project_md_walk.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', 'like_for_like.py', 'model_families.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', '_measure/ttl_file_memo.py', '_measure/project_md_walk.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/like_for_like.py', '_measure/model_families.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:
|
|
@@ -156,7 +156,7 @@ def _collect_history(home: Path) -> dict:
|
|
|
156
156
|
return history
|
|
157
157
|
try:
|
|
158
158
|
available = {r[1] for r in conn.execute("PRAGMA table_info(session_log)").fetchall()}
|
|
159
|
-
want = {"jsonl_path", "input_tokens", "output_tokens", "quality_score"}
|
|
159
|
+
want = {"jsonl_path", "input_tokens", "output_tokens", "quality_score", "quality_grade"}
|
|
160
160
|
if not {"jsonl_path", "input_tokens", "output_tokens"} <= available:
|
|
161
161
|
history["note"] = "trends.db lacks the session_log columns the coach needs"
|
|
162
162
|
return history
|
|
@@ -180,7 +180,8 @@ def _collect_history(home: Path) -> dict:
|
|
|
180
180
|
history["tokens_resolved_sessions"] += 1
|
|
181
181
|
if "quality_score" in idx:
|
|
182
182
|
qs = _safe_float(row[idx["quality_score"]])
|
|
183
|
-
if
|
|
183
|
+
grade = row[idx["quality_grade"]] if "quality_grade" in idx else None
|
|
184
|
+
if qs is not None and ("quality_grade" not in idx or (grade is not None and grade != "?")):
|
|
184
185
|
quality_scores.append(qs)
|
|
185
186
|
if quality_scores:
|
|
186
187
|
history["average_quality_score"] = round(sum(quality_scores) / len(quality_scores), 1)
|
|
@@ -431,7 +432,7 @@ def _generate(cursor_home: Any = None, *, days: int = 30, focus: Any = None) ->
|
|
|
431
432
|
for view in session_view:
|
|
432
433
|
provenance[view["token_source"]] = provenance.get(view["token_source"], 0) + 1
|
|
433
434
|
|
|
434
|
-
scores = [q["score"] for q in qualities]
|
|
435
|
+
scores = [q["score"] for q in qualities if q.get("measured") and q.get("score") is not None]
|
|
435
436
|
health_score = round(sum(scores) / len(scores)) if scores else None
|
|
436
437
|
|
|
437
438
|
questions = [
|
|
@@ -455,7 +456,7 @@ def _generate(cursor_home: Any = None, *, days: int = 30, focus: Any = None) ->
|
|
|
455
456
|
"total_compactions": sum(s["compactions"] for s in session_view),
|
|
456
457
|
"token_provenance": provenance,
|
|
457
458
|
"quality": {
|
|
458
|
-
"scored_sessions": len(
|
|
459
|
+
"scored_sessions": len(scores),
|
|
459
460
|
"average_score": round(sum(scores) / len(scores), 1) if scores else None,
|
|
460
461
|
"signals_note": (
|
|
461
462
|
"per-signal provenance on every score; unavailable signals "
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Serve a changed-file diff instead of a full re-read (delta mode), for read_cache.
|
|
3
|
+
|
|
4
|
+
Called from read_cache's PreToolUse Read path once a diff smaller than the file
|
|
5
|
+
exists. It refreshes the cache entry, logs the decision and answers with a deny
|
|
6
|
+
plus the diff. A deny is not a read the host records, so the entry is marked
|
|
7
|
+
"delta_served": read_cache lets the next read of that file through to the host
|
|
8
|
+
(#361). Without that, hosts that refuse Edit until a Read succeeds loop.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
import sys
|
|
14
|
+
import time
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
from typing import Any, Callable
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
DELTA_SERVED = "delta_served"
|
|
20
|
+
DELTA_REREAD = "delta_read_reread"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def host_requires_successful_read() -> bool:
|
|
24
|
+
"""True where the host refuses Edit until a real Read succeeds."""
|
|
25
|
+
try:
|
|
26
|
+
from runtime_env import detect_runtime, is_cowork
|
|
27
|
+
return detect_runtime() == "claude" or is_cowork()
|
|
28
|
+
except Exception:
|
|
29
|
+
return True
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def delta_read_pending(entry: dict[str, Any], mtime_match: bool, size_match: bool) -> bool:
|
|
33
|
+
"""True when the last answer for this file was a delta deny and nothing changed since."""
|
|
34
|
+
return bool(mtime_match and size_match and entry.get("last_replacement_type") == DELTA_SERVED)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def post_delta_full_read_required(entry: dict[str, Any], mtime_match: bool, size_match: bool) -> bool:
|
|
38
|
+
"""True when this host needs the post-delta pass-through for its Edit gate."""
|
|
39
|
+
return delta_read_pending(entry, mtime_match, size_match) and host_requires_successful_read()
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def emit_reread_debit(*, entry: dict[str, Any], file_path: str, session_id: str, log_savings_fn: Callable[..., Any]) -> int:
|
|
43
|
+
"""Reverse the prior delta credit once the host pays the full read it was meant to avoid."""
|
|
44
|
+
debit = int(entry.get("delta_debit_tokens", 0) or 0)
|
|
45
|
+
if debit <= 0:
|
|
46
|
+
return 0
|
|
47
|
+
entry["delta_debit_tokens"] = 0
|
|
48
|
+
name = Path(file_path).name
|
|
49
|
+
detail = f"{name}: full reread after delta"
|
|
50
|
+
log_savings_fn(DELTA_REREAD, debit, session_id, detail)
|
|
51
|
+
try:
|
|
52
|
+
from compression_log import log_compression_event
|
|
53
|
+
log_compression_event(
|
|
54
|
+
feature=DELTA_REREAD,
|
|
55
|
+
session_id=session_id,
|
|
56
|
+
command_pattern=f"Read:{name}",
|
|
57
|
+
quality_preserved=True,
|
|
58
|
+
verified=True,
|
|
59
|
+
tier="measured",
|
|
60
|
+
detail="full reread after delta",
|
|
61
|
+
original_tokens=0,
|
|
62
|
+
compressed_tokens=debit,
|
|
63
|
+
)
|
|
64
|
+
except Exception:
|
|
65
|
+
pass
|
|
66
|
+
return debit
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def serve_delta(
|
|
70
|
+
*,
|
|
71
|
+
file_path: str,
|
|
72
|
+
entry: dict[str, Any],
|
|
73
|
+
store: Any,
|
|
74
|
+
reset_epoch: Any,
|
|
75
|
+
session_id: str,
|
|
76
|
+
mode: str,
|
|
77
|
+
language: Any,
|
|
78
|
+
offset: int,
|
|
79
|
+
limit: int,
|
|
80
|
+
quiet: bool,
|
|
81
|
+
save_hook_context_enabled: bool,
|
|
82
|
+
current_stat: Any,
|
|
83
|
+
new_hash: str,
|
|
84
|
+
safe_new_content: str,
|
|
85
|
+
delta_text: str,
|
|
86
|
+
delta_stats: dict[str, Any],
|
|
87
|
+
old_tokens: int,
|
|
88
|
+
delta_tokens: int,
|
|
89
|
+
max_cache_bytes: int,
|
|
90
|
+
emit_fn: Callable[..., None],
|
|
91
|
+
log_decision_fn: Callable[..., Any],
|
|
92
|
+
log_savings_fn: Callable[..., Any],
|
|
93
|
+
reset_fn: Callable[[dict[str, Any]], Any],
|
|
94
|
+
) -> None:
|
|
95
|
+
"""Refresh the entry, log, and emit the delta deny."""
|
|
96
|
+
net_saved = max(0, old_tokens - delta_tokens)
|
|
97
|
+
entry["mtime_ns"] = current_stat.st_mtime_ns
|
|
98
|
+
entry["size_bytes"] = current_stat.st_size
|
|
99
|
+
entry["content_hash"] = new_hash
|
|
100
|
+
entry["delta_debit_tokens"] = net_saved
|
|
101
|
+
entry["read_count"] = int(entry.get("read_count", 0) or 0) + 1
|
|
102
|
+
entry["last_access"] = time.time()
|
|
103
|
+
reset_fn(entry)
|
|
104
|
+
entry["last_replacement_type"] = DELTA_SERVED
|
|
105
|
+
if len(safe_new_content.encode("utf-8", errors="replace")) <= max_cache_bytes:
|
|
106
|
+
store.upsert_cached_content(file_path, safe_new_content, new_hash)
|
|
107
|
+
cached = store.get_cached_content(file_path)
|
|
108
|
+
if not cached or cached.get("content_hash") != new_hash:
|
|
109
|
+
entry["content_hash"] = None
|
|
110
|
+
entry.pop("cached_content", None)
|
|
111
|
+
store.delete_cached_content(file_path)
|
|
112
|
+
else:
|
|
113
|
+
entry["cached_content"] = safe_new_content
|
|
114
|
+
else:
|
|
115
|
+
entry["content_hash"] = None
|
|
116
|
+
entry.pop("cached_content", None)
|
|
117
|
+
store.delete_cached_content(file_path)
|
|
118
|
+
store.upsert_file_entry(file_path, entry, expected_reset_epoch=reset_epoch)
|
|
119
|
+
|
|
120
|
+
log_decision_fn(
|
|
121
|
+
"block",
|
|
122
|
+
file_path,
|
|
123
|
+
f"delta_read_{entry['read_count']}",
|
|
124
|
+
session_id,
|
|
125
|
+
mode=mode,
|
|
126
|
+
actual_substitution=True,
|
|
127
|
+
eligible=True,
|
|
128
|
+
language=language,
|
|
129
|
+
reason_code="delta_diff",
|
|
130
|
+
offset=offset,
|
|
131
|
+
limit=limit,
|
|
132
|
+
replacement_type="delta",
|
|
133
|
+
file_tokens_est=old_tokens,
|
|
134
|
+
replacement_tokens_est=delta_tokens,
|
|
135
|
+
net_saved_tokens_est=net_saved,
|
|
136
|
+
replacement_fingerprint=new_hash[:16],
|
|
137
|
+
repeat_replacement_count=0,
|
|
138
|
+
save_hook_additional_context_enabled=save_hook_context_enabled,
|
|
139
|
+
)
|
|
140
|
+
log_savings_fn("delta_read", net_saved, session_id,
|
|
141
|
+
f"{Path(file_path).name}:+{delta_stats['added']}/-{delta_stats['removed']}")
|
|
142
|
+
# Log to compression_events for v5 telemetry
|
|
143
|
+
try:
|
|
144
|
+
from compression_log import log_compression_event
|
|
145
|
+
log_compression_event(
|
|
146
|
+
feature="delta_read",
|
|
147
|
+
session_id=session_id,
|
|
148
|
+
command_pattern=f"Read:{Path(file_path).name}",
|
|
149
|
+
quality_preserved=True,
|
|
150
|
+
verified=True,
|
|
151
|
+
tier="measured", # realized: reaches headline explicitly
|
|
152
|
+
detail=f"+{delta_stats['added']}/-{delta_stats['removed']}",
|
|
153
|
+
original_tokens=old_tokens,
|
|
154
|
+
compressed_tokens=delta_tokens,
|
|
155
|
+
)
|
|
156
|
+
except Exception:
|
|
157
|
+
pass
|
|
158
|
+
if not quiet:
|
|
159
|
+
print(
|
|
160
|
+
f"[Read Cache] Delta mode: {file_path} "
|
|
161
|
+
f"(+{delta_stats['added']}/-{delta_stats['removed']}, saved~{net_saved:,})",
|
|
162
|
+
file=sys.stderr,
|
|
163
|
+
)
|
|
164
|
+
if host_requires_successful_read():
|
|
165
|
+
suffix = "If the host refuses Edit because no full Read succeeded, read the file once more."
|
|
166
|
+
else:
|
|
167
|
+
suffix = "No extra full read is needed just to satisfy the host."
|
|
168
|
+
reason = (
|
|
169
|
+
f"{Path(file_path).name} was edited; showing diff "
|
|
170
|
+
f"(+{delta_stats['added']}/-{delta_stats['removed']} lines) "
|
|
171
|
+
f"instead of full re-read. {suffix}"
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
emit_fn("deny", reason, delta_text)
|
|
@@ -20,7 +20,7 @@ REPO_MODULES = frozenset((
|
|
|
20
20
|
'_measure', '_tomli', 'hook_skip_log', 'lean_resume_carry', 'structural',
|
|
21
21
|
'activity_tracker', 'adapter_hook_command', 'antigravity_doctor', 'antigravity_hook_bridge', 'antigravity_install',
|
|
22
22
|
'antigravity_proto', 'antigravity_session', 'antigravity_state', 'archive_result',
|
|
23
|
-
'bash_compress', 'bash_search_results', 'bash_compress_hook', 'bash_hook', 'bash_whitelist', 'benchmark', 'big_noncode_read', 'cloud_kit',
|
|
23
|
+
'bash_compress', 'bash_search_results', 'bash_compress_hook', 'bash_hook', 'bash_whitelist', 'benchmark', 'big_noncode_read', 'delta_serve', 'cloud_kit',
|
|
24
24
|
'build_output_compress', 'compact_markers', 'process_identity', 'codex_command_compress', 'codex_compact_prompt', 'codex_doctor',
|
|
25
25
|
'codex_hook_bridge', 'codex_hook_provenance', 'codex_install', 'codex_io', 'codex_log_index', 'codex_models',
|
|
26
26
|
'codex_session', 'codex_state', 'codex_statusline', 'command_filters',
|
|
@@ -80,6 +80,7 @@ REQUIRED_ENGINE_SCRIPTS = (
|
|
|
80
80
|
"archive_verify.py",
|
|
81
81
|
"context_intel.py",
|
|
82
82
|
"read_cache.py",
|
|
83
|
+
"delta_serve.py",
|
|
83
84
|
"compact_markers.py",
|
|
84
85
|
"process_identity.py",
|
|
85
86
|
"session_store.py",
|
|
@@ -357,7 +358,7 @@ def _registration_checks() -> list[dict[str, str]]:
|
|
|
357
358
|
|
|
358
359
|
|
|
359
360
|
# 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', '_measure/ttl_file_memo.py', '_measure/project_md_walk.py')
|
|
361
|
+
_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/like_for_like.py', '_measure/model_families.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
362
|
|
|
362
363
|
|
|
363
364
|
def _engine_checks() -> list[dict[str, str]]:
|
|
@@ -79,6 +79,7 @@ _ENGINE_SCRIPTS = (
|
|
|
79
79
|
"context_intel.py",
|
|
80
80
|
"read_cache.py",
|
|
81
81
|
"big_noncode_read.py",
|
|
82
|
+
"delta_serve.py",
|
|
82
83
|
"compact_markers.py",
|
|
83
84
|
"process_identity.py",
|
|
84
85
|
"session_store.py",
|
|
@@ -106,7 +107,7 @@ _ENABLE_SNIPPET = "plugins:\n enabled:\n - token-optimizer\n"
|
|
|
106
107
|
|
|
107
108
|
|
|
108
109
|
# 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', '_measure/ttl_file_memo.py', '_measure/project_md_walk.py')
|
|
110
|
+
_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/like_for_like.py', '_measure/model_families.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
111
|
|
|
111
112
|
|
|
112
113
|
def _scripts_dir() -> Path:
|