Skip to content

Polish cache-hit telemetry + spec reconcile & archive#52

Merged
silversurfer562 merged 7 commits into
mainfrom
claude/crazy-nash-8e60e0
Jun 7, 2026
Merged

Polish cache-hit telemetry + spec reconcile & archive#52
silversurfer562 merged 7 commits into
mainfrom
claude/crazy-nash-8e60e0

Conversation

@silversurfer562

Copy link
Copy Markdown
Member

This session's attune-author work.

Feature — polish prompt-cache hit-rate telemetry (spec polish-cache-hit-metrics):

  • call_anthropic gains optional on_cache_usage callback; polish.py adds PolishCacheStats + in-process accumulator; end-of-run summary logs Polish cache hit: NN% (...) with a <50% regression warning.
  • 16 new tests; README "Cache hit rate" section; CHANGELOG entry. Full suite 990 passed (only unrelated date-bomb failures in test_maintenance_batch.py — flagged separately).

Spec reconciliation:

Archive: moved 4 terminal specs (polish-fact-check, polish-cache-hit-metrics, regen-pipeline, regen-staleness-hash-mismatch) into docs/specs/archive/. skill-export-evangelism kept active (open, awaiting topic decision).

🤖 Generated with Claude Code

silversurfer562 and others added 7 commits June 6, 2026 19:05
…eans

Audit found regen-pipeline was marked "complete" with all 24 tasks
checked, but none of its named symbols ever shipped in either repo
(attune-author: _regen, regen_template(corpus_root=...),
_resolve_corpus_root, atomic_write, _patch_summaries_json;
attune-gui: /api/config, /api/templates/refresh-all,
/api/browse/directory, CorpusSetup, App.jsx). A bogus "Shipped" note
had conflated it with the unrelated hash-mismatch regenerate CLI.

The 3 user stories are all satisfied by a more evolved architecture:
- regen: POST /api/living-docs/docs/{id}/regenerate (Jobs +
  generate_feature_templates)
- corpus config: multi-corpus registry + workspace config
- bulk: make regen-all

No genuine product gaps remain. This commit corrects the spec docs:
- requirements.md: status -> reconciled, with user-story->reality map
- design.md: marked obsolete (assumes React/JSX + single corpus_root)
- tasks.md: flags the false done-marks and corrects the Shipped note

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…0.14.2)

Status said "Implementation TBD" but the fix shipped in PR #48
(commit 1b1c7c5), released in 0.14.2: apply_polish_results now
re-injects deterministic frontmatter via _replace_polished_frontmatter,
with regression test tests/unit/test_polished_frontmatter_reinjection.py
and a CHANGELOG entry. Status corrected to reflect shipped reality.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…metrics)

Each polish run now tracks Anthropic prompt-cache token usage and logs
a one-line summary at the end of `attune-author regenerate`:

  Polish cache hit: 87% (1241 read / 1421 total tokens, 6 call(s))

A WARNING is appended when the run's hit rate < 50% (with >=1 cacheable
token), surfacing silent cache regressions (prompt edits, model alias
drift). Hit rate = read / (read + creation) cacheable input tokens.

Implementation:
- doc_gen/_anthropic.call_anthropic gains an optional
  on_cache_usage(creation, read, model) callback; _log_cache_usage now
  returns (creation, read). Backward compatible — doc-gen passes nothing.
- polish.py: PolishCacheStats dataclass, in-process accumulator
  (_polish_cache_telemetry / reset_polish_cache_telemetry, mirroring
  generator._faithfulness_telemetry), polish_cache_stats(), and
  format_polish_cache_summary(). _call_llm wires the callback.
- maintenance.py: reset at run start, log summary at run end alongside
  the faithfulness summary.

Deviation from the written spec: attune-author has no telemetry JSONL,
so the metric follows the existing in-process faithfulness-counter
pattern instead of a new JSONL subsystem; the threshold warning is
current-run, not cross-run. Acceptance criteria in decisions.md all met.

Tests: 16 new in tests/unit/test_polish_cache_metrics.py (callback
firing incl. zero case, hit-rate math, accumulator, summary, warning).
Docs: README "Cache hit rate" subsection; CHANGELOG [Unreleased].
Spec docs updated to DONE with the deviation noted.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…s change

Auto-regenerated by the pre-commit help-freshness hook following the
polish prompt-cache telemetry work (d4af5a3).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Move terminal specs into docs/specs/archive/ so they stop inflating the
active count: polish-fact-check (v0.14.0), polish-cache-hit-metrics
(done), regen-staleness-hash-mismatch (#48/0.14.2), regen-pipeline
(superseded). skill-export-evangelism kept active (open).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The _state() helper hardcoded submitted_at=2026-05-08, which silently
expired past the 29-day retention window on 2026-06-06 and broke the
status/cancel tests (they read batch state without an injected now=).
Default to now-1day so the fixture stays inside the window.

Fixes the 3 date-bomb failures in test_maintenance_batch.py
(TestStatus/TestCancel).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.67925% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/attune_author/polish.py 92.68% 2 Missing and 1 partial ⚠️
src/attune_author/maintenance.py 66.66% 1 Missing and 1 partial ⚠️
src/attune_author/doc_gen/_anthropic.py 83.33% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@silversurfer562 silversurfer562 merged commit e4ce8d3 into main Jun 7, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant