Repository navigation
Native data (G2): token-tool savings into Loki and Grafana, one series per native scope - #365
Merged
seathatflowsinourveins merged 1 commit intoSep 26, 2026
Conversation
seathatflowsinourveins
force-pushed
the
claude/monitor-token-savings-20260926
branch
from
September 26, 2026 21:42
2b2b56e to
f549728
Compare
…cope Native data adapter (observability/native-data): - snapshot.py: optional report_scopes maps entity ids to this host's token-report scope labels (labels stay private; rows carry only fixed ids and titles), and optional ai_memory.server_url (exact 127.0.0.1 origin) is passed as AI_MEMORY_SERVER_URL to the ai-memory 2.4 status command only. - native-data.service.example: PATH with a Node >=22 directory for QMD's `env node` launcher, RTK_TELEMETRY_DISABLED=1, python3 -B. - render.py: panel 20 draws each savings scope as its own series, grouped only by entity_id, never stacked or summed. A step shows a value only when the scope's newest row in that step is ok (newest ok observed_unix == newest observed_unix), so an earlier success never fills a failed or stale step; the legend carries no value. Checked on a sandboxed Loki 3.7.8 with a synthetic timeline: the previous state="ok"-only query showed 3 earlier successes in failed/stale steps, the guarded query shows none. savings_series() sits after by_query_source() so the G1 render.py change merges without conflict. - README: scheduled deployment (private paths, unit placeholders, stale bound, native undo commands), report_scopes and server_url, marked changed after `v2026.09.26.2`; adoption README/manifest list the recipe in the observability profile; docs/native-dashboard-data.md states the trend panel's gap rule and links the deployment section (both marked changed after `v2026.09.26.2`). - README undo (repair round 2, GPT-6 cross-family review p2-u2): `enable --now` on a timer that was already enabled but inactive starts it without recording that activation, so the earlier undo left it running. The README now reads the timer's UnitFileState and ActiveState before `enable --now`, disables it only if it was not enabled before and stops it only if it was not active before; a timer that was enabled but inactive gets its earlier unit files restored and is stopped again. The change sits inside the section already marked changed after `v2026.09.26.2`. - tests: literal guarded query, no legend value, report scope selection, server origin, unit examples, the documented undo order, and a contract test for the separate enablement/activation undo (it fails on the previous README). - manifests/evidence.json: changed files re-registered on current main; component_matrix and new_host_grand_list re-run with --write. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
seathatflowsinourveins
force-pushed
the
claude/monitor-token-savings-20260926
branch
from
September 26, 2026 22:14
f549728 to
d6fd17b
Compare
seathatflowsinourveins
deleted the
claude/monitor-token-savings-20260926
branch
September 26, 2026 22:30
This was referenced Sep 26, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The native-data adapter now publishes the token-tool savings to Loki as one series per native
scope. A new trend panel, 20, in the native-foundation dashboard draws them. On this workstation the
unchanged adapter left 5 measurement rows
unknown. The changed adapter, run against the real toolswith a systemd-like environment and no publish, had all 9 measurement rows
ok(6 savings,3 memory), plus 68 coverage rows, with 0 unknown and 0 stale.
The adapter needed three fixes to get there:
snapshot.py: optionalreport_scopesmaps entity ids to this host's token-report scope labels.The labels stay private, and rows carry only fixed ids and titles.
snapshot.py: optionalai_memory.server_url, an exact 127.0.0.1 origin, reaches the ai-memory2.4
statuscommand only.native-data.service.exampleputs a Node 22+ directory onPATHfor QMD'senv nodelauncher.render.py, panel 20: each scope is its own series, grouped only byentity_id, never stackedor summed. A step shows a value only when the scope's newest row in that step is
ok, so anearlier success never fills a failed or stale step. The legend carries no value.
README.md: scheduled deployment (private paths, unit placeholders, stale bound). The nativeundo reads the timer's earlier enablement and activation separately. The section is marked
changed after
v2026.09.26.2.The adoption README and manifest list the recipe in the
observabilityprofile.Scope
snapshot.py,render.py, the unit and configexamples, the README),
docs/native-dashboard-data.md, theobservabilityprofile's recipe pathsin
adoption/manifest.jsonandadoption/README.md, andtests/test_native_dashboard_data.py.803bc351.git merge-treeagainstorigin/maindde28cc2is clean.lane:foundation.manifests/evidence.jsonis only re-registered.observability/native-data/,docs/native-dashboard-data.md,adoption/(the
observabilityprofile, not a trading profile) andtests/.What was verified
2b2b56e9scripts/validate.py(6,917 hashed files, 159 receipts),evidence_manifest.py --check,component_matrix.py --check,new_host_grand_list.py --checkandbuild_ecosystem.py --checkall exit 0test_native_dashboard_data,test_adoption_docs_consistency,test_adoption_statusandtest_release_pin_contents: 162 OK, 1 skipped by designunittest discover -s tests -q: 6,237 tests, 635 skipped, 1 failure:test_pre_commit_gatehit the per-user gitleaks lock while another worktree's suite ran. The single rerun of that module passed 3 of 3.[3m]). The oldstate="ok"query showed 3 earlier successes in failed or stale steps. The guarded query matches all 25 expected values and all 8 expected gaps.pkg/loki/frame.gosets the step interval; Grafana v13.2.2nullInsertThreshold.tsinserts nulls, drawn as gaps withspanNulls: falsesystemctlstand-in, real coreutils) gave 20 PASS and 9 FAIL on the reviewed scripts and 29 of 29 on the repaired ones. ShellCheck 0.11.0 is clean andbash -npasses.apply.sh --dry-runon this worktree exits 0: 77 rows, 0 unknown, 0 stale. On the live clone it refuses until merge.rollback.sh --dry-runreports nothing to undo.Reviews (bounded to two rounds; the notes are in the session scratchpad):
Round 1, adversarial review by a Claude Opus reviewer (
p2rev/review-u2.md) found 10 defects,none blocking deployment. All 10 are fixed:
--purge-stateedge cases;--repositorycould point at a/tmpworktree;config.toml.Before the repair, 13 of 20 sandbox scenarios failed; after it, 20 of 20 passed. The resolution
is
u2-p2/REPAIR-1.md, commitb7e299fe.Round 2, GPT-6 cross-family review (
codex-rev/review-p2-u2.md) found 4 medium issues, andall held against the reviewed code:
All four are fixed. Findings 1, 2 and 4 are in the host scripts; finding 3 is in the README's
native undo and a new contract test, commit
2b2b56e9. The resolution isu2-p2/REPAIR-2.md.Host-apply plan (after merge)
apply.sh --applyruns only against the live clone, which followsorigin/main, or a cleancheckout at
origin/mainoutside temporary directories. So the host step waits until this PR hasmerged and the live clone has synced.
apply.sh --dry-runis read-only. It runs a no-publish preflight snapshot and lists the actions.apply.sh --applywrites the private config (0600) and the state directory (0700), then theecosystem-native-data.{service,timer}user units and the provisioned dashboard file. It recordseach file's sha256 and a backup of any file it replaces. It also records the timer's earlier
enablement and activation, and copies
rollback.shandprove.shbeside those records.prove.shruns onertk lsin a fresh temporary directory, waits for the next timer run andchecks the rows in Loki and the deployed panel through Grafana's anonymous Viewer API.
rollback.sh --applyrefuses, with nothing undone, if a recorded file changed afterthe apply. It undoes the timer's enablement and activation only where a recorded run changed
them.
Residuals
apply.sh,rollback.sh,prove.shand theirsandbox evidence live in the session scratchpad. The apply copies
rollback.shandprove.shinto its private state directory, but there is no committed receipt for the sandbox runs yet.
prove.shon the host have not run. The exact-equality check is backed by aserved-panel probe on the two existing dashboards, not yet on
native-foundation-data.enabled,disabledand not-found timer states were exercised.rollback --forceon a paththat became a directory, and a string datasource reference in prove.sh.
disableDeletion);manifests/evidence.json. Whichevermerges second takes
main's copy and re-registers its own files (hot-file protocol indocs/lanes.md).render.pyand the tests merge textually.SOTA sources
v13.2.2:packages/grafana-data/src/transformations/transformers/nulls/nullInsertThreshold.tsandpublic/app/plugins/panel/timeseries/utils.ts(gap insertion;spanNulls);docs/sources/administration/provisioning/index.md(file provisioning,disableDeletion).v13.2.0:pkg/loki/frame.go(the time field interval is thequery step).
v3.7.8:docs/sources/reference/loki-http-api.md(push and query APIs) anddocs/sources/query/metric_queries.md(last_over_time, vector matching).v255(the host's systemd 255):man/systemd.timer.xmlandman/systemctl.xml(
enable --now,UnitFileStateandActiveState).Decision record
No separate record. The deployment contract is in
observability/native-data/README.md("Scheduled deployment") and
docs/native-dashboard-data.md.🤖 Generated with Claude Code