Skip to content

refactor(metrics): Complete coherent energy sampling - #114

Merged
bigtomcat6 merged 4 commits into
mainfrom
feat/energy-impact-coherent-sampling-integration
Aug 9, 2026
Merged

refactor(metrics): Complete coherent energy sampling#114
bigtomcat6 merged 4 commits into
mainfrom
feat/energy-impact-coherent-sampling-integration

Conversation

@bigtomcat6

Copy link
Copy Markdown
Owner

Summary

  • Replace split Energy Impact sampling/publication state with one coherent three-second sampler observation.
  • Move process reads, ownership, baselines, publication statistics, smoothing, ranking, and sorting behind an actor-owned lease.
  • Reconcile the safety and coverage regressions from PR refactor(metrics): Isolate visible sampling sessions #113 under the coherent lease architecture.
  • Add an inert-by-default, repeatable five-process native cost gate.
  • Supersede the unmerged local Part 4 implementation at feat/energy-impact-coherent-sampling; that retained branch remains unchanged as historical evidence and is not the PR head.
  • Integrated series:
    • 85ff0092af25544791d47c42743140f5a3f2e934 refactor(energy): extract publication state
    • a31bd63d0b68886cd14872a233bc9c84a4962999 refactor(energy): add coherent sampler sessions
    • 88041b5fb0dd488e42b32ac816564dde4d47a0bd refactor(energy): control visible observation lifecycle
    • abf4ecb884005fae2b28f4fca2e25f442bcbbb63 test(energy): add repeatable native gate

How to test

  • swift test --filter EnergyImpact
    • Exact result: 126 total / 125 passed / 1 expected native-default skip / 0 failed / 0 unexpected failures.
  • swift test
    • Exact result: 1,170 total / 1,169 passed / 1 expected native-default skip / 0 failed / 0 unexpected failures.
  • xcodegen generate --quiet
    • PASS: regenerated MacActivity.xcodeproj/project.pbxproj was unchanged.
  • xcodebuild test -project MacActivity.xcodeproj -scheme MacActivity -destination 'platform=macOS' CODE_SIGNING_ALLOWED=NO
    • ** TEST SUCCEEDED **; xcresult: 1,170 total / 1,169 passed / 1 skipped / 0 failed / 0 expected failures.
  • Static superseded-API and MainActor-boundary scans from the Part 4 integration gate returned zero matches: no Energy topApps call, no superseded cadence/session/cache symbols, and no App/provider ownership of low-level process or smoothing/ranking state.
  • Five-process native gate, authoritative attempt 3 (each run had 21 observations and passed the p95, CPU, and wall-duration thresholds):
Run Observations Pre-run apps Snapshot processes p50 ms p95 ms CPU % Wall s
1 21 7 398 13.427 15.319 0.438875 60.092
2 21 7 397 13.128 15.377 0.452884 60.099
3 21 7 397 13.811 15.028 0.456702 60.043
4 21 7 397 12.498 15.778 0.413864 60.056
5 21 7 400 13.572 15.199 0.449276 60.116
  • Aggregate result: median CPU 0.449276%; maximum CPU 0.456702%; maximum p95 15.778 ms; minimum wall duration 60.043 s; valid native runs 5/5; ENERGY_NATIVE_GATE PASS.
  • Attempts 1 and 2 are preserved only as non-authoritative failed/incomplete execution-environment attempts and were not used for this PASS.
  • Manual visible lifecycle limitation: the SHA-bound Debug app built and launched, but Computer Use returned timeoutReached for the app name and exact app path; the bundle ID was ambiguous across builds. No accessibility tree or screenshot was returned, so no visible scenario is claimed as passed:
    1. Immediate honest collecting/status rows without false zero: UNVERIFIED — the menu-bar UI was not observable.
    2. Next valid value opportunity after approximately three seconds: UNVERIFIED — no UI state or timestamped row transition was observable.
    3. Rapid Energy → another tab → Energy suppresses an old row from the prior run: UNVERIFIED — the required tab interactions were unavailable.
    4. Return after at least six seconds hidden without queued/burst publication: UNVERIFIED — the visibility transition was unavailable; internal read stoppage is also manually unverified, with deterministic lifecycle tests providing internal-contract evidence.
    5. Sixty-second visible observation with no burst catch-up: UNVERIFIED — no visible observation could be started.

Release impact

  • Type: Internal
  • Release note: None

Checklist

  • I have seen this code, I have run this code, and I take responsibility for this code.
  • PR title follows type(scope): Summary.
  • Tests or a clear manual verification path are included.
  • User-facing changes include release-note wording or Release impact: None.

@bigtomcat6

Copy link
Copy Markdown
Owner Author

@codex review

@codecov

codecov Bot commented Aug 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.66504% with 30 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...yCore/Metrics/Providers/EnergyImpactProvider.swift 41.86% 25 Missing ⚠️
...rces/MacActivityApp/Models/EnergyImpactModel.swift 94.23% 3 Missing ⚠️
...tyCore/Metrics/Providers/EnergyImpactSampler.swift 98.71% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: abf4ecb884

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/run-energy-impact-native-gate.command

@bigtomcat6 bigtomcat6 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewed

@bigtomcat6
bigtomcat6 marked this pull request as ready for review August 9, 2026 22:45
@bigtomcat6
bigtomcat6 merged commit 70c08fc into main Aug 9, 2026
13 of 14 checks passed
@bigtomcat6
bigtomcat6 deleted the feat/energy-impact-coherent-sampling-integration branch August 14, 2026 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant