Skip to content

bug(perf, P1): detect Android/Termux CPU capacity without silent normalization defaults #297

Description

@jinon86

Summary

The performance harness records cpu_cores: 0 on Android/Termux when os.cpus() returns an empty array. computeEfficiency() then silently treats zero as four cores through hwProfile.cpu_cores || 4, creating metadata/scoring disagreement and invalid hardware normalization.

The 12-node diagnostic exhibition observed this on both Android participants (gongyung and daegyo). Their reports were retained only as diagnostics and excluded from ranking.

Current behavior

cpu_cores: os.cpus().length
cpu_model: os.cpus().length > 0 ? os.cpus()[0].model : 'unknown'

Later:

const cpuCores = hwProfile.cpu_cores || 4;

This makes the report say 0 while scoring as if the node had 4 cores. The fallback is neither observable nor defensible.

Expected behavior

  • Hardware metadata and scoring use the same positive core count and record how it was derived.
  • Termux/Android has a bounded, safe fallback chain.
  • If no trustworthy positive value is available, the report is explicitly non-comparable; it does not invent four cores.

Implementation direction

Use an ordered capability probe with no network or privileged reads, for example:

  1. os.availableParallelism() when available and positive.
  2. os.cpus().length when positive.
  3. A bounded platform fallback such as _NPROCESSORS_ONLN, /sys/devices/system/cpu/online, or a safe /proc/cpuinfo count.
  4. If all fail, set hardware-profile completeness false and block normalized scoring.

Record a safe enum such as cpu_core_source and retain cpu_model: unknown when unavailable. Do not record hostnames, device identifiers, serials, IPs, or raw /proc contents.

Acceptance criteria

  • cpu_cores is a positive integer for supported Linux and Android/Termux fixtures.
  • The selected probe source is recorded with a bounded, schema-defined value.
  • computeEfficiency() never silently substitutes four cores for zero/missing metadata.
  • Unknown core count marks the report/iteration non-comparable and suppresses normalized efficiency scoring.
  • Hardware metadata and normalization use the same resolved count.
  • CPU model may remain unknown without invalidating a report when core count is trustworthy.
  • No sensitive device identifiers or raw system-file contents enter reports.

Required tests

  • Normal Linux os.cpus() path.
  • Empty os.cpus() with successful availableParallelism().
  • Termux-style fallback with a CPU-online range such as 0-7.
  • Total probe failure, proving fail-closed comparability.
  • Schema/packet bridge regression for the new source/completeness fields.

Verification

npm test
node scripts/perf-harness.js --iterations 3 --json --validate
node scripts/harness-to-packet.js results/ --agent-id termux-hardware-check

At least one real Termux canary should be run only after the source-only fixture suite is green and operator approval is obtained.

Safety boundary

Read-only local hardware probes. No device identifiers, ADB mutation, package installation, provider calls, service restarts, or public scoring.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingjavascriptPull requests that update javascript code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions