Skip to content

Agree a shared cross-platform JSON schema as the CLI contract #16

Description

@aclinick

Summary

If Juice gains a command line front end on more than one platform, the thing that should be shared is the output schema, not the implementation.
A script or an AI tool asking "what is drawing power right now" should not care whether it is talking to macOS or Windows.

Why this needs deciding up front

The two platforms genuinely measure different things, and pretending otherwise would produce a dishonest schema.

macOS meters CPU, GPU and Neural Engine energy per coalition from powerlog.
Windows meters physical rails through an ACPI Energy Meter Interface device, which exposes CPU cluster, GPU, supply and sometimes NPU rails, and on machines without that device it can only read battery discharge and therefore cannot report draw on AC at all.

So the schema needs to express "this field is genuinely unavailable here" rather than defaulting to zero.
That is the same principle already applied in the UI, where recording gaps render as gaps and are never interpolated.

Suggested rules

  • Include a platform field so consumers can branch when they must.
  • Make component fields nullable and omit them when unmeasured, rather than emitting 0.
    A zero watt reading and an unknown watt reading are different facts and must not be conflated.
  • Carry the provenance of a reading, so a consumer can tell a hardware measurement from an estimate.
    The Windows port uses a tier for this (HardwareRail, Battery, Modelled, None); macOS has an equivalent distinction between powerlog and IOKit.
  • Keep energy in watt-hours everywhere, since both platforms already normalise to that internally.
  • Version the schema, so tooling can fail loudly rather than silently misread a future change.

Non-goal

This is not a proposal to unify the two codebases.
It is only a proposal to agree the JSON contract once, so that anything built on top of --json keeps working across platforms.

Related: #14.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions