agent-usage-tracker 0.3.0__tar.gz → 0.4.0__tar.gz

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.
Files changed (338) hide show
  1. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/PKG-INFO +3 -1
  2. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/docs/development.md +28 -0
  3. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/docs/evidence.md +100 -0
  4. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/pyproject.toml +2 -1
  5. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/__init__.py +1 -1
  6. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/backup.py +2 -0
  7. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/access.py +7 -2
  8. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/access_cli.py +86 -3
  9. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/access_mcp.py +27 -1
  10. agent_usage_tracker-0.4.0/src/agent_usage_tracker/improve/investigation.py +256 -0
  11. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/runtime.py +12 -6
  12. agent_usage_tracker-0.4.0/src/agent_usage_tracker/improve/session_observability.py +55 -0
  13. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/turn_revisions.py +11 -3
  14. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/collectors/test_cursor_api.py +5 -3
  15. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/collectors/test_source_registry.py +3 -1
  16. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_evidence_access.py +9 -4
  17. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_evidence_mcp.py +50 -0
  18. agent_usage_tracker-0.4.0/tests/improve/test_investigation.py +147 -0
  19. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_native_evidence.py +8 -0
  20. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_runtime.py +26 -0
  21. agent_usage_tracker-0.4.0/tests/improve/test_session_observability.py +43 -0
  22. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_turn_revisions.py +44 -5
  23. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/test_observation_server.py +14 -3
  24. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/.gitignore +0 -0
  25. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/CONTRACT.md +0 -0
  26. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/DEPLOY.md +0 -0
  27. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/LICENSE +0 -0
  28. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/README.md +0 -0
  29. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/config.example.toml +0 -0
  30. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/docs/assets/aut-local-setup.png +0 -0
  31. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/docs/assets/aut-workflow.png +0 -0
  32. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/docs/collectors-to-add.md +0 -0
  33. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/docs/first-run.md +0 -0
  34. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/docs/harness-coverage.md +0 -0
  35. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/docs/human-html/2026-11-08-understanding-implicit-state-machines.html +0 -0
  36. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/docs/human-html/2026-11-09-status-state-reliability-fixes.html +0 -0
  37. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/docs/human-html/docs-index.json +0 -0
  38. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/docs/human-html/index.html +0 -0
  39. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/docs/improvement-studies.md +0 -0
  40. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/docs/improvement.md +0 -0
  41. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/docs/local-labels.md +0 -0
  42. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/docs/new-laptop.md +0 -0
  43. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/docs/observations.md +0 -0
  44. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/docs/quota.md +0 -0
  45. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/docs/reference.md +0 -0
  46. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/docs/research/codexbar-learnings.md +0 -0
  47. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/docs/research/otel-lane.md +0 -0
  48. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/docs/research/sdk-usage-capture.md +0 -0
  49. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/docs/superpowers/plans/2026-07-22-aut-showcase-metrics.md +0 -0
  50. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/docs/superpowers/specs/2026-07-22-aut-showcase-metrics-design.md +0 -0
  51. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/packaging/README.md +0 -0
  52. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/packaging/claude/commands/outcome.md +0 -0
  53. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/packaging/launchd/aut-scan.sh +0 -0
  54. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/packaging/launchd/dev.aut.backup.plist +0 -0
  55. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/packaging/launchd/dev.aut.improve-audit.plist +0 -0
  56. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/packaging/launchd/dev.aut.improve-draft.plist +0 -0
  57. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/packaging/launchd/dev.aut.retry.plist +0 -0
  58. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/packaging/launchd/dev.aut.scan.plist +0 -0
  59. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/packaging/observations/Dockerfile +0 -0
  60. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/packaging/observations/Dockerfile.dockerignore +0 -0
  61. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/packaging/observations/README.md +0 -0
  62. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/packaging/observations/aut-observations.service +0 -0
  63. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/packaging/sql/turn-snapshot-grant.sql +0 -0
  64. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/packaging/systemd/agent-usage-tracker.service +0 -0
  65. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/packaging/systemd/agent-usage-tracker.timer +0 -0
  66. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/packaging/windows/register-task.ps1 +0 -0
  67. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/cli.py +0 -0
  68. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/collectors/__init__.py +0 -0
  69. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/collectors/_util.py +0 -0
  70. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/collectors/activity_common.py +0 -0
  71. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/collectors/activitywatch.py +0 -0
  72. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/collectors/claude_code.py +0 -0
  73. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/collectors/claude_code_activity.py +0 -0
  74. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/collectors/codex.py +0 -0
  75. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/collectors/commits.py +0 -0
  76. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/collectors/cursor.py +0 -0
  77. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/collectors/cursor_api.py +0 -0
  78. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/collectors/cursor_cli.py +0 -0
  79. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/collectors/cursor_sdk.py +0 -0
  80. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/collectors/generic_sdk.py +0 -0
  81. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/collectors/pi.py +0 -0
  82. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/collectors/session_digest.py +0 -0
  83. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/collectors/t3.py +0 -0
  84. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/config.py +0 -0
  85. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/coverage.py +0 -0
  86. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/coverage_catalog.json +0 -0
  87. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/cursor_run.py +0 -0
  88. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/demo.py +0 -0
  89. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/demo_cli.py +0 -0
  90. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/diagnostics.py +0 -0
  91. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/episode_store.py +0 -0
  92. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/event.py +0 -0
  93. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/git_day_cache.py +0 -0
  94. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/git_days.py +0 -0
  95. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/git_safe.py +0 -0
  96. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/harness_inventory.py +0 -0
  97. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/history_steers.py +0 -0
  98. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/__init__.py +0 -0
  99. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/case_view.py +0 -0
  100. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/cli.py +0 -0
  101. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/cursor_evidence.py +0 -0
  102. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/decide.py +0 -0
  103. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/desktop.py +0 -0
  104. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/draft.py +0 -0
  105. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/draft_adapters.py +0 -0
  106. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/draft_gguf.py +0 -0
  107. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/evidence.py +0 -0
  108. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/file_reads.py +0 -0
  109. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/groups.py +0 -0
  110. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/inbox.py +0 -0
  111. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/judge.py +0 -0
  112. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/outputs.py +0 -0
  113. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/proposals.py +0 -0
  114. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/qualify.py +0 -0
  115. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/ranked_search.py +0 -0
  116. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/report_card.py +0 -0
  117. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/rubric.py +0 -0
  118. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/rubrics/avoidable_recovery.md +0 -0
  119. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/rubrics/code_quality.md +0 -0
  120. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/rubrics/completion_supported.md +0 -0
  121. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/rubrics/redundant_tests.md +0 -0
  122. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/rubrics/verbosity.md +0 -0
  123. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/schedule.py +0 -0
  124. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/scores.py +0 -0
  125. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/search_check.py +0 -0
  126. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/setup_git.py +0 -0
  127. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/skill_proposals.py +0 -0
  128. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/store.py +0 -0
  129. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/studies.py +0 -0
  130. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/study_candidates.py +0 -0
  131. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/study_cli.py +0 -0
  132. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/study_decision.py +0 -0
  133. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/study_followup.py +0 -0
  134. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/study_independence.py +0 -0
  135. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/study_model_calls.py +0 -0
  136. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/study_observe.py +0 -0
  137. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/study_reviews.py +0 -0
  138. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/t3.py +0 -0
  139. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/trial.py +0 -0
  140. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve/validation.py +0 -0
  141. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/improve_publish.py +0 -0
  142. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/inspector.py +0 -0
  143. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/label/__init__.py +0 -0
  144. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/label/backends.py +0 -0
  145. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/label/bakeoff.py +0 -0
  146. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/label/baseline.py +0 -0
  147. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/label/clef.py +0 -0
  148. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/label/context.py +0 -0
  149. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/label/core.py +0 -0
  150. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/label/covered_run.py +0 -0
  151. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/label/evalset.py +0 -0
  152. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/label/gold.py +0 -0
  153. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/label/local.py +0 -0
  154. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/label/local_parallel.py +0 -0
  155. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/label/merge.py +0 -0
  156. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/label/outcome_coverage.py +0 -0
  157. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/label/replay.py +0 -0
  158. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/label/run.py +0 -0
  159. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/label/tasks.py +0 -0
  160. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/label/teach.py +0 -0
  161. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/local_page.py +0 -0
  162. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/manual_time.py +0 -0
  163. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/net.py +0 -0
  164. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/observation_cli.py +0 -0
  165. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/observation_report.py +0 -0
  166. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/observation_server.py +0 -0
  167. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/observations.py +0 -0
  168. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/operational_status.py +0 -0
  169. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/outcome_git.py +0 -0
  170. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/outcomes.py +0 -0
  171. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/overview.py +0 -0
  172. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/overview_cli.py +0 -0
  173. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/pricing.py +0 -0
  174. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/pricing_cli.py +0 -0
  175. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/push.py +0 -0
  176. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/quota.py +0 -0
  177. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/quota_cli.py +0 -0
  178. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/redact.py +0 -0
  179. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/repo_keys.py +0 -0
  180. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/review.py +0 -0
  181. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/scan.py +0 -0
  182. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/scheduled.py +0 -0
  183. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/sdk.py +0 -0
  184. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/setup_cli.py +0 -0
  185. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/setup_schedule.py +0 -0
  186. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/sink.py +0 -0
  187. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/sink_stack/README.md +0 -0
  188. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/sink_stack/apply.sh +0 -0
  189. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/sink_stack/compose.yaml +0 -0
  190. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/sink_stack/env.example +0 -0
  191. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/sink_stack/grafana/dashboards/agents-effort.json +0 -0
  192. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/sink_stack/grafana/dashboards/agents-usage.json +0 -0
  193. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/sink_stack/grafana/provisioning/dashboards/aut.yaml +0 -0
  194. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/sink_stack/grafana/provisioning/datasources/agents.yaml +0 -0
  195. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/sink_stack/sql/01_schema.sql +0 -0
  196. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/sink_stack/sql/02_price.sql +0 -0
  197. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/sink_stack/sql/03_effort.sql +0 -0
  198. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/sink_stack/sql/04_grants.sql +0 -0
  199. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/sink_stack/sql/refresh.sql +0 -0
  200. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/sources.py +0 -0
  201. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/state.py +0 -0
  202. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/summary.py +0 -0
  203. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/summary_cli.py +0 -0
  204. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/telemetry.py +0 -0
  205. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/src/agent_usage_tracker/usage_price.py +0 -0
  206. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/collectors/codex_pi_helpers.py +0 -0
  207. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/collectors/test_activity.py +0 -0
  208. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/collectors/test_activitywatch.py +0 -0
  209. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/collectors/test_activitywatch_macos.py +0 -0
  210. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/collectors/test_claude_code.py +0 -0
  211. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/collectors/test_claude_profiles.py +0 -0
  212. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/collectors/test_codex.py +0 -0
  213. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/collectors/test_codex_pi.py +0 -0
  214. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/collectors/test_collectors.py +0 -0
  215. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/collectors/test_commits.py +0 -0
  216. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/collectors/test_cursor.py +0 -0
  217. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/collectors/test_cursor_cli.py +0 -0
  218. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/collectors/test_cursor_cli_cache.py +0 -0
  219. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/collectors/test_cursor_sdk.py +0 -0
  220. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/collectors/test_generic_sdk.py +0 -0
  221. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/collectors/test_links.py +0 -0
  222. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/collectors/test_links_claude.py +0 -0
  223. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/collectors/test_pi.py +0 -0
  224. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/collectors/test_read_horizon.py +0 -0
  225. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/collectors/test_session_digest.py +0 -0
  226. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/collectors/test_t3.py +0 -0
  227. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/conftest.py +0 -0
  228. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/fixtures/claude-statusline-quota.json +0 -0
  229. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/__init__.py +0 -0
  230. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/conftest.py +0 -0
  231. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_case_context.py +0 -0
  232. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_case_view.py +0 -0
  233. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_cli.py +0 -0
  234. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_count_evidence.py +0 -0
  235. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_decide.py +0 -0
  236. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_desktop.py +0 -0
  237. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_draft.py +0 -0
  238. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_draft_adapters.py +0 -0
  239. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_evidence.py +0 -0
  240. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_evidence_citations.py +0 -0
  241. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_file_reads.py +0 -0
  242. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_groups.py +0 -0
  243. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_inbox.py +0 -0
  244. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_judge.py +0 -0
  245. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_judge_choices.py +0 -0
  246. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_judge_deadline.py +0 -0
  247. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_judge_native_deadline.py +0 -0
  248. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_judge_queue.py +0 -0
  249. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_judge_sampling.py +0 -0
  250. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_judge_stall.py +0 -0
  251. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_outputs.py +0 -0
  252. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_proposals.py +0 -0
  253. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_qualify.py +0 -0
  254. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_ranked_evidence.py +0 -0
  255. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_report_card.py +0 -0
  256. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_rubric.py +0 -0
  257. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_schedule.py +0 -0
  258. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_scores.py +0 -0
  259. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_search_check.py +0 -0
  260. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_skill_proposals.py +0 -0
  261. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_store.py +0 -0
  262. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_studies.py +0 -0
  263. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_studies_decision.py +0 -0
  264. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_study_candidates.py +0 -0
  265. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_t3.py +0 -0
  266. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_trial.py +0 -0
  267. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_turn_provenance.py +0 -0
  268. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/improve/test_validation.py +0 -0
  269. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/label/label_helpers.py +0 -0
  270. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/label/test_context_paths.py +0 -0
  271. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/label/test_covered_run.py +0 -0
  272. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/label/test_cursor_origin.py +0 -0
  273. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/label/test_history_steers.py +0 -0
  274. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/label/test_label.py +0 -0
  275. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/label/test_label_bakeoff.py +0 -0
  276. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/label/test_label_baseline.py +0 -0
  277. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/label/test_label_context.py +0 -0
  278. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/label/test_label_core.py +0 -0
  279. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/label/test_label_evalset.py +0 -0
  280. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/label/test_label_gap.py +0 -0
  281. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/label/test_label_gold.py +0 -0
  282. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/label/test_label_local.py +0 -0
  283. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/label/test_label_models.py +0 -0
  284. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/label/test_label_parallel.py +0 -0
  285. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/label/test_label_reliability.py +0 -0
  286. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/label/test_label_replay.py +0 -0
  287. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/label/test_label_tasks.py +0 -0
  288. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/label/test_label_teach.py +0 -0
  289. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/label/test_label_writing.py +0 -0
  290. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/label/test_outcome_coverage.py +0 -0
  291. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/outcomes/conftest.py +0 -0
  292. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/outcomes/test_outcome_git.py +0 -0
  293. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/outcomes/test_outcome_reliability.py +0 -0
  294. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/outcomes/test_outcomes.py +0 -0
  295. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/pipeline/fake_psycopg.py +0 -0
  296. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/pipeline/price_fixture.py +0 -0
  297. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/pipeline/test_backup.py +0 -0
  298. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/pipeline/test_cli.py +0 -0
  299. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/pipeline/test_coverage.py +0 -0
  300. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/pipeline/test_coverage_diagnostics.py +0 -0
  301. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/pipeline/test_coverage_scan.py +0 -0
  302. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/pipeline/test_cursor_run.py +0 -0
  303. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/pipeline/test_delivery_cli.py +0 -0
  304. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/pipeline/test_delivery_notices.py +0 -0
  305. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/pipeline/test_demo.py +0 -0
  306. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/pipeline/test_first_run.py +0 -0
  307. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/pipeline/test_git_day_cache.py +0 -0
  308. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/pipeline/test_git_days.py +0 -0
  309. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/pipeline/test_harness_inventory.py +0 -0
  310. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/pipeline/test_heartbeat.py +0 -0
  311. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/pipeline/test_inspect.py +0 -0
  312. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/pipeline/test_ledger_zone.py +0 -0
  313. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/pipeline/test_local_page.py +0 -0
  314. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/pipeline/test_net.py +0 -0
  315. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/pipeline/test_overview.py +0 -0
  316. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/pipeline/test_overview_quota.py +0 -0
  317. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/pipeline/test_pricing.py +0 -0
  318. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/pipeline/test_publish_improve.py +0 -0
  319. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/pipeline/test_push.py +0 -0
  320. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/pipeline/test_push_outbox.py +0 -0
  321. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/pipeline/test_push_snapshots.py +0 -0
  322. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/pipeline/test_quota.py +0 -0
  323. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/pipeline/test_redact.py +0 -0
  324. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/pipeline/test_repo_keys.py +0 -0
  325. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/pipeline/test_review.py +0 -0
  326. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/pipeline/test_scan_wrapper.py +0 -0
  327. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/pipeline/test_sessions.py +0 -0
  328. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/pipeline/test_sink.py +0 -0
  329. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/pipeline/test_sink_sql.py +0 -0
  330. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/pipeline/test_state.py +0 -0
  331. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/pipeline/test_summary.py +0 -0
  332. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/pipeline/test_summary_native_counts.py +0 -0
  333. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/test_observation_cli.py +0 -0
  334. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/test_observation_report.py +0 -0
  335. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/test_observations.py +0 -0
  336. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/test_observe_entrypoint.py +0 -0
  337. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/test_public_projection.py +0 -0
  338. {agent_usage_tracker-0.3.0 → agent_usage_tracker-0.4.0}/tests/test_telemetry.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: agent-usage-tracker
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: Track coding-agent usage and outcomes from local logs, find recurring problems, and test proposed fixes before adopting them.
5
5
  Project-URL: Homepage, https://github.com/rhnfzl/agent-usage-tracker
6
6
  Project-URL: Issues, https://github.com/rhnfzl/agent-usage-tracker/issues
@@ -14,6 +14,8 @@ Classifier: Programming Language :: Python :: 3
14
14
  Classifier: Topic :: Software Development
15
15
  Requires-Python: >=3.11
16
16
  Requires-Dist: tzdata; sys_platform == 'win32'
17
+ Provides-Extra: code
18
+ Requires-Dist: pydantic-monty<1.7,>=1.6; extra == 'code'
17
19
  Provides-Extra: label
18
20
  Requires-Dist: huggingface-hub>=1.3; (sys_platform == 'darwin' and platform_machine == 'arm64') and extra == 'label'
19
21
  Requires-Dist: mlx-lm<0.33,>=0.32.2; (sys_platform == 'darwin' and platform_machine == 'arm64') and extra == 'label'
@@ -36,6 +36,34 @@ In GitHub's branch protection for `main`, require a pull request and the `CI req
36
36
  Require branches to be up to date before merging, and apply the rule to administrators.
37
37
  CI also runs on `main` to verify the landed commit.
38
38
  SQL integration tests require a scratch database on a TimescaleDB server and `psql`, through `AUT_TEST_PG_DSN` with a literal IP address and port; otherwise those tests skip.
39
+
40
+ ## Local preflight and packages
41
+
42
+ Run these commands on macOS or Linux with `uv`, Docker Compose, `psql`, and Perl with `shasum` available.
43
+
44
+ ```bash
45
+ ./scripts/local-ci.sh quick
46
+ ./scripts/local-ci.sh check
47
+ ./scripts/local-ci.sh package HEAD
48
+ ```
49
+
50
+ `quick` runs Ruff. `check` runs Ruff, mypy, the two suite time zones, the MCP suite, and the SQL and Compose checks.
51
+ These checks run concurrently. The preflight reserves cores for other checks and uses up to six pytest workers per time zone.
52
+ Set `AUT_CI_WORKERS` to lower the worker count per time zone if the machine is busy.
53
+ It uses a disposable TimescaleDB container on a random loopback port.
54
+ The preflight defaults to Python 3.11. Set `AUT_CI_PYTHON` to test another supported version.
55
+ For the Mac batch publisher, pass `./scripts/local-ci.sh quick` as `--light` and `./scripts/local-ci.sh check` as `--full`.
56
+ The full local preflight fails above 60 seconds, including dependency setup and cleanup.
57
+ It lets every check finish and reports the results before rejecting an over-budget run.
58
+ GitHub still runs the required platform matrix for the pull request. That run has its own runner queue and timing.
59
+
60
+ `package` builds a wheel from the source distribution of the named commit.
61
+ It checks both distributions, installs the wheel in isolation, and saves the artifacts under `dist/local-<short-commit>/`.
62
+ The directory contains `SOURCE_COMMIT` and `SHA256SUMS` for deployment verification.
63
+ Build from the merged commit when preparing a deployment candidate.
64
+ Check the bundle with `shasum -a 256 -c SHA256SUMS` from its output directory.
65
+ Use the verified wheel with the [standalone runtime installer](improvement.md#install-a-stable-runtime) to stage an upgrade before switching a timer.
66
+
39
67
  To release, raise `__version__` in `src/agent_usage_tracker/__init__.py`, merge, and push the tag `v<version>`.
40
68
  The [release workflow](../.github/workflows/release.yml) builds it and publishes it to PyPI through trusted publishing.
41
69
  Use synthetic fixtures in public contributions. Keep session logs, personal labels, and private benchmarks out of commits.
@@ -179,3 +179,103 @@ hash. To trial the addition, explicitly list the file with a null value in `file
179
179
  SHA-256 hash in `files.candidate`. This binds the trial to the absence of the skill before the change.
180
180
  A successful tool result is evidence for the cited step. Review whether the proposed instructions
181
181
  apply to the whole workflow before you adopt the skill.
182
+
183
+ ## Run a programmable investigation
184
+
185
+ A recipe can use evidence from one session to decide what to search for in another.
186
+ Give it explicit audits or bundles, then return citations, a timeline, a hypothesis,
187
+ or a statistic with its counting rule.
188
+
189
+ ```sh
190
+ pip install 'agent-usage-tracker[code]'
191
+ aut evidence code-catalog
192
+ aut evidence --audit FIRST --content redacted run-code follow.py --include-audit SECOND --save
193
+ ```
194
+
195
+ For example, put this program in `follow.py`. It takes a lead from a match in the
196
+ first audit and searches the second. The last expression becomes the JSON result.
197
+
198
+ ```python
199
+ seed = read("search", query="setup failed", limit=1)
200
+ found = []
201
+ if seed["data"]["items"]:
202
+ query = seed["data"]["items"][0]["preview"].split()[-1]
203
+ cursor = ""
204
+ while cursor is not None:
205
+ page = read("search", scope="2", lead=seed["receipt"], query=query, cursor=cursor)
206
+ for hit in page["data"]["items"]:
207
+ found.append({"session_id": hit["session_id"], "event_id": hit["event_id"]})
208
+ cursor = page["data"]["next_cursor"]
209
+ found
210
+ ```
211
+
212
+ Use `-` in place of the path to read source from stdin. Pass a JSON object with
213
+ `--params` to populate the program's `params` variable. The `scopes` variable lists
214
+ the actual coverage and content grant per source. Scope `1` is the main audit or
215
+ bundle. Additional audits come next, followed by additional bundles. Each type
216
+ retains command-line order. Bundles can narrow the content grant. Code mode
217
+ defaults to redacted access. Existing direct commands keep their own defaults.
218
+
219
+ The catalog lists the read operations, their parameters, and defaults. Set `lead`
220
+ to an earlier read's receipt to record which observation motivated a later read.
221
+ Each successful read records available event references, a result digest, and
222
+ whether a further page was offered. Continue an empty page if it has a cursor.
223
+ Check scope and session coverage before drawing conclusions. A returned citation
224
+ identifies an observed record. A person or a reviewed rule must check what it
225
+ supports. Snapshot IDs may repeat across audits or change after a recapture.
226
+ When comparing distinct source sessions, use an available source identity and
227
+ report cases where it is unknown. The readers expose recorded Git outcomes and
228
+ study evidence. They require independently verified links for joins with usage
229
+ or records outside the selected evidence.
230
+
231
+ Recipes run in fresh local Monty sessions. The runner limits source size, host
232
+ calls, evidence bytes, output, and wall time. Failed execution reports an error.
233
+ Recipes use the Python subset supported by Monty. They get no general host
234
+ filesystem, network, or shell operations. Plan a stopping rule for recursive
235
+ searches, and report which leads you left open if you stop early.
236
+
237
+ Save a run with `--save` to keep its program, parameters, scopes, and read receipts
238
+ in the private AUT store. Saving can retain sensitive text in a program or its
239
+ parameters. The default AUT backup exclusions cover this directory under the
240
+ standard store and `AUT_IMPROVE_ROOT`. Add a backup exclusion when using a different
241
+ `--root` inside a backed-up directory.
242
+
243
+ ```sh
244
+ aut evidence --audit FIRST replay-code RUN_ID --include-audit SECOND
245
+ aut evidence --audit NEW_FIRST run-code --recipe RUN_ID --include-audit NEW_SECOND
246
+ ```
247
+
248
+ Replay checks the original scope and compares the result and read record with the
249
+ saved digest. Deleted inputs can prevent replay. Changes in AUT or Monty versions
250
+ can change the digest. Use `--recipe` to run the same program on new inputs and
251
+ optionally pass new parameters.
252
+
253
+ Install `agent-usage-tracker[mcp,code]` to use a recipe through MCP. If you use
254
+ the pinned-wheel runtime installer, pass `--code` to include both optional dependencies. Add `--code`
255
+ to the server arguments after `mcp` and include any additional scopes there.
256
+ The server adds `code_catalog` and `run_code(source, params)`. The client receives
257
+ the result under the connection's grant. Restart the MCP server to select a
258
+ changed bundle. A client connected to a hosted model can
259
+ forward that result. Session observability settings govern a separate delivery
260
+ path.
261
+
262
+ ## Send session evidence to a configured receiver
263
+
264
+ Set `AUT_SESSION_OBSERVABILITY_URL` to an HTTPS endpoint that accepts AUT evidence
265
+ bundle JSON by POST. Loopback HTTP is available for local development. Set
266
+ `AUT_SESSION_OBSERVABILITY_TOKEN` if your receiver requires bearer authentication.
267
+ AUT uses a dedicated endpoint for session evidence. The existing usage sink
268
+ continues to receive usage data.
269
+
270
+ With a destination configured, `aut evidence capture` sends the new audit with
271
+ redacted content by default. Set `AUT_SESSION_OBSERVABILITY=metadata` for event
272
+ references and coverage, `full` for available raw session text, or `off` to stop
273
+ delivery. Use `capture --no-observe` to keep a single capture local. A capture or
274
+ bundle can further restrict what is sent. Redaction masks recognized patterns.
275
+ Review the content policy and the receiver's retention before sharing private work.
276
+
277
+ A delivery failure appears in the capture's JSON as `observability.status=failed`.
278
+ The private audit remains available. Retry with
279
+ `aut evidence --audit AUDIT_ID observe`, or select a bundle to deliver a smaller
280
+ set of sessions. The request carries an `Idempotency-Key` that matches the bundle
281
+ digest. A receiver can use it to deduplicate identical deliveries.
@@ -36,6 +36,7 @@ merge = ["torch>=2.14", "peft>=0.21", "transformers>=5.17", "huggingface_hub>=1.
36
36
 
37
37
  # The evidence CLI runs without the optional MCP server.
38
38
  mcp = ["mcp>=1.30,<2"]
39
+ code = ["pydantic-monty>=1.6,<1.7"]
39
40
 
40
41
  # Run the suite: pip install -e '.[test]' && pytest -q
41
42
  test = ["pytest", "pytest-xdist==3.8.0"]
@@ -89,5 +90,5 @@ disallow_any_generics = true
89
90
  # Optional extras: the base install, and CI's lint job, have none of them.
90
91
  [[tool.mypy.overrides]]
91
92
  module = ["psycopg.*", "mlx.*", "mlx_lm.*", "huggingface_hub.*", "transformers.*", "torch.*", "peft.*",
92
- "mcp.*", "anyio.*", "uvicorn.*", "starlette.*"]
93
+ "mcp.*", "anyio.*", "uvicorn.*", "starlette.*", "pydantic_monty.*"]
93
94
  ignore_missing_imports = true
@@ -5,4 +5,4 @@ session, activity and active-time rows, and pushes them to a self-hosted sink. C
5
5
  local-model labels are separate pipelines over the same sink.
6
6
  """
7
7
 
8
- __version__ = "0.3.0"
8
+ __version__ = "0.4.0"
@@ -71,6 +71,8 @@ def default_excludes() -> list[str]:
71
71
  data_dir() / "label" / "models",
72
72
  data_dir() / "improve" / "session_content",
73
73
  root.resolve() / "session_content",
74
+ data_dir() / "improve" / "investigation_runs",
75
+ root.resolve() / "investigation_runs",
74
76
  ))))
75
77
 
76
78
 
@@ -460,7 +460,7 @@ class Evidence:
460
460
  agent, before, include_excluded, cursor, limit, self._label,
461
461
  supplemental=self.supplemental)
462
462
 
463
- def export(self, path: Path, ids: list[str]) -> dict[str, Any]:
463
+ def bundle_bytes(self, ids: list[str]) -> tuple[str, bytes]:
464
464
  if not ids or len(set(ids)) != len(ids):
465
465
  raise AutError("evidence: select distinct session IDs for export")
466
466
  sessions = {}
@@ -481,9 +481,14 @@ class Evidence:
481
481
  sessions[key] = projected
482
482
  payload = {"version": 1, "audit_id": self.audit_id, "content": self.content,
483
483
  "coverage": _coverage(self.coverage), "sessions": sessions}
484
- data = (canonical({"sha256": digest(payload), "evidence": payload}) + "\n").encode("utf-8")
484
+ identity = digest(payload)
485
+ data = (canonical({"sha256": identity, "evidence": payload}) + "\n").encode("utf-8")
485
486
  if len(data) > BUNDLE_LIMIT:
486
487
  raise AutError("evidence: select fewer sessions for the 64 MiB bundle limit")
488
+ return identity, data
489
+
490
+ def export(self, path: Path, ids: list[str]) -> dict[str, Any]:
491
+ _, data = self.bundle_bytes(ids)
487
492
  _create_bundle(path, data)
488
493
  return {"path": str(path), "sessions": len(ids), "content": self.content}
489
494
 
@@ -25,7 +25,7 @@ def register(commands: Any) -> None:
25
25
  scope = parser.add_mutually_exclusive_group()
26
26
  scope.add_argument("--audit", help="freeze access to the selected audit ID")
27
27
  scope.add_argument("--bundle", type=Path, help="open a previously exported evidence bundle")
28
- parser.add_argument("--content", choices=MODES, default="full",
28
+ parser.add_argument("--content", choices=MODES,
29
29
  help="content available through this command or MCP connection")
30
30
  actions = parser.add_subparsers(dest="evidence_cmd", required=True)
31
31
 
@@ -34,6 +34,8 @@ def register(commands: Any) -> None:
34
34
  capture.add_argument("--limit", type=int, default=20)
35
35
  capture.add_argument("--idle-s", type=int, default=120)
36
36
  capture.add_argument("--project", type=Path)
37
+ capture.add_argument("--no-observe", action="store_true", help="keep this capture local")
38
+ actions.add_parser("observe", help="send the selected audit or bundle to session observability")
37
39
  capture.add_argument("--max-mib", type=int, default=BYTE_LIMIT // _MIB,
38
40
  help="maximum MiB read per source (1..256, default: 16)")
39
41
  record = actions.add_parser("record-codex-turn", help="record Git context from a Codex prompt hook")
@@ -94,12 +96,31 @@ def register(commands: Any) -> None:
94
96
  export.add_argument("ids", nargs="+")
95
97
  mcp = actions.add_parser("mcp", help="serve the selected evidence through MCP")
96
98
  mcp.add_argument("--transport", choices=("stdio", "http"), default="stdio")
99
+ code = actions.add_parser("run-code", help="run a local evidence recipe")
100
+ code.add_argument("source", nargs="?", help="Python recipe path or - for stdin")
101
+ code.add_argument("--recipe", help="reuse the source from a saved run")
102
+ code.add_argument("--params", help="JSON object passed to the program")
103
+ code.add_argument("--save", action="store_true", help="save private recipe and replay record")
104
+ replay = actions.add_parser("replay-code", help="replay a saved investigation")
105
+ replay.add_argument("run_id")
106
+ actions.add_parser("code-catalog", help="list operations available to recipes")
107
+ mcp.add_argument("--code", action="store_true", help="enable programmable investigations")
108
+ for action in (code, replay, mcp):
109
+ action.add_argument("--include-audit", action="append", default=[])
110
+ action.add_argument("--include-bundle", action="append", type=Path, default=[])
97
111
  mcp.add_argument("--port", type=int, default=8765, help="loopback port for HTTP")
98
112
 
99
113
 
100
114
  def run(args: argparse.Namespace) -> None:
101
115
  root = args.root or Path(os.environ.get("AUT_IMPROVE_ROOT", str(data_dir() / "improve")))
102
116
  action = args.evidence_cmd
117
+ with_code = action in {"run-code", "replay-code", "code-catalog"} or (
118
+ action == "mcp" and args.code)
119
+ args.content = args.content or ("redacted" if with_code else "full")
120
+ if action == "code-catalog" or action in {"run-code", "replay-code"}:
121
+ value = _code(args, root)
122
+ print(json.dumps(value, sort_keys=True))
123
+ return
103
124
  if action == "record-codex-turn":
104
125
  if args.audit or args.bundle:
105
126
  raise AutError("evidence: the Codex turn hook uses a store, not an audit or bundle")
@@ -112,13 +133,24 @@ def run(args: argparse.Namespace) -> None:
112
133
  raise AutError("evidence: capture takes no scope and requires full or redacted content")
113
134
  if not 1 <= args.max_mib <= _MAX_CAPTURE_MIB:
114
135
  raise AutError("evidence: use a per-source capture budget of 1..256 MiB")
115
- value = audit(Store(root), Path.home(), days=args.days, limit=args.limit,
136
+ writable = Store(root)
137
+ value = audit(writable, Path.home(), days=args.days, limit=args.limit,
116
138
  idle_s=args.idle_s, project=args.project, capture_full=args.content == "full",
117
139
  max_bytes=args.max_mib * _MIB)
140
+ if not args.no_observe and os.environ.get("AUT_SESSION_OBSERVABILITY_URL"):
141
+ from .session_observability import publish
142
+ try:
143
+ value["observability"] = publish(args.content, writable, value["audit_id"], None)
144
+ except AutError as exc:
145
+ value["observability"] = {"status": "failed", "error": str(exc)}
118
146
  else:
119
147
  if not (args.audit or args.bundle):
120
148
  raise AutError("evidence: select --audit ID or --bundle PATH")
121
149
  store = Store(root, read_only=True) if args.audit else None
150
+ if action == "observe":
151
+ from .session_observability import publish
152
+ print(json.dumps(publish(args.content, store, args.audit, args.bundle), sort_keys=True))
153
+ return
122
154
  evidence = Evidence(args.content, store, args.audit, args.bundle)
123
155
  if action == "mcp":
124
156
  try:
@@ -127,7 +159,14 @@ def run(args: argparse.Namespace) -> None:
127
159
  if exc.name not in {"mcp", "anyio", "uvicorn", "starlette"}:
128
160
  raise
129
161
  raise AutError("evidence: install agent-usage-tracker[mcp] for MCP access") from exc
130
- serve(evidence, args.transport, args.port)
162
+ scopes = None
163
+ if args.code:
164
+ from .investigation import scope_specs
165
+ scopes = scope_specs(root, args.content, args.audit, args.bundle,
166
+ args.include_audit, args.include_bundle)
167
+ elif args.include_audit or args.include_bundle:
168
+ raise AutError("investigation: additional scopes require mcp --code")
169
+ serve(evidence, args.transport, args.port, scopes)
131
170
  return
132
171
  if action == "propose-skill":
133
172
  if store is None:
@@ -178,3 +217,47 @@ def run(args: argparse.Namespace) -> None:
178
217
  else:
179
218
  value = evidence.describe()
180
219
  print(json.dumps(value, sort_keys=True))
220
+
221
+
222
+ def _code(args: argparse.Namespace, root: Path) -> dict[str, Any]:
223
+ from .investigation import CONTRACT, MAX_SOURCE, catalog, run, scope_specs
224
+ from .store import digest
225
+
226
+ if args.evidence_cmd == "code-catalog":
227
+ return catalog()
228
+ if not (args.audit or args.bundle):
229
+ raise AutError("investigation: select --audit ID or --bundle PATH")
230
+ specs = scope_specs(root, args.content, args.audit, args.bundle,
231
+ args.include_audit, args.include_bundle)
232
+ if args.evidence_cmd == "replay-code":
233
+ record = Store(root, read_only=True).get("investigation_runs", args.run_id)
234
+ if record["contract"] != CONTRACT:
235
+ raise AutError("investigation: saved recipe uses an unsupported operation contract")
236
+ value = run(record["source"], record["params"], specs, record["scopes"])
237
+ return {**value, "replayed": args.run_id, "matches": digest(value) == record["result_sha256"]}
238
+ if bool(args.source) == bool(args.recipe):
239
+ raise AutError("investigation: select a source path, stdin, or --recipe ID")
240
+ try:
241
+ params = json.loads(args.params) if args.params is not None else {}
242
+ if args.recipe:
243
+ recipe = Store(root, read_only=True).get("investigation_runs", args.recipe)
244
+ if recipe["contract"] != CONTRACT:
245
+ raise AutError("investigation: saved recipe uses an unsupported operation contract")
246
+ source = recipe["source"]
247
+ if args.params is None:
248
+ params = recipe["params"]
249
+ elif args.source == "-":
250
+ source = sys.stdin.buffer.read(MAX_SOURCE + 1).decode("utf-8")
251
+ else:
252
+ with Path(args.source).open("rb") as stream:
253
+ source = stream.read(MAX_SOURCE + 1).decode("utf-8")
254
+ except (ValueError, OSError, RecursionError) as exc:
255
+ raise AutError("investigation: provide UTF-8 source and valid JSON parameters") from exc
256
+ value = run(source, params, specs)
257
+ if args.save:
258
+ record = {"contract": CONTRACT, "source": source, "params": params,
259
+ "scopes": value["scopes"], "result_sha256": digest(value),
260
+ "reads": value["reads"], "aut_version": value["aut_version"],
261
+ "runtime_version": value["runtime_version"]}
262
+ value["run_id"] = Store(root).put("investigation_runs", record)
263
+ return value
@@ -7,6 +7,7 @@ import os
7
7
  import re
8
8
  from collections.abc import Callable
9
9
  from functools import partial, wraps
10
+ from threading import BoundedSemaphore
10
11
  from typing import Any
11
12
 
12
13
  import anyio
@@ -51,7 +52,8 @@ def _tool(method: Callable[..., dict[str, Any]]) -> Callable[..., Any]:
51
52
  return call
52
53
 
53
54
 
54
- def serve(evidence: Evidence, transport: str, port: int) -> None:
55
+ def serve(evidence: Evidence, transport: str, port: int,
56
+ code_scopes: list[dict[str, Any]] | None = None) -> None:
55
57
  token = os.environ.get("AUT_EVIDENCE_TOKEN", "")
56
58
  if transport == "http" and not re.fullmatch(r"[A-Za-z0-9_-]{32,128}", token):
57
59
  raise AutError("evidence: HTTP requires a URL-safe AUT_EVIDENCE_TOKEN of 32..128 characters")
@@ -68,6 +70,30 @@ def serve(evidence: Evidence, transport: str, port: int) -> None:
68
70
  for operation in operations:
69
71
  server.add_tool(_tool(operation), annotations=ToolAnnotations(
70
72
  readOnlyHint=True, destructiveHint=False, openWorldHint=False))
73
+ if code_scopes is not None:
74
+ from .investigation import catalog, pin_scopes, require_runtime, run
75
+
76
+ require_runtime()
77
+ slots = BoundedSemaphore(2)
78
+ scopes = code_scopes
79
+ pinned = pin_scopes(scopes, evidence)
80
+
81
+ def code_catalog() -> dict[str, Any]:
82
+ """List the evidence operations and arguments accepted by run_code."""
83
+ return {**catalog(), "scopes": pinned}
84
+
85
+ def run_code(source: str, params: dict[str, Any] | None = None) -> dict[str, Any]:
86
+ """Run scoped Python using read(operation, scope='1', lead=None, **arguments)."""
87
+ if not slots.acquire(blocking=False):
88
+ raise AutError("investigation: both execution slots are busy")
89
+ try:
90
+ return run(source, params if params is not None else {}, scopes, pinned)
91
+ finally:
92
+ slots.release()
93
+
94
+ for code_tool in (code_catalog, run_code):
95
+ server.add_tool(_tool(code_tool), annotations=ToolAnnotations(
96
+ readOnlyHint=True, destructiveHint=False, openWorldHint=False))
71
97
  if transport == "stdio":
72
98
  server.run()
73
99
  else:
@@ -0,0 +1,256 @@
1
+ """Run evidence recipes against an explicitly selected set of scopes."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import inspect
6
+ import json
7
+ import os
8
+ import subprocess
9
+ import sys
10
+ from datetime import datetime, timezone
11
+ from importlib.metadata import version
12
+ from importlib.util import find_spec
13
+ from pathlib import Path
14
+ from typing import Any, Literal, get_args, get_origin, get_type_hints
15
+
16
+ from .. import __version__
17
+ from ..config import AutError
18
+ from .access import Evidence
19
+ from .store import Store, canonical, digest
20
+
21
+ CONTRACT = 1
22
+ MAX_SOURCE = 16_384
23
+ MAX_PARAMS = 8_192
24
+ MAX_SCOPES = 8
25
+ MAX_CALLS = 48
26
+ MAX_DATA = 2 * 1024 * 1024
27
+ MAX_OUTPUT = 65_536
28
+ TIMEOUT = 12
29
+ OPERATIONS = ("describe", "search", "session", "event", "compare", "commits", "case",
30
+ "ordinary_work")
31
+ WORKER = "agent_usage_tracker.improve.investigation"
32
+
33
+
34
+ def require_runtime() -> None:
35
+ if find_spec("pydantic_monty") is None:
36
+ raise AutError("investigation: install agent-usage-tracker[code] to run recipes")
37
+
38
+
39
+ def _matches(value: Any, annotation: Any) -> bool:
40
+ if get_origin(annotation) is Literal:
41
+ return any(type(value) is type(choice) and value == choice
42
+ for choice in get_args(annotation))
43
+ if options := get_args(annotation):
44
+ return any(_matches(value, option) for option in options)
45
+ return type(value) is annotation
46
+
47
+
48
+ def catalog() -> dict[str, Any]:
49
+ operations = {}
50
+ for name in OPERATIONS:
51
+ method = getattr(Evidence, name)
52
+ hints = get_type_hints(method)
53
+ fields = {}
54
+ for param in list(inspect.signature(method).parameters.values())[1:]:
55
+ field = {"type": inspect.formatannotation(hints[param.name])}
56
+ if param.default is not inspect.Parameter.empty:
57
+ field["default"] = param.default
58
+ fields[param.name] = field
59
+ operations[name] = {"description": method.__doc__, "arguments": fields}
60
+ return {"contract": CONTRACT, "operations": operations,
61
+ "interface": "read(operation, scope='1', lead=None, **arguments) returns receipt and data",
62
+ "limits": {"source_bytes": MAX_SOURCE, "parameter_bytes": MAX_PARAMS,
63
+ "calls": MAX_CALLS, "seconds": TIMEOUT, "output_bytes": MAX_OUTPUT}}
64
+
65
+
66
+ def scope_specs(root: Path, content: str, audit: str | None, bundle: Path | None,
67
+ audits: list[str], bundles: list[Path]) -> list[dict[str, Any]]:
68
+ sources = [(audit, bundle), *((key, None) for key in audits),
69
+ *((None, path) for path in bundles)]
70
+ if len(sources) > MAX_SCOPES:
71
+ raise AutError(f"investigation: select at most {MAX_SCOPES} evidence scopes")
72
+ specs = [{"audit": key, "bundle": str(path.expanduser().resolve()) if path else None,
73
+ "root": str(root.expanduser().resolve()) if key else None, "content": content}
74
+ for key, path in sources]
75
+ if len({(row["audit"], row["bundle"]) for row in specs}) != len(specs):
76
+ raise AutError("investigation: select distinct evidence scopes")
77
+ return specs
78
+
79
+
80
+ def _bounded(value: Any, limit: int, label: str) -> bytes:
81
+ try:
82
+ data = canonical(value).encode("utf-8")
83
+ except (TypeError, ValueError, RecursionError) as exc:
84
+ raise AutError(f"investigation: {label} must be finite JSON") from exc
85
+ if len(data) > limit:
86
+ raise AutError(f"investigation: {label} exceeds {limit} bytes")
87
+ return data
88
+
89
+
90
+ def run(source: str, params: dict[str, Any], specs: list[dict[str, Any]],
91
+ expected_scopes: dict[str, Any] | None = None) -> dict[str, Any]:
92
+ require_runtime()
93
+ try:
94
+ source_size = len(source.encode("utf-8"))
95
+ except UnicodeError as exc:
96
+ raise AutError("investigation: source must be UTF-8") from exc
97
+ if not source.strip() or source_size > MAX_SOURCE:
98
+ raise AutError(f"investigation: provide 1..{MAX_SOURCE} bytes of Python source")
99
+ if not isinstance(params, dict):
100
+ raise AutError("investigation: parameters must be a JSON object")
101
+ _bounded(params, MAX_PARAMS, "parameters")
102
+ payload = canonical({"source": source, "params": params, "specs": specs,
103
+ "expected_scopes": expected_scopes}).encode("utf-8")
104
+ env = {name: os.environ[name] for name in ("PATH", "SYSTEMROOT", "WINDIR", "TMP", "TEMP", "TMPDIR")
105
+ if name in os.environ}
106
+ try:
107
+ process = subprocess.run([sys.executable, "-I", "-m", WORKER], input=payload,
108
+ capture_output=True, timeout=TIMEOUT, env=env, check=False)
109
+ except subprocess.TimeoutExpired as exc:
110
+ raise AutError("investigation: execution exceeded the wall-clock limit") from exc
111
+ except OSError as exc:
112
+ raise AutError("investigation: could not start the local runtime") from exc
113
+ if process.returncode:
114
+ raise AutError("investigation: local runtime failed")
115
+ try:
116
+ response = json.loads(process.stdout)
117
+ except (ValueError, RecursionError) as exc:
118
+ raise AutError("investigation: local runtime returned an invalid response") from exc
119
+ if "error" in response:
120
+ raise AutError(response["error"])
121
+ return dict(response)
122
+
123
+
124
+ def _references(operation: str, value: dict[str, Any]) -> list[dict[str, str]]:
125
+ references: dict[tuple[str, str], None] = {}
126
+
127
+ def include(session: Any, *events: Any) -> None:
128
+ if isinstance(session, str):
129
+ for event in events:
130
+ if isinstance(event, str):
131
+ references[session, event] = None
132
+
133
+ if operation == "compare":
134
+ difference = value["first_tool_difference"] or {}
135
+ for side in ("baseline", "candidate"):
136
+ row = value[side]
137
+ tool = difference.get(side) or {}
138
+ include(row["id"], *row["error_event_ids"], tool.get("call_event_id"),
139
+ tool.get("result_event_id"))
140
+ elif operation == "event":
141
+ include(value["session_id"], value["id"])
142
+ elif operation == "case":
143
+ include(value["session_id"], *value["event_ids"])
144
+ else:
145
+ session = value.get("session", {}).get("id")
146
+ for item in value.get("items", []):
147
+ key = item.get("session_id") or item.get("session_snapshot") or session
148
+ include(key, item.get("event_id") or item.get("id"), item.get("call_event_id"),
149
+ item.get("result_event_id"))
150
+ return [{"session_id": session, "event_id": event} for session, event in references]
151
+
152
+
153
+ def _open_scope(spec: dict[str, Any]) -> Evidence:
154
+ store = Store(Path(spec["root"]), read_only=True) if spec["root"] else None
155
+ bundle = Path(spec["bundle"]) if spec["bundle"] else None
156
+ return Evidence(spec["content"], store, spec["audit"], bundle)
157
+
158
+
159
+ def _describe_scope(evidence: Evidence) -> dict[str, Any]:
160
+ return {**evidence.describe(), "bundle": digest(evidence.bundled) if evidence.bundled else None}
161
+
162
+
163
+ def pin_scopes(specs: list[dict[str, Any]], primary: Evidence) -> dict[str, Any]:
164
+ scopes = {"1": _describe_scope(primary)}
165
+ for i, spec in enumerate(specs[1:], 2):
166
+ scopes[str(i)] = _describe_scope(_open_scope(spec))
167
+ return scopes
168
+
169
+
170
+ def _execute(source: str, params: dict[str, Any], specs: list[dict[str, Any]],
171
+ expected_scopes: dict[str, Any] | None) -> dict[str, Any]:
172
+ from pydantic_monty import Monty, MontyError, MontyRuntimeError, MontySyntaxError
173
+
174
+ sources = {str(i): _open_scope(spec) for i, spec in enumerate(specs, 1)}
175
+ scopes = {alias: _describe_scope(evidence) for alias, evidence in sources.items()}
176
+ if expected_scopes is not None and scopes != expected_scopes:
177
+ raise AutError("investigation: evidence scope or content grant changed")
178
+
179
+ reads: list[dict[str, Any]] = []
180
+ printed: list[str] = []
181
+ calls = data_bytes = print_bytes = 0
182
+
183
+ def capture(stream: str, message: str) -> None:
184
+ nonlocal print_bytes
185
+ print_bytes += len(message.encode())
186
+ if print_bytes > MAX_OUTPUT:
187
+ raise AutError("investigation: printed output exceeds the output budget")
188
+ printed.append(message)
189
+
190
+ def read(operation: str, *, scope: str = "1", lead: int | None = None,
191
+ **arguments: Any) -> dict[str, Any]:
192
+ nonlocal calls, data_bytes
193
+ calls += 1
194
+ if calls > MAX_CALLS:
195
+ raise AutError("investigation: evidence call budget exhausted")
196
+ if not isinstance(operation, str) or operation not in OPERATIONS:
197
+ raise AutError("investigation: unknown evidence operation")
198
+ if not isinstance(scope, str) or scope not in sources:
199
+ raise AutError("investigation: unknown evidence scope")
200
+ if lead is not None and (type(lead) is not int or not 1 <= lead <= len(reads)):
201
+ raise AutError("investigation: lead must reference an earlier receipt")
202
+ _bounded(arguments, MAX_PARAMS, "operation arguments")
203
+ method = getattr(sources[scope], operation)
204
+ hints = get_type_hints(method)
205
+ try:
206
+ inspect.signature(method).bind(**arguments)
207
+ except TypeError as exc:
208
+ raise AutError("investigation: invalid argument names for evidence operation") from exc
209
+ if any(not _matches(value, hints[name]) for name, value in arguments.items()):
210
+ raise AutError("investigation: invalid argument types for evidence operation")
211
+ data = method(**arguments)
212
+ encoded = _bounded(data, MAX_DATA - data_bytes, "evidence data")
213
+ data_bytes += len(encoded)
214
+ receipt = len(reads) + 1
215
+ reads.append({"receipt": receipt, "lead": lead, "scope": scope, "operation": operation,
216
+ "arguments_sha256": digest(arguments), "data_sha256": digest(data),
217
+ "has_more": any(data.get(key) is not None for key in ("next_cursor", "next_offset")),
218
+ "references": _references(operation, data)})
219
+ return {"receipt": receipt, "data": data}
220
+
221
+ try:
222
+ with Monty(max_processes=1, request_timeout=TIMEOUT) as pool, pool.checkout(
223
+ limits={"max_feed_duration_secs": 3, "max_memory": 32 * 1024 * 1024,
224
+ "max_recursion_depth": 128, "max_suspensions": 256, "max_total_sleep_secs": 0},
225
+ os_policy={"datetime": datetime(2000, 1, 1, tzinfo=timezone.utc),
226
+ "random_start": {"seed": 0}},
227
+ ) as session:
228
+ result = session.feed_run(source, inputs={"params": params, "scopes": scopes},
229
+ external_lookup={"read": read}, print_callback=capture)
230
+ except MontySyntaxError as exc:
231
+ raise AutError(f"investigation: invalid Python syntax: {exc.display('type-msg')[:300]}") from exc
232
+ except MontyRuntimeError as exc:
233
+ error_type = type(exc.exception()).__name__
234
+ raise AutError(f"investigation: program stopped with {error_type}") from exc
235
+ except MontyError as exc:
236
+ raise AutError("investigation: sandbox could not complete the program") from exc
237
+ output = {"result": result, "stdout": "".join(printed)}
238
+ _bounded(output, MAX_OUTPUT, "program output")
239
+ _bounded(reads, MAX_DATA, "read receipts")
240
+ return {**output, "contract": CONTRACT, "aut_version": __version__,
241
+ "runtime_version": version("pydantic-monty"), "scopes": scopes, "reads": reads,
242
+ "calls": calls, "read_errors": calls - len(reads), "evidence_bytes": data_bytes,
243
+ "source_sha256": digest(source), "parameters_sha256": digest(params)}
244
+
245
+
246
+ def worker() -> None:
247
+ try:
248
+ request = json.load(sys.stdin.buffer)
249
+ value = _execute(**request)
250
+ except AutError as exc:
251
+ value = {"error": str(exc)}
252
+ sys.stdout.buffer.write(canonical(value).encode("utf-8") + b"\n")
253
+
254
+
255
+ if __name__ == "__main__":
256
+ worker()