Skip to content

feat(harmony): project HarmonyOS package inventory evidence - #1447

Merged
morluto merged 4 commits into
morluto:mainfrom
BaaRai:feat/harmony-package-inventory
Oct 11, 2026
Merged

morluto merged 4 commits into
morluto:mainfrom
BaaRai:feat/harmony-package-inventory

Conversation

@BaaRai

@BaaRai BaaRai commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Implements the package-identification and inventory increment of #1431. This is static, provider-free inspection; manifest semantics, Ark decoding, resource resolution, signature verification, and runtime analysis remain deferred.

Behavior

  • Recognize HAP, HSP, and App Pack roots through the hardened ZIP reader. App Pack .app classification requires ZIP magic and applies only to root inputs; nested .app ZIP members retain their existing format. HTTP Archive .har handling is unchanged.
  • Expose project_harmony_application_graph through CLI and MCP. Authenticated inventory Evidence produces deterministic component paths, IDs and hashes, packaging-model path hints, App Pack children, runtime hints, and explicitly hypothetical native bridge candidates.
  • Include Stage and FA resource layouts. Preserve encrypted or otherwise unavailable occurrence paths with null content identities in unavailable_components, and mark projection coverage partial instead of claiming absence.
  • Share ZIP-family classification across archive target identity, root occurrence roles, admitted descriptor ownership, reader routing, and non-entry-byte limitations.
  • Preserve existing Android/Apple projection semantics while sharing their projection scaffolding. Integrate current main's inventory ownership and lazy CLI imports.

Verification

Verified on macOS arm64 with Node 24.18.0 and npm 11.16.0:

  • 67 focused tests passed across Harmony, Android/Apple, ZIP integrity and archive safety, advertised schemas, MCP projection and Evidence retention.
  • npm run check:fast, npm run docs:check, and architecture guards passed.
  • The real HAP lane passed against the repository build and a freshly packed and temporarily installed REA package: compiled CLI inspection, deterministic projection, and actual SDK-connected stdio MCP parity.
  • Verifier workspace cleanup was checked after a command failure before MCP connection.

The fixture is the SHA-256-pinned harmony-next-pipeline 1.0.1 release, from an MIT-licensed source repository. Its pin records source revision, asset ID, byte size and digest; downloaded bytes are not committed or redistributed. This replaces the repeatedly rotated VHome asset. The fixture's compiler/SDK versions and reproducible source-to-artifact build have not been independently established, so the full pinned-toolchain acceptance in #1431 remains open. Bundled component licenses, Ark contents, and signature validity were not independently audited.

The guide now supplies the required inventory_evidence wrapper and documents unavailable coverage and verification boundaries. The verifier removes its workspace on success and failure and bounds downloads to the pinned size.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator

Review to help land this. I tested it locally merged with current main (f9ce32b4) on macOS arm64 with Node 26.

1. Conflict with main. src/domain/android/androidApplication.ts conflicts with main's new nativeRuntimeConvention (src/domain/nativeConvention.ts). This resolution builds and passes:

  • keep this PR's import block from ../mobileApplicationGraphProjection.js and add import { nativeRuntimeConvention } from "../nativeConvention.js";;
  • in runtimeFamilies, take main's loop (for (const { path } of all) { const convention = nativeRuntimeConvention(path); … }) and sort with compareProjectionStrings instead of the removed local compare.

Results on the merged tree:

  • typecheck and lint pass;
  • vitest run src/domain passes (112 files, 1,512 tests);
  • src/application src/contracts src/server src/cli pass (67 files, 691 tests);
  • tests/composition/{harmony,android} and the MCP toolSchemaValidity, contractPresentation and serverIdentity suites pass;
  • docs:check passes.

2. The real-HAP lane is unreproducible: the pinned fixture is gone. npm run fixtures:harmony fails with HTTP 404 for VHome-5.0.111-beta-unsigned.hap. The v5.0.111-beta release no longer exists. muleos/VHome-release was created on 2026-10-04, declares no license, and was republished today as v2.6.14-beta (VHome-2.6.14-beta-unsigned.hap, 20,729,946 bytes, SHA-256 d19c8dcd9866bbf07332544e727d5e14fb03ddf103aa2562a83eab87b8181ce8).

On that replacement, inspect-artifact followed by project-harmony-application-graph gives:

  • 239 occurrences, root_format: hap;
  • packaging_model: stage, manifests module.json and pack.info;
  • bytecode ets/modules.abc;
  • native libraries libs/arm64-v8a/{libImSDK,libc++_shared,libxuspine}.so;
  • families ark and native, 3 bridge candidates, coverage complete-within-inventory.

So the projection itself behaves as described. But the lane needs a stable fixture. #1431's acceptance asks for source-generated public fixtures packaged by a pinned toolchain; failing that, at least a licensed artifact with a durable URL. A days-old, unlicensed release repository has already rotated once.

3. .app → app-pack is applied globally on the suffix. zipPackageFormatForPath now maps every ZIP-signature path ending in .app to app-pack. That also changes generic inventory outside Harmony. Example: an IPA containing a nested ZIP file Payload/Nested.app inventories as container/app-pack here, versus container/zip on main, which changes that IPA's graph_sha256. Directory bundles such as Autoupdate.app inside Transmission.app are unaffected; I checked that the graph hash is identical. Separately, the projection accepts any ZIP root named *.app as an App Pack without checking for pack.info, and the limitations don't say the root classification is suffix-based. Suggestions:

  • require pack.info (and child .hap/.hsp entries) before claiming app-pack, or report an explicit limitation; and/or
  • scope the .app suffix rule to root inputs.

4. Unrelated commit. 82338a36 fix(browser): launch verification Chrome without the desktop keyring is your separate #1432. Dropping it here would keep this PR to the Harmony increment.

5. Minor (signing). components.signing lists only META-INF/*.{p7b,sig,…} entries. As far as I know, HAP signatures (hapsigner) sit in a signing block inside the ZIP structure rather than as entries, so a signed HAP can still produce signing: []. The general "signing semantics require a dedicated provider" limitation partly covers this. An explicit note that an empty list does not mean unsigned would stop agents reading it as absence.

If useful, I can push the conflict resolution (item 1) to your branch, since maintainer edits are enabled. Let me know.

First HarmonyOS increment from morluto#1431: HAP, HSP, and App Pack roots are
classified through the hardened ZIP reader and projected into an
execution-free application graph with packaging-model hints, exact
component paths and hashes, App Pack children by path, runtime-family
hints, and path-based N-API bridge hypotheses. HarmonyOS .har stays
unclassified by suffix because .har also names HTTP Archive JSON.

Adds the project_harmony_application_graph tool (CLI and MCP), synthetic
composition coverage, a pinned real-package verify lane, and docs.
The HarmonyOS projection mirrors the Android and Apple projections by
design, which pushed jscpd duplication over its 2.5 percent budget.
Extract the identical pieces (inventory input schema, projected
component schema and occurrence flattening, bridge candidate schema
factory, coverage assembly, comparator, canonical digest) into
domain/mobileApplicationGraphProjection.ts and route all three
projections plus the composition fixtures through it. Duplication drops
from 2.52 to 2.49 percent with no behavior change: projection ids,
classifications, and limitations are byte-identical.
- rebased onto main; the shared projection scaffolding now keeps main's
  nativeRuntimeConvention loop and the harmony runtime families adopt the
  same react-native/flutter/unity path conventions
- the .app App Pack suffix is now a root-input rule only (verified ZIP
  magic in classifyRootFormat and BinaryTargetResolver); nested .app ZIP
  members inside other packages keep the generic zip classification, with
  a regression test, so existing inventories do not change
- the signing limitation now states that an empty signing list does not
  mean unsigned because packaging-tool signatures live in the ZIP signing
  block, and the app-pack root rule is disclosed as suffix-based
- repinned the real-package fixture to the current VHome 2.6.14-beta asset
  after the upstream deleted v5.0.111-beta and replaced the v2.6.14-beta
  asset within hours; the pin records both observed digests
@BaaRai
BaaRai force-pushed the feat/harmony-package-inventory branch from 33e8163 to e5dbdeb Compare October 10, 2026 11:30
@BaaRai

BaaRai commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

Thank you for a genuinely useful review. All five items are addressed in e5dbdeb (force-pushed, rebased onto current main):

1. Conflict. Resolved exactly as you specified: shared scaffolding imports plus nativeRuntimeConvention, main's convention loop with compareProjectionStrings. I went one step further and made the Harmony runtime families adopt nativeRuntimeConvention too, so react-native/flutter/unity hints now come from the same path-convention helper instead of drifting per projection.

2. Fixture. The instability is even worse than your run showed: the v2.6.14-beta asset you pinned this morning (d19c8dcd\u2026) was itself replaced within hours; my download today hashes 06cccd1c\u2026 (20,722,910 vs your 20,729,946 bytes). I repinned to the current asset, and the pin record now documents both observed digests and the deletion of v5.0.111-beta, so the next mismatch reads as an upstream rotation rather than a mystery. Layout is unchanged (238 entries, same manifests/bytecode/libs), the lane is green against the new pin (inspect_artifact, projection, determinism, CLI/MCP parity), and docs/testing.md now states the rotation caveat. I agree this upstream is not a durable home: my preference for the follow-up is building the fixture from source with a pinned ohos-sdk command-line toolchain, which is what #1431's acceptance asks for anyway, and I am happy to do that as the next increment unless a better-licensed stable artifact turns up first.

3. .app scoping. Adopted your second suggestion: the App Pack suffix is now a root-input rule only, applied after ZIP magic verification in classifyRootFormat (main's magic-first classification made this clean) and mirrored in BinaryTargetResolver. zipPackageFormatForPath no longer maps .app, so nested ZIP members ending in .app keep the generic zip classification and existing inventories do not change. A regression test locks your exact example: an IPA containing Payload/Nested.app inventories the nested member as zip, root stays ipa. The projection also now discloses that the app-pack root classification is a verified-magic-plus-suffix rule that does not require pack.info.

4. Unrelated commit. Dropped; the branch now contains only the two Harmony commits on top of main, and #1432 carries the keyring change alone.

5. Signing. The projection limitations and docs now state explicitly that the signing component lists META-INF certificate-entry suffixes only and that an empty list does not mean unsigned, since packaging-tool signatures live in the ZIP signing block rather than archive entries.

Checks on the updated branch: typecheck, lint, jscpd (2.48%), docs:check, and the harmony/android/contracts/catalog suites all pass, and the real-package lane is green on Linux.

@CassieFox23

Copy link
Copy Markdown
Contributor

TL;DR: I tested e5dbdeb on Linux with six real open-source HarmonyOS packages. Its tests, lint and type check pass on Node 22 and Node 24, and the file lists match the ZIP contents. Two small gaps remain: HAP results lack the ZIP tail note, and FA resource folders are not counted. The branch also conflicts with current main in three files.

Results

Check Node 22.23.1 Node 24.18.0
tests/composition/harmony/ (6 tests) pass pass
Wider unit and MCP suites pass, 1,533 tests pass, 2,219 tests, 3 skipped
npm run check and docs:check not run pass
6 real packages, CLI and MCP give the same projection 2 of 6 checked, same result 6 of 6, same result
Hand-built edge cases (23 files) not run as expected, except the two gaps below
  • Real packages. All six are Stage-model .hap files. Each reads as hap, model stage, with module.json and pack.info. In every case, the counts match the file list that Python's zipfile gives me. The counts are for the manifests, the bytecode files, the resources and the libraries. Main reads all six as plain zip.
  • Gap 1: the ZIP tail note is gone. On main, a ZIP inspection says that bytes after the central directory are not occurrences. HAP, HSP and App Pack inspections no longer say it, because inventoryLimitations in src/artifacts/inventory/reader.ts lists only zip, ipa, apk, msix and appx. The projection itself says signatures live in the ZIP signing block. That block sits after the central directory.
  • Gap 2: Feature Ability (FA) resources. The OpenHarmony docs put FA resources under assets/entry/resources/. In my FA package, only assets/entry/resources.index counted as a resource. The two files under assets/entry/resources/ did not.
  • Fine as built. A .har HTTP archive is not opened at all, and a ZIP named .har stays zip. A plain-text .hap, a zero-byte .hap, a truncated .hap, a duplicate entry and five bad paths all fail closed, as on main. An IPA holding a nested ZIP named Payload/Nested.app has the same graph hash as main.

Not run

  • The branch merged with main d21132f. It conflicts in src/artifacts/inventory/classify.ts, src/artifacts/inventory/reader.ts and src/domain/android/androidApplication.ts. I tested the head only.
  • npm run fixtures:harmony and verify:harmony. The pinned package declares no licence, so I did not download it.
  • A real .hsp, .app or FA package. I found no licensed one, so those are hand-built.
  • Signature checks and Ark bytecode parsing. Any device or emulator. Node 26 and macOS. The whole vitest run suite.
  • Whether the one package with "signed" in its file name has a signature. It shows an empty signing list, as the limitations say it can.

Thanks, kaoru0822-kitauji, for the review that you did on the Mac. On Linux, your item 3 (the IPA graph hash) and item 5 (the signing note) hold up.

The packages and their licences

I downloaded each one from its public release page. The licence of each repository is linked beside the name. It covers the source. I did not audit what each file bundles.

  • The LinysBrowser_NEXT repo is under the MIT licence, as I read it in the file. The release I used is v2.1.0-beta.
  • The ohos-scrcpy-app repo is under the MIT licence, as I read it in the file. The release I used is 1.0.3.
  • The harmony-next-pipeline repo is under the MIT licence, as I read it in the file. The release I used is v1.0.1.
  • The ha-companion-harmonyos repo is under the Apache-2.0 licence, as I read it in the file. The release I used is v1.4.2.
  • The Tailscale-OHOS repo is under the BSD-3-Clause licence, as I read it in the file. The release I used is v0.3.19-release.
  • The transharmony repo is under the Apache-2.0 licence, as I read it in the file. The release I used is v1.0.9.

SHA-256 of each file, in the same order:

af7496934c2afdebca80da78c7603048352a55491ccf5966daa97d2cf0021001  home-default-unsigned.hap
a65a99f1222f8fc13c8d7ad33d01390a00ffd227a438840231f3860c69edd0c7  OHScrcpyServer.hap
928a4c6718125328695d2c32297ef5dfba2e06d16fd501d507d4aa32423cbad6  entry-default-unsigned.hap
9140a91eaa7bab8e6ea161261609cd6fcb76e3740aecfe0433cebca45e863b8d  20260916-release-1.4.2.hap
c8c5c51817708f587e5be1a7ddb54b15b9dd396026e7a78e5ee77f4c85f96c73  Tailscale-OHOS-0.3.19-release-signed.hap
510fe7074d614b634dfebec44f46a11e6b2e6a56be9c4990bb7b3ecb3e6d57ac  TransHarmony-v1.0.9-unsigned.hap
What the projection found in each package

Every package: coverage complete-within-inventory, no JavaScript, and an empty signing list (none has a META-INF entry).

  • In LinysBrowser_NEXT, the tool found 1 bytecode file and 7 resources. It also found 0 native libraries and 0 bridge candidates.
  • In ohos-scrcpy-app, the tool found 1 bytecode file and 8 resources. It also found 2 native libraries and 2 bridge candidates.
  • In harmony-next-pipeline, the tool found 1 bytecode file and 8 resources. It also found 0 native libraries and 0 bridge candidates.
  • In ha-companion-harmonyos, the tool found 2 bytecode files and a total of 76 resources. It also found 2 native libraries and 4 bridge candidates.
  • In Tailscale-OHOS, the tool found 1 bytecode file and 9 resources. It also found 3 native libraries and 3 bridge candidates.
  • In transharmony, the tool found 1 bytecode file and 12 resources. It also found 6 native libraries and 6 bridge candidates.

Two smaller notes. The tool pairs every bytecode file with every native library. So libc++_shared.so, the C++ runtime, shows up as a bridge candidate in four of the six packages. The PR calls these hypotheses. Also, a fake .abc under resources/rawfile/ counted as bytecode, as a resource and as a bridge source.

How it compares with the OpenHarmony docs

The docs are openharmony/docs at f41b9345, under en/application-dev/quick-start/.

  • Docs: HAP, HSP and App Pack are the shipped forms, and a HAR is a build-time library copied into them (application-package-overview.md). The PR names hap, hsp and app-pack and leaves .har alone. Match.
  • Docs: a Stage build turns ets into .abc and writes module.json (application-package-structure-stage.md). Match on all six real packages.
  • Docs: an App Pack holds .hap and .hsp files next to pack.info (same page). The PR lists children by suffix anywhere in the pack, so nested/dir/feature.hap counted. It lists pack.info but does not read it.
  • Docs: FA uses config.json, assets/entry/resources and assets/js (application-package-structure-fa.md). The PR finds config.json and assets/js but misses assets/entry/resources/ (gap 2).
  • Docs: entry and feature HAPs, shared and static library types, and the integrated HSP (application-package-overview.md). Not covered, since the PR does not read module.json. The PR says so.

Nothing in #1447 claims anything about what is inside a .abc file. It lists path, hash and size. It also says a suffix does not prove valid Ark bytecode.

Hand-built edge cases, 23 files

The fixtures and the build script are in my notes. Layouts follow the docs pages above.

  • Stage .hap, FA .hap, .hsp, UPPER.HAP, and a .hap with both module.json and config.json: head says hap or hsp, with models stage, fa, stage, stage, stage. Main says zip.
  • App Pack with two children and one nested child: head says app-pack and lists three children. Main says zip.
  • A .app ZIP with no pack.info, and an empty ZIP named .app: head says app-pack, and its limitations say so. Main says zip.
  • An empty ZIP named .hap, and a .hap holding one text file: head says hap with no components and complete coverage. Main says zip.
  • HTTP archive JSON named .har: not opened, on head and on main.
  • A ZIP named .har, and a Stage layout in a ZIP named .zip: zip on both, and the projection refuses both.
  • Plain text, zero bytes, a truncated file and a duplicate entry: not opened, on head and on main.
  • Bad paths ../../evil.abc, /abs/x.abc, a/../../b.js, C:\win\x.abc and a/../b.abc: all rejected on head. On main only the first was run, and it was rejected.
  • An IPA with a nested ZIP named Payload/Nested.app: ipa on both, with the same graph hash.
Test setup
  • Box: Nobara 44 (Fedora 44 base), Linux 7.2.9
  • CPU: AMD Ryzen 9 5900X, 12 cores / 24 threads
  • RAM: 32 GB DDR4-3600
  • Node: 22.23.1, 24.18.0
  • Head / base: e5dbdeb / b9c4398 (test(clients): verify native Gemini CLI integration #1541). Main at test time: d21132f.
  • Other: clang 22.1.8, for the small test libraries
  • Wider suites differ by Node version. Node 22 ran src/domain, harmony and three MCP files (116 files). Node 24 ran 182 files from src/domain, application, contracts, server, cli, harmony and android, plus 13 MCP tests.
  • npm run check needed a stand-in for git ls-files, because I unpacked the head as an archive with no repository. The stand-in lists files with find. I have not confirmed that it matches the tracked file list.

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

Unify ZIP package ownership, archive identity, and inventory limitations. Preserve unavailable encrypted component paths and partial coverage; include FA resource directories. Repair the documented CLI input and verifier cleanup, and replace the rotating VHome fixture with a hash-pinned Harmony pipeline release.
@morluto
morluto merged commit f2150eb into morluto:main Oct 11, 2026
23 of 24 checks passed
@morluto

morluto commented Oct 11, 2026

Copy link
Copy Markdown
Owner

Thank you @BaaRai for the HarmonyOS package inventory PR! Reusing the hardened archive reader and shared CLI/MCP Evidence workflows gives this first increment a useful foundation. I appreciate the component inventory, explicit limits on what the path-based hints establish, and the verification work. I’ve reviewed it and pushed the remaining fixes and merge-conflict resolution. Thanks for contributing this to REA!

@github-actions github-actions Bot mentioned this pull request Oct 11, 2026
3 tasks done
@morluto morluto added enhancement New feature or request area: evidence Evidence, artifacts, and reconstruction labels Oct 14, 2026
@morluto morluto added the area: build Build, CI, packaging, and publishing label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: build Build, CI, packaging, and publishing area: evidence Evidence, artifacts, and reconstruction enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants