[PR #4167] [CLOSED] fix(adb): parse the bare numeric wm density form #6107

Closed
opened 2026-10-31 01:11:55 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/4167
Author: @DeryFerd
Created: 10/15/2026
Status: ❌ Closed

Base: main ← Head: fix/adb-density-bare-number


📝 Commits (1)

  • a38667c fix(adb): parse the bare numeric wm density form

📊 Changes

2 files changed (+29 additions, -2 deletions)

View changed files

📝 src/adb/AdbShellOutput.test.ts (+23 -1)
📝 src/adb/AdbShellOutput.ts (+6 -1)

📄 Description

fix(adb): parse the bare numeric wm density form

Summary

Fixes #3942.

inspect-adb-display reports physical_density: null for devices and builds whose wm density prints the physical density as a bare number with no label, which is the older format the parser's own documentation already recognizes. The command still exits 0 and returns a successful result, so the loss is silent: the caller sees a missing density rather than a failed read. This change reads the bare numeric line and keeps it as the physical density.

Problem and expected behavior

The smallest trigger is a device whose wm density output is exactly 420 followed by a newline. parseWmDensityOutput only matched Physical density: <n> and Override density: <n>, so a bare number matched neither branch and the loop returned { physical: null, override: null }. The CLI projection then showed physical_density: null and override_density: null alongside the correctly parsed physical_size, with exit code 0, ok: true, and empty stderr. The labeled controls (Physical density: 420 and Physical density: 420\nOverride density: 480) returned the expected values, which shows the failure is specific to the unlabeled form and not to density parsing in general.

The violated invariant is that a successful display inspection reports the size and density the device declared, and the parser's documentation already states that older builds print a bare number. Reporting null for a value the device did supply turns an observation into an absence, and because the result is still a success the caller has no signal that anything was dropped.

Expected behavior after the change: 420 yields { physical: 420, override: null }, the labeled single-line form yields { physical: 420, override: null }, the two-line labeled form yields { physical: 420, override: 480 }, and an unlabeled line that is not a plain integer, such as Physical size: 1080x2340, still yields { physical: null, override: null } rather than a fabricated density.

Change and scope

A third pattern, ^(\d+)$, is matched against each trimmed line and its value is held in a separate bare slot. The return keeps the labeled physical density when present and falls back to the bare value otherwise: { physical: physical ?? bare, override }. The labeled form stays authoritative, so a device that prints both cannot have the bare reading override the explicit declaration.

The fallback is applied only to the physical density and never to the override. A bare number carries no label, so the only reading the format supports is the physical density; assigning it to the override would be a guess. The bare pattern requires the entire trimmed line to be digits, so 1080x2340, Physical size: …, or any other non-integer line is left alone. This is the same shape the parser already uses for wm size, where an unrecognized line contributes nothing.

Not included: no change to parseWmSizeOutput, no change to the CLI projection or the result schema, no new field, and no heuristic for guessing an override from an unlabeled value.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/adb/AdbShellOutput.ts owns the device-output parsers; the earliest changed stage is the parse of wm density output.
  • Contribution scope fit and linked maintainer decision: an ordinary fix inside an existing boundary, so not applicable.
  • CLI and MCP/tool-catalog contract: no signature or schema change. inspect-adb-display reports a non-null physical_density where the device declared one.
  • Provider, bridge, target-format, or platform compatibility: the labeled format keeps its existing result, so newer builds are unaffected; older bare-number builds gain the density they always printed.
  • Evidence, artifact, provenance, or reconstruction contract: a declared density is now preserved instead of being reported as absent, which keeps omission and observation distinct.
  • Target selection, authority, upstream behavior, and cleanup details: none, this stage reads command output and issues no device action beyond the observation the command already runs.
  • Generated metadata, package, or installation impact: none.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: src/adb/AdbShellOutput.test.ts gains a parseWmDensityOutput block covering the labeled physical and override declarations, the bare numeric declaration read as the physical density, and an unlabeled non-numeric line that is not treated as a density.

  • Base reproduction or other evidence: the issue records the base CLI returning physical_density: null with exit 0 for the bare declaration and 420 for the labeled controls. The new bare-number test fails on the base and passes on this branch, and the labeled-form test passes on both, which pins the regression to the missing format branch.

  • User-visible CLI/MCP output: the issue shows the base display projection with physical_density: null while physical_size is populated, and the labeled controls with 420 and 480. After the change the bare declaration returns 420 in the same field.
    For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.

  • Artifact identity, source provenance, and failed attempts remain preserved.

  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

  • Remaining proof gaps: this session exercised the parser through its unit tests rather than through the CLI. The issue's reproduction used a simulated provider, so it establishes the format-specific loss for that provider and not its frequency on real devices. No real adb binary or physical device was available here, so the end-to-end CLI path and real-device format coverage remain unverified.

Validation performed

  • npm run test:focused -- src/adb/AdbShellOutput.test.ts — all tests passed, including the bare-number case that fails on the base revision.
  • npm run check:fast — typecheck and lint succeeded.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Only previously null results for the bare format change, and they change to the value the device declared.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable. No real adb binary or device was available, so this change is not claimed as verified against a physical device.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: the change reads one additional line of already-captured command output and issues no new command or device action.

Author readiness

Human owner: @DeryFerd

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/4167 **Author:** [@DeryFerd](https://github.com/DeryFerd) **Created:** 10/15/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/adb-density-bare-number` --- ### 📝 Commits (1) - [`a38667c`](https://github.com/morluto/rea/commit/a38667cb87b0a72b74ad80d1e0d08d4b92d2b2fd) fix(adb): parse the bare numeric wm density form ### 📊 Changes **2 files changed** (+29 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/adb/AdbShellOutput.test.ts` (+23 -1) 📝 `src/adb/AdbShellOutput.ts` (+6 -1) </details> ### 📄 Description fix(adb): parse the bare numeric wm density form ## Summary Fixes #3942. `inspect-adb-display` reports `physical_density: null` for devices and builds whose `wm density` prints the physical density as a bare number with no label, which is the older format the parser's own documentation already recognizes. The command still exits 0 and returns a successful result, so the loss is silent: the caller sees a missing density rather than a failed read. This change reads the bare numeric line and keeps it as the physical density. ## Problem and expected behavior The smallest trigger is a device whose `wm density` output is exactly `420` followed by a newline. `parseWmDensityOutput` only matched `Physical density: <n>` and `Override density: <n>`, so a bare number matched neither branch and the loop returned `{ physical: null, override: null }`. The CLI projection then showed `physical_density: null` and `override_density: null` alongside the correctly parsed `physical_size`, with exit code 0, `ok: true`, and empty stderr. The labeled controls (`Physical density: 420` and `Physical density: 420\nOverride density: 480`) returned the expected values, which shows the failure is specific to the unlabeled form and not to density parsing in general. The violated invariant is that a successful display inspection reports the size and density the device declared, and the parser's documentation already states that older builds print a bare number. Reporting `null` for a value the device did supply turns an observation into an absence, and because the result is still a success the caller has no signal that anything was dropped. Expected behavior after the change: `420` yields `{ physical: 420, override: null }`, the labeled single-line form yields `{ physical: 420, override: null }`, the two-line labeled form yields `{ physical: 420, override: 480 }`, and an unlabeled line that is not a plain integer, such as `Physical size: 1080x2340`, still yields `{ physical: null, override: null }` rather than a fabricated density. ## Change and scope A third pattern, `^(\d+)$`, is matched against each trimmed line and its value is held in a separate `bare` slot. The return keeps the labeled physical density when present and falls back to the bare value otherwise: `{ physical: physical ?? bare, override }`. The labeled form stays authoritative, so a device that prints both cannot have the bare reading override the explicit declaration. The fallback is applied only to the physical density and never to the override. A bare number carries no label, so the only reading the format supports is the physical density; assigning it to the override would be a guess. The bare pattern requires the entire trimmed line to be digits, so `1080x2340`, `Physical size: …`, or any other non-integer line is left alone. This is the same shape the parser already uses for `wm size`, where an unrecognized line contributes nothing. Not included: no change to `parseWmSizeOutput`, no change to the CLI projection or the result schema, no new field, and no heuristic for guessing an override from an unlabeled value. ## Contract and boundary impact - Semantic owner and earliest changed stage: `src/adb/AdbShellOutput.ts` owns the device-output parsers; the earliest changed stage is the parse of `wm density` output. - Contribution scope fit and linked maintainer decision: an ordinary fix inside an existing boundary, so not applicable. - CLI and MCP/tool-catalog contract: no signature or schema change. `inspect-adb-display` reports a non-null `physical_density` where the device declared one. - Provider, bridge, target-format, or platform compatibility: the labeled format keeps its existing result, so newer builds are unaffected; older bare-number builds gain the density they always printed. - Evidence, artifact, provenance, or reconstruction contract: a declared density is now preserved instead of being reported as absent, which keeps omission and observation distinct. - Target selection, authority, upstream behavior, and cleanup details: none, this stage reads command output and issues no device action beyond the observation the command already runs. - Generated metadata, package, or installation impact: none. Expected effects (check known effects; use documentation-only on its own). Unchecked items do not establish absence; leave uncertainties visible. - [x] Read existing files or captured data. - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [ ] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [ ] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - Tests added or updated: `src/adb/AdbShellOutput.test.ts` gains a `parseWmDensityOutput` block covering the labeled physical and override declarations, the bare numeric declaration read as the physical density, and an unlabeled non-numeric line that is not treated as a density. - Base reproduction or other evidence: the issue records the base CLI returning `physical_density: null` with exit 0 for the bare declaration and 420 for the labeled controls. The new bare-number test fails on the base and passes on this branch, and the labeled-form test passes on both, which pins the regression to the missing format branch. - User-visible CLI/MCP output: the issue shows the base display projection with `physical_density: null` while `physical_size` is populated, and the labeled controls with 420 and 480. After the change the bare declaration returns 420 in the same field. For evidence-bearing changes: - [ ] Observed, derived, and inferred claims remain distinguishable. - [ ] Artifact identity, source provenance, and failed attempts remain preserved. - [ ] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. - Remaining proof gaps: this session exercised the parser through its unit tests rather than through the CLI. The issue's reproduction used a simulated provider, so it establishes the format-specific loss for that provider and not its frequency on real devices. No real adb binary or physical device was available here, so the end-to-end CLI path and real-device format coverage remain unverified. ## Validation performed - `npm run test:focused -- src/adb/AdbShellOutput.test.ts` — all tests passed, including the bare-number case that fails on the base revision. - `npm run check:fast` — typecheck and lint succeeded. ## Compatibility, safety, and release - Breaking changes or migration steps: none. Only previously null results for the bare format change, and they change to the value the device declared. - Real Hopper/Ghidra, browser, or OS coverage: not applicable. No real adb binary or device was available, so this change is not claimed as verified against a physical device. - Package or release metadata impact: none. - Security, privacy, process, or containment review: the change reads one additional line of already-captured command output and issues no new command or device action. ## Author readiness Human owner: @DeryFerd - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge - [ ] This PR addresses a concrete problem or an agreed enhancement. - [ ] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [ ] The PR has one focused outcome and the title follows `type(scope): outcome`. - [ ] Related issue is linked, or the reason for not linking one is stated above. - [ ] Tests cover changed observable behavior and meaningful failure paths. - [ ] Owning docs, contracts, and generated metadata are updated where needed. - [ ] User-visible CLI/MCP changes include representative output. - [ ] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:11:55 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#6107
No description provided.