Restore BloodKetones quantity identifier and harden generator against symbol-graph omissions#354
Open
robertherber with Copilot wants to merge 7 commits into
Open
Restore BloodKetones quantity identifier and harden generator against symbol-graph omissions#354robertherber with Copilot wants to merge 7 commits into
robertherber with Copilot wants to merge 7 commits into
Conversation
🦋 Changeset detectedLatest commit: 1a88178 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Copilot
AI
changed the title
[WIP] Fix regression of HKQuantityTypeIdentifierBloodKetones in enum
Restore BloodKetones quantity identifier and harden generator against symbol-graph omissions
Jun 3, 2026
commit: |
The backfill loop for symbol-graph-omitted identifiers relies on parseQuantityIdentifierComments to populate commentMap. The old regex required a trailing // comment, so any declaration in HKTypeIdentifiers.h that lacks one (e.g. HKQuantityTypeIdentifierBloodKetones in Xcode 26.2) would silently be skipped, leaving the identifier absent from the schema. Making the comment group optional ((?:\/\/\s*(.*))?$) ensures all HK_EXTERN HKQuantityTypeIdentifier const ... ; declarations are captured regardless of whether they carry an inline comment. https://claude.ai/code/session_01McYUQGPrExiii4ETfdp4y3
…26.2 SDK HKQuantityTypeIdentifierBloodKetones is absent from both the symbol graph and HKTypeIdentifiers.h in the Xcode 26.2 SDK, so neither the symbol graph pass nor the header backfill can recover it. Adds a forcedInclusions field to identifier-overrides.json (and its corresponding type in IdentifierOverrides) that lists identifiers with full metadata (ios, canonicalUnit, aggregationStyle, writeable, legacy). A final pass in parseQuantityIdentifiers inserts any forced entry that neither the symbol graph nor the header provided. HKQuantityTypeIdentifierBloodKetones is seeded with the known metadata (iOS 8.0, mmol/L, Discrete (Arithmetic)) so it will always appear in generated artifacts regardless of SDK version. https://claude.ai/code/session_01McYUQGPrExiii4ETfdp4y3
…nerated files The generator sorts quantity identifiers alphabetically, so BloodGlucose (G) must precede BloodKetones (K). The PR had manually placed BloodKetones first, causing git diff --exit-code to fail after regeneration. Reorder in all four affected locations: - healthkit-schema.json entry order - QuantityTypeIdentifierWriteable union - QUANTITY_IDENTIFIER_IOS_AVAILABILITY object - QUANTITY_IDENTIFIER_CANONICAL_UNITS object - QuantityUnitByIdentifierMap interface https://claude.ai/code/session_01McYUQGPrExiii4ETfdp4y3
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a v14 regression where HKQuantityTypeIdentifierBloodKetones was missing from generated HealthKit quantity identifier artifacts, causing enum conversion failures, and hardens the generation pipeline to preserve SDK/header-defined identifiers even when symbol graphs omit constants.
Changes:
- Hardened
generate-healthkitto backfill missing quantity identifiers fromHKTypeIdentifiers.hparsing (including iOS availability + legacy/deprecation signal) and to support explicit forced inclusions. - Restored
HKQuantityTypeIdentifierBloodKetonesacross generated artifacts, including canonical unit mapping (mmol/L) and iOS availability (8.0), and mapped its unit typing viaBloodGlucoseUnit. - Added type-level regression coverage ensuring Blood Ketones is present in
QuantityTypeIdentifierand its sampleunittype narrows as expected.
Reviewed changes
Copilot reviewed 6 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/react-native-healthkit/src/types/Units.ts | Extends BloodGlucoseUnit to include 'mmol/L' for restored/generated canonical unit typing. |
| packages/react-native-healthkit/src/type-tests/generated-typing.ts | Adds type-level regression checks for Blood Ketones identifier presence and unit narrowing. |
| packages/react-native-healthkit/src/generated/healthkit.generated.ts | Reintroduces HKQuantityTypeIdentifierBloodKetones into generated identifier unions, availability map, canonical unit map, and unit-by-identifier typing. |
| packages/react-native-healthkit/src/generated/healthkit-schema.json | Restores Blood Ketones entry in the generated schema with iOS availability and canonical unit. |
| packages/react-native-healthkit/scripts/verify-healthkit-sdk.ts | Adds an SDK-backed regression assertion that Blood Ketones is present in parsed quantity identifiers. |
| packages/react-native-healthkit/scripts/healthkit-schema/identifier-overrides.json | Adds a forcedInclusions entry to ensure Blood Ketones can be included even if omitted by both symbol graph and header parsing. |
| packages/react-native-healthkit/scripts/generate-healthkit.ts | Hardens identifier parsing/generation by backfilling from header parsing and adding forced inclusion support; updates canonical unit typing logic for 'mmol/L'. |
| .changeset/thirty-peas-pull.md | Adds a patch changeset for the regression fix. |
Comment on lines
+48
to
+54
| const bloodKetones = schema.quantityIdentifiers.find( | ||
| (identifier) => identifier.name === 'HKQuantityTypeIdentifierBloodKetones', | ||
| ) | ||
| assert.ok( | ||
| bloodKetones, | ||
| 'Pinned SDK should expose HKQuantityTypeIdentifierBloodKetones', | ||
| ) |
| "@kingstinct/react-native-healthkit": patch | ||
| --- | ||
|
|
||
| [WIP] Fix regression of HKQuantityTypeIdentifierBloodKetones in enum |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
v14 regressed
HKQuantityTypeIdentifierBloodKetones: it was absent from generated quantity identifier artifacts, causing synchronous bridge enum conversion failures before Promise construction. This PR restores the identifier and adds a generation guard so header-defined quantity identifiers are preserved even when symbol graph extraction omits them.Generation pipeline hardening
scripts/generate-healthkit.tsnow backfills quantity identifiers fromHKTypeIdentifiers.hcomment parsing when they are missing from symbol graph constants.Restored generated identifier artifacts
HKQuantityTypeIdentifierBloodKetonesin:src/generated/healthkit.generated.tssrc/generated/healthkit-schema.jsonmmol/L) and availability (iOS 8.0) in generated outputs.Typing alignment
BloodGlucoseUnitto include'mmol/L'and mapped Blood Ketones unit typing through that shared unit type.QuantityTypeIdentifierand has the expected unit typing.Regression guard
scripts/verify-healthkit-sdk.tsnow assertsHKQuantityTypeIdentifierBloodKetonesexists in parsed SDK-backed quantity identifiers.