holosphere 1.1.12 → 1.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/federation.js CHANGED
@@ -892,19 +892,36 @@ export async function propagate(holosphere, holon, lens, data, options = {}) {
892
892
  if (propagateToParents) {
893
893
  console.log(`[Federation] Starting parent propagation for holon: ${holon}`);
894
894
  try {
895
- // Check if the holon is a valid H3 hexagon
895
+ // Validate if the holon is a proper H3 hexagon
896
+ // H3 hexagons should start with '8' and have a valid format
896
897
  let holonResolution;
897
- try {
898
- holonResolution = h3.getResolution(holon);
899
- console.log(`[Federation] Holon ${holon} is valid H3 hexagon with resolution: ${holonResolution}`);
900
- } catch (error) {
901
- // Not a valid H3 hexagon, skip parent propagation
902
- console.log(`[Federation] Holon ${holon} is not a valid H3 hexagon: ${error.message}`);
898
+ let isValidH3 = false;
899
+
900
+ // First check: H3 hexagons should start with '8' and be at least 15 characters long
901
+ if (typeof holon === 'string' && holon.startsWith('8') && holon.length >= 15) {
902
+ try {
903
+ holonResolution = h3.getResolution(holon);
904
+ // Additional validation: resolution should be >= 0 and <= 15
905
+ if (holonResolution >= 0 && holonResolution <= 15) {
906
+ isValidH3 = true;
907
+ console.log(`[Federation] Holon ${holon} is valid H3 hexagon with resolution: ${holonResolution}`);
908
+ } else {
909
+ console.log(`[Federation] Holon ${holon} has invalid resolution: ${holonResolution}`);
910
+ }
911
+ } catch (error) {
912
+ console.log(`[Federation] Holon ${holon} failed H3 validation: ${error.message}`);
913
+ }
914
+ } else {
915
+ console.log(`[Federation] Holon ${holon} is not a valid H3 hexagon: does not start with '8' or too short`);
916
+ }
917
+
918
+ if (!isValidH3) {
919
+ console.log(`[Federation] Skipping parent propagation for non-H3 holon: ${holon}`);
903
920
  result.parentPropagation.messages.push(`Holon ${holon} is not a valid H3 hexagon. Skipping parent propagation.`);
904
921
  result.parentPropagation.skipped++;
905
922
  }
906
923
 
907
- if (holonResolution !== undefined) {
924
+ if (isValidH3 && holonResolution !== undefined) {
908
925
  // Get all parent hexagons up to the specified max levels
909
926
  const parentHexagons = [];
910
927
  let currentHolon = holon;