Skip to content

feat(api): expose the cache figure the System Info page shows - #3433

Open
vpetersson-bot wants to merge 1 commit into
masterfrom
agent/anthias-claude/f11a514d7fa6
Open

vpetersson-bot wants to merge 1 commit into
masterfrom
agent/anthias-claude/f11a514d7fa6

Conversation

@vpetersson-bot

Copy link
Copy Markdown
Contributor

What is wrong today

/api/v2/info returns memory.buff, which is the kernel's raw Buffers
line on its own. The System Info page shows a row labelled Buffers /
cache
, which is a different and much larger quantity: buffers + page cache

  • shared, derived in page_context.system_info() as total - used - free.

No field in the API response carried that second quantity, so a client had
nothing to reconcile the two with. Reading buff as "the cache figure" is
the obvious move and it is wrong by a wide margin.

Measured on an x86 test device at the same moment:

Source Field Value (MiB)
System Info page "Buffers / cache" 3,129
/api/v2/info memory.buff 878

What this changes

  • Adds memory_cache_mib() to anthias_common.utils, the single definition
    of the reclaimable slice.
  • page_context.system_info() now calls it instead of computing the figure
    inline, so the page is unchanged but no longer owns the formula.
  • get_memory() in api/views/v2.py gains memory.cache from the same
    helper, and the OpenAPI schema documents both fields and the difference
    between them.

This is additive. buff keeps its exact meaning and value, no existing field
changes shape, and clients that ignore the new key are unaffected — so it
stays within the "never break the REST API" rule rather than needing a new
version.

How I know it is right

  • memory_cache_mib on the live values from the device above yields 3,129,
    matching the page exactly.
  • test_info_v2_endpoint's mock now uses used=3 GiB / free=4 GiB of an
    8 GiB total so cache is a non-zero 1,024 MiB, with buffers set to a
    deliberately different 64 MiB — wiring cache to buffers by mistake
    would fail the assertion rather than pass silently.
  • Two unit tests cover the helper directly: the buffers-vs-cache distinction,
    and the clamp that stops a kernel reporting odd values producing a negative
    pie wedge.
  • Full non-integration suite passes (2,590). ruff check, ruff format --check and mypy are clean on the touched files.

One pre-existing failure, TestWaitForWaylandSocket:: test_probe_reports_not_ready_for_a_non_socket_path, shows up only under
pytest -n auto and reproduces identically on an unmodified tree, so it is
unrelated to this change.

Reported at https://forums.screenly.io/t/api-memory-discrepancy/6721

Closes #3432

🤖 Generated with Claude Code

/api/v2/info carried memory.buff, the kernel's raw "Buffers" line
alone. The System Info page's "Buffers / cache" row is a different,
much larger quantity: buffers + page cache + shared, derived as
total - used - free. No field in the API response let a client
reconstruct it, so the two surfaces disagreed with no way to
reconcile them. On an x86 test device the page read 3,129 MiB while
the API's buff read 878 at the same moment.

Add memory.cache alongside memory.buff, and derive both the page row
and the new field from one memory_cache_mib() helper so they cannot
drift apart again. Additive only: buff keeps its meaning and every
existing field is untouched, so current clients are unaffected.

Refs: https://forums.screenly.io/t/api-memory-discrepancy/6721
Closes #3432

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: multica-agent <github@multica.ai>
Copilot AI lite review requested due to automatic review settings October 29, 2026 08:18
@vpetersson-bot
vpetersson-bot requested a review from a team as a code owner October 29, 2026 08:18

Copilot AI 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.

Copilot encountered an error: Your billing is not configured or you have Copilot licenses from multiple standalone organizations or enterprises. To use premium requests, select a billing entity via the GitHub site, under Settings > Copilot > Features.

@vpetersson-bot
vpetersson-bot requested a lite review from Copilot October 29, 2026 08:18

Copilot AI 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.

Copilot encountered an error: Your billing is not configured or you have Copilot licenses from multiple standalone organizations or enterprises. To use premium requests, select a billing entity via the GitHub site, under Settings > Copilot > Features.

@sonarqubecloud

Copy link
Copy Markdown

@vpetersson-bot

Copy link
Copy Markdown
Contributor Author

Note on the red run-python-linter check: it is not from this branch. ruff format --check trips on the Python snippet in website/content/agents.md, which is already red on master and is what PR 3427 fixes. The five files this PR touches are clean under ruff check, ruff format --check and mypy. Once 3427 lands this should go green on a re-run.

This branch has not been deployed

No deployments
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.

/api/v2/info has no field matching the System Info page's "Buffers / cache"

2 participants