# Platform facts and profiler policy

HPX reads built-in hardware, SDK and HAL facts from
[helia-platforms](https://github.com/AmbiqAI/helia-platforms).
The catalog describes a target; HPX decides whether and how to profile it.
Installing a catalog entry does not enable an additional HPX board or qualify
its firmware, transport, timing or energy measurements.

## Ownership

| Input | Owner | HPX implementation |
|---|---|---|
| Core, ISA, PMU presence, clock operating points, memory regions, fitted PSRAM, SDK symbols, boot origin and known probe device | helia-platforms | `platform/catalog.py` projects catalog facts into `SocDef` and `BoardDef` |
| Accepted board spellings, stable/preview channel, exposed clock labels and default, firmware performance tier, GPIO measurement wiring, transport support and PMU storage limits | HPX | `platform/policy.py` |
| Generated default SDK linker windows, source verification and fit rules | HPX | `platform/linker/`; `platform/memory_map.py` retains the classification view |
| Explicit per-run catalog file and custom board/SoC declarations | Caller, resolved by HPX | `platform/overlay.py`, `platform/custom.py` and `platform/registry.py` |

The adapter loads the packaged builtin catalog with plugins disabled. An explicit
`target.platform_overlay` adds a local file to a per-run catalog; there is no
environment search. See [catalog overlays](https://ambiqai.github.io/helia-profiler/guide/boards/#reuse-a-catalog-overlay)
for supported policy lineage and source-binding behavior. `BoardDef.psram_kb` stores only a board-specific difference
from the SoC default, such as the Cygnus add-on. An explicit custom-SoC
capacity therefore remains effective on boards that inherit that default;
an explicit custom-board capacity takes precedence, and `null` restores the
SoC default. Each `ProfileConfig` gets its own frozen registry mappings;
only the immutable built-in projections are cached. Explicit custom declarations
continue to override those views and are labelled `hpx-custom`, rather than
claimed as catalog targets.

`apollo3p_evb_cygnus` selects the catalog's `apollo3p_evb` plus the `cygnus`
add-on. `apollo5b_evb` remains an HPX SDK-descriptor compatibility route:
the catalog deliberately excludes it because there is no sourced physical
product identity. Its provenance says `sdk-descriptor`, with no catalog target.
See the [catalog owner decision](https://github.com/AmbiqAI/helia-platforms/issues/64#issuecomment-6064752168).

Some profiler routes still have explicit compatibility policy. The catalog
has no J-Link device for Apollo330P, Apollo510 Lite or Atomiq110 FPGA, so
HPX retains its existing probe aliases; they are not necessarily the current
SDK part spelling. Existing SWO probe clock controls
and the Blue board's radio-reset BSP wiring are also retained separately.
`TargetSelection.compatibility` names these exceptions; they are not catalog
hardware facts or new hardware qualification. RSS shutdown additionally requires
both a declared radio subsystem and a known supporting SDK header route;
physical radio topology alone cannot enable a HAL call. Legacy custom children
recheck that support after applying SDK part/header overrides. An unsupported
intermediate route does not erase inherited shutdown eligibility: a later
descendant can select a supported route again.

`MemoryLayout` records physical capacities for HPX's selected logical banks,
including fitted board PSRAM. It does not subtract linker reservations. The
catalog records zero fitted PSRAM on the plain Apollo3 Plus and Apollo330P
EVBs; Cygnus has 8 MiB. Apollo3's RTT scan covers its contiguous 64 KiB TCM
and 704 KiB SRAM from `0x10000000`.

## Linker layout and admission

HPX generates default GNU and armlink layouts from the pinned SDK's scripts
and headers. Generation uses the shared catalog extractor as a maintainer tool;
normal installation and profiling use packaged data, with no runtime parser or
source checkout. A layout records classification apertures, script application
extents, fixed stack reservations, and the source paths and hashes that supplied
them. `linked_memory_map()` remains a characterization view; calling it does not
verify a build.

Planning starts with declared capacities. Before each profile or dedicated-power
link, HPX refreshes CMake configuration under its workspace lock, reads that
executable's selected script, and checks current SDK module revisions and source
content. Each executable has its own decision, including incremental power
rebuilds. Matching the profile executable does not qualify the power executable.

For verified sources, HPX intersects script extents with the catalog's application
ranges in the selected core's address space. Known empty space refuses an
allocation; unknown space makes no catalog-backed fit claim. Separated intervals
cannot be summed into a contiguous arena. Admission uses the largest contiguous
interval as a conservative scalar budget. Fixed stack reservations outside the
script's application extent are charged once; floating stacks remain app usage.
This models requested occupancy, not complete allocator or linker success.

PSRAM uses the selected core’s catalog aperture, bounded by the declared fitted
capacity and intersected with application intervals. This includes Cygnus’s
8 MiB add-on. PSRAM is runtime-allocated, so this admission does not establish
ELF section attribution or measured free space. A missing address and a known
empty application range produce distinct placement errors; neither means the
board physically lacks its declared PSRAM.

Explicit SDK/script overrides and uncharacterized profiles can still build for
development, but report unavailable linker fit/accounting instead of borrowing
default windows. Strict compiled fixture/run receipts require verified source
provenance and refuse unsupported publication. ELF placement checks use the
verified intervals. Measured free-space accounting is unavailable when its
single-extent representation cannot describe the effective allowed intervals.

## Retained platform input

`PlatformSnapshot` records the requested board, effective HPX board/SoC views,
catalog package/schema version and digest, source identities, resolved target,
core, boot configuration, implementation and add-ons. It also records the
selected linker family/profile, expected source-bound layout, characterized
application windows and boot load address. These are build inputs, not measured
ELF extents. Actual per-executable verification is recorded separately in
metadata and compiled receipts. Uncharacterized profiles record no windows. Unknown
facts stay absent; an application boot origin is never inferred from a linker
window for a catalog-backed target.

Ordinary profiling writes the snapshot as `platform_provenance` in metadata,
summary and manifest provenance. A frozen run includes it as `platform`, and
the plan's `hpx.intent/2` hash binds it. The compiled build and standalone
fixture receipt retain the same snapshot. Portable run observations expose it
in their producer extension under mapping `hpx-run-4`.

Loading a current-format receipt validates its retained facts and files without
resolving a replacement platform. The ordinary reader parses every supplied
platform snapshot, requires the copies to agree, and checks their board name
against the retained target/build identity. Replaying a plan or capturing a standalone
fixture checks the current catalog and HPX settings before device access. If
they differ, use the matching producer environment or freeze and build again.
This catches accidental environment drift; it is not an authentication scheme.
The Cygnus PSRAM admission correction changes its retained layout: an earlier
plan still reads offline, but replay requires freezing and building again.
The same applies to native-derived custom plans whose SDK overrides previously
retained an unsupported RSS shutdown flag.

The builtin-derived custom-SoC inheritance correction also changes selected
custom targets based on `apollo330P`, `apollo510L`, `apollo3p`, `atomiq110`,
`apollo4l`, `apollo4p`, `apollo510` or `apollo510b`, including descendants and
builtin-name shadows. Refreeze and rebuild these plans. The correction retains
the base's USB, trace, SRAM-power, radio and known cache inputs instead of
replacing them with custom defaults. Even a cache-provenance-only change alters
the intent when the effective cache behavior was already the same. Retained
plans and receipts remain readable without rewriting their facts. Unmodified
builtin targets, board-only custom definitions, unused custom declarations,
standalone definitions and SDK-descriptor-derived defaults are unchanged.
Existing native-derived inheritance is unchanged. There are no new config keys
or payload/schema versions.

The catalog digest does not establish physical equivalence between producers.
`hpx.target-config/1` still hashes the same retained target/clock/placement
facts. Configured CPU frequency remains distinct from firmware-reported or
measured frequency; catalog adoption supplies no new measurement evidence.

## Saved-format changes

| Contract | Current version |
|---|---|
| `hpx.frozen-run` | 4 |
| `hpx.compiled-build` (run API) | 5 |
| Standalone fixture receipt `fixture_api` | `[9, 0]` (outer envelope remains 1) |
| `hpx.run-result` | 3 |
| `hpx.run-metadata` | 3 |
| `hpx.run-summary` | 22 |

Create a complete plan with `Session.freeze()`. A manually constructed
`FrozenRun` must include its recorded `platform` before `to_dict()` or `save()`;
HPX refuses publication when it is missing, without resolving replacement facts.

These strict readers refuse earlier versions. Read historical evidence with
the HPX release that wrote it; do not edit version fields or substitute current
catalog facts into an old receipt. Existing Python calls and CLI commands keep
their spellings. See [Output files](https://ambiqai.github.io/helia-profiler/guide/output/) for artifact fields.
