@warpgogol/werkstatt-shared 0.2.0
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/package.json +352 -0
- package/src/checks/index.ts +24 -0
- package/src/checks/lib/astro-site-url.ts +30 -0
- package/src/checks/lib/i18n.ts +30 -0
- package/src/checks/result-helpers.ts +102 -0
- package/src/checks/suppressions-config.ts +195 -0
- package/src/index.ts +14 -0
- package/src/integration/README.md +38 -0
- package/src/integration/adapters.ts +143 -0
- package/src/integration/crm-buffer.ts +491 -0
- package/src/integration/dispatch.ts +106 -0
- package/src/integration/funnel.ts +379 -0
- package/src/integration/index.ts +56 -0
- package/src/integration/lifecycle.ts +155 -0
- package/src/integration/orchestration.ts +439 -0
- package/src/integration/port-barrel.ts +124 -0
- package/src/integration/port.ts +143 -0
- package/src/integration/qstash.ts +134 -0
- package/src/integration/sharding.ts +133 -0
- package/src/integration/tests/deliver-event.test.ts +52 -0
- package/src/integration/tests/dispatch.test.ts +88 -0
- package/src/integration/tests/funnel-bridge.test.ts +46 -0
- package/src/integration/tests/hub-runtime.test.ts +128 -0
- package/src/integration/tests/lifecycle.test.ts +69 -0
- package/src/integration/tests/qstash.test.ts +83 -0
- package/src/integration/tests/sharding.test.ts +64 -0
- package/src/integration/vitest.config.ts +8 -0
- package/src/integration-adapter-supabase-crm/adapter.ts +437 -0
- package/src/integration-adapter-supabase-crm/client.ts +605 -0
- package/src/integration-adapter-supabase-crm/index.ts +28 -0
- package/src/integration-adapter-supabase-crm/pipedrive-sync-target.ts +482 -0
- package/src/integration-adapter-supabase-crm/supabase-rest.ts +89 -0
- package/src/integration-adapter-supabase-crm/tenant-registry.ts +334 -0
- package/src/integration-adapter-supabase-crm/tests/change-balance.pbt.test.ts +83 -0
- package/src/integration-adapter-supabase-crm/tests/funnel-persistence.test.ts +409 -0
- package/src/integration-adapter-supabase-crm/tests/lifecycle-sync.test.ts +288 -0
- package/src/integration-adapter-supabase-crm/tests/stage-map.test.ts +80 -0
- package/src/integration-adapter-supabase-crm/vitest.config.ts +8 -0
- package/src/integration-adapter-supabase-crm/worker.ts +223 -0
- package/src/observability/conventions.ts +93 -0
- package/src/observability/env-resolver.ts +57 -0
- package/src/observability/index.ts +57 -0
- package/src/observability/metric-registry.ts +184 -0
- package/src/observability/otlp-converter.ts +125 -0
- package/src/observability/otlp-json.ts +135 -0
- package/src/observability/otlp-transport.ts +68 -0
- package/src/observability/pusher.ts +142 -0
- package/src/observability/redact.ts +27 -0
- package/src/observability/tests/conventions.test.ts +100 -0
- package/src/observability/tests/metric-registry.test.ts +117 -0
- package/src/observability/tests/otlp-converter.pbt.test.ts +77 -0
- package/src/observability/tests/otlp-converter.test.ts +157 -0
- package/src/observability/tests/otlp-json.test.ts +120 -0
- package/src/observability/tests/pusher.test.ts +75 -0
- package/src/observability/tests/redact.pbt.test.ts +71 -0
- package/src/observability/tests/redact.test.ts +37 -0
- package/src/observability/typed-refs.ts +137 -0
- package/src/observability/vitest.config.ts +8 -0
- package/src/ontology/analytics/matomo-binding.yaml +172 -0
- package/src/ontology/analytics/matomo-fleet.registry.yaml +26 -0
- package/src/ontology/analytics/messkanon.yaml +151 -0
- package/src/ontology/archetype-registry.ts +61 -0
- package/src/ontology/archetypes/components/brand-label.yaml +19 -0
- package/src/ontology/archetypes/components/copyright.yaml +19 -0
- package/src/ontology/archetypes/components/currency-aware-price-display.yaml +19 -0
- package/src/ontology/archetypes/components/currency-selector.yaml +19 -0
- package/src/ontology/archetypes/components/footer-promo.yaml +19 -0
- package/src/ontology/archetypes/components/lang-switcher.yaml +19 -0
- package/src/ontology/archetypes/components/layout.yaml +19 -0
- package/src/ontology/archetypes/components/live-photo.yaml +20 -0
- package/src/ontology/archetypes/components/material-credit.yaml +20 -0
- package/src/ontology/archetypes/components/media.yaml +21 -0
- package/src/ontology/archetypes/components/nachweis-card.yaml +34 -0
- package/src/ontology/archetypes/components/nachweis-detail.yaml +43 -0
- package/src/ontology/archetypes/components/nachweis-list.yaml +37 -0
- package/src/ontology/archetypes/components/nachweis-verify.yaml +31 -0
- package/src/ontology/archetypes/components/not-found.yaml +22 -0
- package/src/ontology/archetypes/components/offer-capacity.yaml +21 -0
- package/src/ontology/archetypes/components/passport-header.yaml +19 -0
- package/src/ontology/archetypes/components/passport-provenance.yaml +20 -0
- package/src/ontology/archetypes/components/passport-score-grid.yaml +20 -0
- package/src/ontology/archetypes/components/passport-star-map.yaml +20 -0
- package/src/ontology/archetypes/components/person-profile.yaml +20 -0
- package/src/ontology/archetypes/components/pulsar.yaml +20 -0
- package/src/ontology/archetypes/components/responsive-image.yaml +19 -0
- package/src/ontology/archetypes/components/scroll-to-top.yaml +22 -0
- package/src/ontology/archetypes/components/social-meta.yaml +20 -0
- package/src/ontology/archetypes/components/structured-data.yaml +19 -0
- package/src/ontology/archetypes/index.json +1003 -0
- package/src/ontology/archetypes/index.yaml +821 -0
- package/src/ontology/archetypes/sections/approach.yaml +23 -0
- package/src/ontology/archetypes/sections/article-list.yaml +30 -0
- package/src/ontology/archetypes/sections/audience-cards.yaml +30 -0
- package/src/ontology/archetypes/sections/breadcrumbs.yaml +21 -0
- package/src/ontology/archetypes/sections/chat-widget.yaml +37 -0
- package/src/ontology/archetypes/sections/comparison-cards.yaml +31 -0
- package/src/ontology/archetypes/sections/controlled-responsibility-block.yaml +34 -0
- package/src/ontology/archetypes/sections/credits.yaml +29 -0
- package/src/ontology/archetypes/sections/donation-card.yaml +53 -0
- package/src/ontology/archetypes/sections/donation-use.yaml +23 -0
- package/src/ontology/archetypes/sections/dynamic-status-block.yaml +35 -0
- package/src/ontology/archetypes/sections/faq-list.yaml +26 -0
- package/src/ontology/archetypes/sections/final-cta.yaml +53 -0
- package/src/ontology/archetypes/sections/hero-decision-card.yaml +65 -0
- package/src/ontology/archetypes/sections/hero.yaml +50 -0
- package/src/ontology/archetypes/sections/impact.yaml +23 -0
- package/src/ontology/archetypes/sections/markdown.yaml +43 -0
- package/src/ontology/archetypes/sections/mountain-journey.yaml +43 -0
- package/src/ontology/archetypes/sections/navigation.yaml +20 -0
- package/src/ontology/archetypes/sections/notausgang-block.yaml +41 -0
- package/src/ontology/archetypes/sections/open-source-registry.yaml +26 -0
- package/src/ontology/archetypes/sections/ownership-block.yaml +57 -0
- package/src/ontology/archetypes/sections/people.yaml +48 -0
- package/src/ontology/archetypes/sections/price-card.yaml +50 -0
- package/src/ontology/archetypes/sections/problem.yaml +23 -0
- package/src/ontology/archetypes/sections/send-message.yaml +63 -0
- package/src/ontology/archetypes/sections/service-metadata-block.yaml +40 -0
- package/src/ontology/archetypes/sections/social-proof.yaml +27 -0
- package/src/ontology/archetypes/sections/transparency.yaml +32 -0
- package/src/ontology/archetypes/sections/trust-strip.yaml +42 -0
- package/src/ontology/archetypes/sections/video-section.yaml +27 -0
- package/src/ontology/archetypes/sections/women.yaml +29 -0
- package/src/ontology/biome-token-projection.ts +229 -0
- package/src/ontology/biomes/check-concrete-blueprint.yaml +118 -0
- package/src/ontology/biomes/handwerk-material-warm.yaml +135 -0
- package/src/ontology/biomes/nonprofit-trust.yaml +123 -0
- package/src/ontology/blueprints/offer.yaml +39 -0
- package/src/ontology/blueprints/prompts/local-market-signal.md +13 -0
- package/src/ontology/blueprints/prompts/website-local-narrative.md +24 -0
- package/src/ontology/blueprints/ratgeber.yaml +62 -0
- package/src/ontology/blueprints/website-local.yaml +309 -0
- package/src/ontology/blueprints/website-service.yaml +84 -0
- package/src/ontology/capabilities/lead.submit.yaml +44 -0
- package/src/ontology/cosmic/index.ts +48 -0
- package/src/ontology/cosmic/moon-catalog.ts +173 -0
- package/src/ontology/cosmic/planet-catalog.ts +82 -0
- package/src/ontology/cosmic/star-catalog.ts +337 -0
- package/src/ontology/enums.ts +159 -0
- package/src/ontology/external-surfaces/index.ts +158 -0
- package/src/ontology/external-surfaces/jsonld-types.yaml +135 -0
- package/src/ontology/external-surfaces/sitemap-shape.yaml +6 -0
- package/src/ontology/external-surfaces/url-schema.yaml +95 -0
- package/src/ontology/growth/events/contact-email-click.yaml +21 -0
- package/src/ontology/growth/events/contact-form-submit.yaml +25 -0
- package/src/ontology/growth/events/contact-phone-click.yaml +21 -0
- package/src/ontology/growth/events/contact-route-click.yaml +21 -0
- package/src/ontology/growth/events/contact-submit.yaml +28 -0
- package/src/ontology/growth/events/contact-whatsapp-click.yaml +21 -0
- package/src/ontology/growth/events/cta-click.yaml +30 -0
- package/src/ontology/growth/events/donation-confirmed.yaml +32 -0
- package/src/ontology/growth/events/donation-form-start.yaml +21 -0
- package/src/ontology/growth/events/donation-form-submit.yaml +29 -0
- package/src/ontology/growth/events/donation-intent.yaml +29 -0
- package/src/ontology/growth/events/form-error.yaml +27 -0
- package/src/ontology/growth/events/form-start.yaml +21 -0
- package/src/ontology/growth/events/form-submit.yaml +21 -0
- package/src/ontology/growth/events/outbound-click.yaml +25 -0
- package/src/ontology/growth/events/page-view.yaml +24 -0
- package/src/ontology/growth/events/passport-view.yaml +28 -0
- package/src/ontology/growth/events/star-map-navigate.yaml +30 -0
- package/src/ontology/index.ts +165 -0
- package/src/ontology/manifest.ts +344 -0
- package/src/ontology/operations/index.ts +1 -0
- package/src/ontology/schemas/biome.ts +303 -0
- package/src/ontology/schemas/capability.ts +104 -0
- package/src/ontology/schemas/constellation.ts +114 -0
- package/src/ontology/schemas/dns-records.ts +53 -0
- package/src/ontology/schemas/index.ts +95 -0
- package/src/ontology/schemas/manifest-resolver.ts +123 -0
- package/src/ontology/schemas/page-entry.ts +213 -0
- package/src/ontology/schemas/section-archetype.ts +109 -0
- package/src/ontology/schemas/site-family.ts +98 -0
- package/src/ontology/schemas/system/growth.ts +80 -0
- package/src/ontology/schemas/system/integrations.ts +143 -0
- package/src/ontology/schemas/system/manifest.ts +492 -0
- package/src/ontology/schemas/system/page-output.ts +99 -0
- package/src/ontology/schemas/system/release.ts +58 -0
- package/src/ontology/schemas/system/text.ts +58 -0
- package/src/ontology/schemas/system.ts +53 -0
- package/src/ontology/shared-section-props/body-fragments.ts +182 -0
- package/src/ontology/shared-section-props/catalog.ts +195 -0
- package/src/ontology/shared-section-props/common.ts +178 -0
- package/src/ontology/shared-section-props/index.ts +34 -0
- package/src/ontology/shared-section-props/visual-header.ts +163 -0
- package/src/ontology/site-families/charity-donation-trust/cultural-rules.yaml +6 -0
- package/src/ontology/site-families/charity-donation-trust/family.yaml +44 -0
- package/src/ontology/site-families/charity-donation-trust/linguistic-rules.yaml +6 -0
- package/src/ontology/site-families/check-quality-operator/cultural-rules.yaml +6 -0
- package/src/ontology/site-families/check-quality-operator/family.yaml +40 -0
- package/src/ontology/site-families/check-quality-operator/linguistic-rules.yaml +6 -0
- package/src/ontology/site-families/handwerk-trust-engineering/cultural-rules.yaml +6 -0
- package/src/ontology/site-families/handwerk-trust-engineering/family.yaml +53 -0
- package/src/ontology/site-families/handwerk-trust-engineering/linguistic-rules.yaml +6 -0
- package/src/ontology/tests/catalogs.pbt.test.ts +89 -0
- package/src/ontology/tests/enums.test.ts +203 -0
- package/src/ontology/tests/sternsystem-owner.test.ts +63 -0
- package/src/ontology/vitest.config.ts +8 -0
- package/src/passport/dht-sign.test.ts +99 -0
- package/src/passport/dht-sign.ts +73 -0
- package/src/passport/identity-sign.test.ts +134 -0
- package/src/passport/identity-sign.ts +85 -0
- package/src/passport/index.ts +53 -0
- package/src/passport/key-rotate.ts +133 -0
- package/src/passport/schema.ts +198 -0
- package/src/passport/sign.ts +225 -0
- package/src/passport/tests/schema.pbt.test.ts +93 -0
- package/src/passport/tests/schema.test.ts +222 -0
- package/src/passport/vitest.config.ts +8 -0
- package/src/share/agent/api-catalog.ts +77 -0
- package/src/share/agent/capability.ts +68 -0
- package/src/share/agent/dns-aid.test.ts +74 -0
- package/src/share/agent/dns-aid.ts +53 -0
- package/src/share/agent/fleet-catalog.ts +149 -0
- package/src/share/agent/index.ts +29 -0
- package/src/share/agent/knowledge.ts +96 -0
- package/src/share/agent/manifest.ts +126 -0
- package/src/share/agent/mcp-card.ts +63 -0
- package/src/share/agent/omit-empty.ts +77 -0
- package/src/share/agent/openapi.ts +157 -0
- package/src/share/agent/proof.ts +61 -0
- package/src/share/attribution-display.ts +86 -0
- package/src/share/check-hints.ts +38 -0
- package/src/share/content/entity-id.ts +65 -0
- package/src/share/content/index.ts +16 -0
- package/src/share/content/merge.ts +86 -0
- package/src/share/content/resolve-field-path.ts +39 -0
- package/src/share/content/substitute-deep.ts +47 -0
- package/src/share/content-discipline/index.ts +14 -0
- package/src/share/content-discipline/parsers.ts +66 -0
- package/src/share/content-discipline/types.ts +118 -0
- package/src/share/content-reference.ts +333 -0
- package/src/share/counter-utils.ts +75 -0
- package/src/share/css-value-normalize.ts +48 -0
- package/src/share/dev-props-validator.ts +131 -0
- package/src/share/entitlement.ts +172 -0
- package/src/share/env.d.ts +73 -0
- package/src/share/feature-policy.ts +367 -0
- package/src/share/formula-eval.ts +364 -0
- package/src/share/fs/index.ts +96 -0
- package/src/share/i18n/localization.ts +57 -0
- package/src/share/image-provider.ts +314 -0
- package/src/share/index.ts +86 -0
- package/src/share/knowledge/claim.ts +129 -0
- package/src/share/knowledge/derivation.ts +55 -0
- package/src/share/knowledge/freshness.ts +127 -0
- package/src/share/knowledge/index.ts +23 -0
- package/src/share/knowledge/ledger.ts +222 -0
- package/src/share/knowledge/plan.ts +122 -0
- package/src/share/knowledge/source.ts +170 -0
- package/src/share/legal/translation-policy.ts +133 -0
- package/src/share/material-credits.ts +181 -0
- package/src/share/middleware/language-redirect.ts +49 -0
- package/src/share/offer-capacity.ts +149 -0
- package/src/share/onboarding-yaml/index.ts +162 -0
- package/src/share/page.ts +351 -0
- package/src/share/redirects.test.ts +62 -0
- package/src/share/redirects.ts +54 -0
- package/src/share/rfc0042-utils.ts +95 -0
- package/src/share/runtime-context.ts +70 -0
- package/src/share/schemas/claim-records.ts +69 -0
- package/src/share/schemas/claims.ts +150 -0
- package/src/share/schemas/effects.ts +212 -0
- package/src/share/schemas/features.ts +147 -0
- package/src/share/schemas/horizontal-align.ts +22 -0
- package/src/share/schemas/icon-color.ts +27 -0
- package/src/share/schemas/index.ts +43 -0
- package/src/share/schemas/live-photo.ts +53 -0
- package/src/share/schemas/material-credit.ts +292 -0
- package/src/share/schemas/media.ts +220 -0
- package/src/share/schemas/navigation.ts +74 -0
- package/src/share/schemas/page-base.ts +33 -0
- package/src/share/schemas/participant.ts +247 -0
- package/src/share/schemas/person.ts +24 -0
- package/src/share/schemas/print.ts +93 -0
- package/src/share/schemas/section-background.ts +106 -0
- package/src/share/schemas/section-body.ts +138 -0
- package/src/share/schemas/section-cards.ts +37 -0
- package/src/share/schemas/section-cta.ts +74 -0
- package/src/share/schemas/section-header.ts +77 -0
- package/src/share/schemas/section-image.ts +77 -0
- package/src/share/schemas/section-motion.ts +52 -0
- package/src/share/schemas/section-shell.ts +63 -0
- package/src/share/schemas/section-stats.ts +37 -0
- package/src/share/schemas/site-background.ts +78 -0
- package/src/share/schemas/standard-list-item.ts +38 -0
- package/src/share/scripts/external-links.ts +45 -0
- package/src/share/scripts/gsap-counter.ts +168 -0
- package/src/share/scripts/gsap-mountain-journey.ts +236 -0
- package/src/share/scripts/gsap-parallax.ts +50 -0
- package/src/share/scripts/gsap-reveal.ts +65 -0
- package/src/share/scripts/gsap-stagger.ts +54 -0
- package/src/share/scripts/index.ts +25 -0
- package/src/share/scripts/inline-number-animation.ts +120 -0
- package/src/share/scripts/lenis.ts +109 -0
- package/src/share/scripts/live-photos.ts +250 -0
- package/src/share/scripts/lordicon.ts +94 -0
- package/src/share/scripts/orchestrator.ts +138 -0
- package/src/share/scripts/scheduler.ts +53 -0
- package/src/share/scripts/video-player.ts +116 -0
- package/src/share/semantic/ai.ts +140 -0
- package/src/share/semantic/block-extraction.ts +52 -0
- package/src/share/semantic/block-extractors/index.ts +502 -0
- package/src/share/semantic/breadcrumbs.ts +120 -0
- package/src/share/semantic/build-page.ts +309 -0
- package/src/share/semantic/business-projection.ts +278 -0
- package/src/share/semantic/derived-prices-loader.ts +36 -0
- package/src/share/semantic/extract.ts +118 -0
- package/src/share/semantic/feed.ts +124 -0
- package/src/share/semantic/ids.ts +76 -0
- package/src/share/semantic/image-sitemap.ts +153 -0
- package/src/share/semantic/index.ts +36 -0
- package/src/share/semantic/jsonld/article.ts +47 -0
- package/src/share/semantic/jsonld/breadcrumb.ts +47 -0
- package/src/share/semantic/jsonld/collection-list.ts +30 -0
- package/src/share/semantic/jsonld/context.ts +46 -0
- package/src/share/semantic/jsonld/faq.ts +49 -0
- package/src/share/semantic/jsonld/initiative.ts +53 -0
- package/src/share/semantic/jsonld/organization.ts +101 -0
- package/src/share/semantic/jsonld/person.ts +71 -0
- package/src/share/semantic/jsonld/service.ts +80 -0
- package/src/share/semantic/jsonld/shared.ts +31 -0
- package/src/share/semantic/jsonld/types.ts +18 -0
- package/src/share/semantic/jsonld/webpage.ts +98 -0
- package/src/share/semantic/jsonld/website.ts +27 -0
- package/src/share/semantic/jsonld.ts +75 -0
- package/src/share/semantic/llms-policy.ts +74 -0
- package/src/share/semantic/llms.ts +394 -0
- package/src/share/semantic/markdown-hygiene.ts +68 -0
- package/src/share/semantic/markdown-twin-provenance.ts +242 -0
- package/src/share/semantic/models.ts +402 -0
- package/src/share/semantic/organization-profile.ts +160 -0
- package/src/share/semantic/output-projection.ts +131 -0
- package/src/share/semantic/page-builders/markdown-page.ts +84 -0
- package/src/share/semantic/page-markdown.ts +234 -0
- package/src/share/semantic/page-utils.ts +125 -0
- package/src/share/semantic/price-marker-resolver.ts +92 -0
- package/src/share/semantic/robots.ts +127 -0
- package/src/share/semantic/update-stamp.ts +136 -0
- package/src/share/shared-context.ts +177 -0
- package/src/share/string-utils.ts +19 -0
- package/src/share/tests/api-catalog.test.ts +97 -0
- package/src/share/tests/breadcrumbs.test.ts +126 -0
- package/src/share/tests/build-page-price-markers.test.ts +160 -0
- package/src/share/tests/capability.test.ts +107 -0
- package/src/share/tests/claim.test.ts +90 -0
- package/src/share/tests/content-ref-index.test.ts +328 -0
- package/src/share/tests/create-dev-props-validator.test.ts +38 -0
- package/src/share/tests/derivation.test.ts +39 -0
- package/src/share/tests/dev-props-validator.test.ts +88 -0
- package/src/share/tests/fleet-catalog.test.ts +134 -0
- package/src/share/tests/formula-eval.test.ts +619 -0
- package/src/share/tests/freshness.test.ts +60 -0
- package/src/share/tests/hero-section-numbering-parity.test.ts +51 -0
- package/src/share/tests/image-sitemap.test.ts +101 -0
- package/src/share/tests/jsonld-service.test.ts +282 -0
- package/src/share/tests/knowledge.test.ts +86 -0
- package/src/share/tests/ledger.test.ts +125 -0
- package/src/share/tests/llms-0789.test.ts +63 -0
- package/src/share/tests/manifest.test.ts +100 -0
- package/src/share/tests/markdown-twin-provenance.test.ts +108 -0
- package/src/share/tests/mcp-card.test.ts +57 -0
- package/src/share/tests/onboarding-yaml.test.ts +111 -0
- package/src/share/tests/ontology-role-by-cosmic-name.test.ts +28 -0
- package/src/share/tests/openapi.test.ts +116 -0
- package/src/share/tests/organization-jsonld.test.ts +74 -0
- package/src/share/tests/output-projection.test.ts +61 -0
- package/src/share/tests/plan.test.ts +97 -0
- package/src/share/tests/price-marker-resolver.test.ts +141 -0
- package/src/share/tests/proof.test.ts +72 -0
- package/src/share/tests/resolve-field-path.test.ts +52 -0
- package/src/share/tests/source.test.ts +81 -0
- package/src/share/tests/substitute-deep.test.ts +65 -0
- package/src/share/tests/text-normalize.pbt.test.ts +143 -0
- package/src/share/tests/text-normalize.test.ts +285 -0
- package/src/share/tests/twin-path.test.ts +43 -0
- package/src/share/text-normalize.ts +548 -0
- package/src/share/text-position.ts +19 -0
- package/src/share/types/hls-js-light.d.ts +16 -0
- package/src/share/visibility.ts +167 -0
- package/src/share/vitest.config.ts +8 -0
- package/src/share/wrap-inline-numbers.ts +139 -0
- package/src/surface/blueprint-schema.ts +314 -0
- package/src/surface/blueprint-types.ts +256 -0
- package/src/surface/blueprint.ts +300 -0
- package/src/surface/breaker.ts +57 -0
- package/src/surface/decision-composer.ts +156 -0
- package/src/surface/eligibility.ts +372 -0
- package/src/surface/evidence-records.ts +97 -0
- package/src/surface/fleet.ts +60 -0
- package/src/surface/geo.ts +170 -0
- package/src/surface/governance.ts +146 -0
- package/src/surface/index.ts +216 -0
- package/src/surface/io/index.ts +18 -0
- package/src/surface/io/surface-module-context-io.ts +60 -0
- package/src/surface/io/visibility-outcomes-io.ts +46 -0
- package/src/surface/module-context.ts +120 -0
- package/src/surface/substance.ts +161 -0
- package/src/surface/tests/eligibility.pbt.test.ts +137 -0
- package/src/surface/tests/eligibility.test.ts +302 -0
- package/src/surface/types.ts +289 -0
- package/src/surface/visibility.ts +57 -0
- package/src/surface/vitest.config.ts +8 -0
- package/tsconfig.json +17 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { buildResourceAttributes, type WarpgogolResourceInput } from "../conventions.ts";
|
|
3
|
+
|
|
4
|
+
describe("buildResourceAttributes", () => {
|
|
5
|
+
it("builds correct attributes for a site-layer signal", () => {
|
|
6
|
+
const attrs = buildResourceAttributes({
|
|
7
|
+
serviceName: "warpgogol-com",
|
|
8
|
+
layer: "site",
|
|
9
|
+
environment: "production",
|
|
10
|
+
siteId: "warpgogol-com",
|
|
11
|
+
});
|
|
12
|
+
expect(attrs).toEqual([
|
|
13
|
+
{ key: "service.name", value: { stringValue: "warpgogol-com" } },
|
|
14
|
+
{ key: "deployment.environment", value: { stringValue: "production" } },
|
|
15
|
+
{ key: "warpgogol.layer", value: { stringValue: "site" } },
|
|
16
|
+
{ key: "warpgogol.site_id", value: { stringValue: "warpgogol-com" } },
|
|
17
|
+
]);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("includes service.version when provided", () => {
|
|
21
|
+
const attrs = buildResourceAttributes({
|
|
22
|
+
serviceName: "fleet-probe-runner",
|
|
23
|
+
layer: "probe",
|
|
24
|
+
environment: "production",
|
|
25
|
+
siteId: "warpgogol-com",
|
|
26
|
+
serviceVersion: "abc1234",
|
|
27
|
+
});
|
|
28
|
+
expect(attrs.some((a) => a.key === "service.version")).toBe(true);
|
|
29
|
+
expect(attrs.find((a) => a.key === "service.version")?.value.stringValue).toBe("abc1234");
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("throws when siteId is missing for site layer", () => {
|
|
33
|
+
expect(() =>
|
|
34
|
+
buildResourceAttributes({
|
|
35
|
+
serviceName: "warpgogol-com",
|
|
36
|
+
layer: "site",
|
|
37
|
+
environment: "production",
|
|
38
|
+
} as WarpgogolResourceInput),
|
|
39
|
+
).toThrow(/siteId is required/);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("throws when siteId is missing for probe layer", () => {
|
|
43
|
+
expect(() =>
|
|
44
|
+
buildResourceAttributes({
|
|
45
|
+
serviceName: "fleet-probe-runner",
|
|
46
|
+
layer: "probe",
|
|
47
|
+
environment: "production",
|
|
48
|
+
} as WarpgogolResourceInput),
|
|
49
|
+
).toThrow(/siteId is required/);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("throws when siteId is missing for delivery layer", () => {
|
|
53
|
+
expect(() =>
|
|
54
|
+
buildResourceAttributes({
|
|
55
|
+
serviceName: "cf-analytics-poller",
|
|
56
|
+
layer: "delivery",
|
|
57
|
+
environment: "production",
|
|
58
|
+
} as WarpgogolResourceInput),
|
|
59
|
+
).toThrow(/siteId is required/);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("does not require siteId for factory layer", () => {
|
|
63
|
+
const attrs = buildResourceAttributes({
|
|
64
|
+
serviceName: "site-kernel",
|
|
65
|
+
layer: "factory",
|
|
66
|
+
environment: "ci",
|
|
67
|
+
});
|
|
68
|
+
expect(attrs.some((a) => a.key === "warpgogol.site_id")).toBe(false);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("throws for invalid layer", () => {
|
|
72
|
+
expect(() =>
|
|
73
|
+
buildResourceAttributes({
|
|
74
|
+
serviceName: "test",
|
|
75
|
+
layer: "invalid" as never,
|
|
76
|
+
environment: "production",
|
|
77
|
+
}),
|
|
78
|
+
).toThrow(/not in the closed vocabulary/);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("throws for invalid environment", () => {
|
|
82
|
+
expect(() =>
|
|
83
|
+
buildResourceAttributes({
|
|
84
|
+
serviceName: "test",
|
|
85
|
+
layer: "factory",
|
|
86
|
+
environment: "staging" as never,
|
|
87
|
+
}),
|
|
88
|
+
).toThrow(/not in the closed vocabulary/);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it("throws when serviceName is empty", () => {
|
|
92
|
+
expect(() =>
|
|
93
|
+
buildResourceAttributes({
|
|
94
|
+
serviceName: "",
|
|
95
|
+
layer: "factory",
|
|
96
|
+
environment: "ci",
|
|
97
|
+
}),
|
|
98
|
+
).toThrow(/serviceName is required/);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
WARPGOGOL_METRIC_REGISTRY,
|
|
4
|
+
findMetricSpec,
|
|
5
|
+
isMetricNameValid,
|
|
6
|
+
isLabelKeyForbidden,
|
|
7
|
+
FORBIDDEN_LABEL_KEYS,
|
|
8
|
+
} from "../metric-registry.ts";
|
|
9
|
+
|
|
10
|
+
describe("WARPGOGOL_METRIC_REGISTRY", () => {
|
|
11
|
+
it("contains the smoke metric", () => {
|
|
12
|
+
const smoke = findMetricSpec("warpgogol_factory_smoke_total");
|
|
13
|
+
expect(smoke).toBeDefined();
|
|
14
|
+
expect(smoke?.kind).toBe("counter");
|
|
15
|
+
expect(smoke?.labelKeys).toEqual([]);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("has no duplicate names", () => {
|
|
19
|
+
const names = WARPGOGOL_METRIC_REGISTRY.map((s) => s.name);
|
|
20
|
+
const unique = new Set(names);
|
|
21
|
+
expect(names.length).toBe(unique.size);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("all names match the naming grammar", () => {
|
|
25
|
+
for (const spec of WARPGOGOL_METRIC_REGISTRY) {
|
|
26
|
+
expect(isMetricNameValid(spec.name)).toBe(true);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("no entry has a forbidden label key", () => {
|
|
31
|
+
for (const spec of WARPGOGOL_METRIC_REGISTRY) {
|
|
32
|
+
for (const key of spec.labelKeys) {
|
|
33
|
+
expect(isLabelKeyForbidden(key)).toBe(false);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("contains all 5 back metrics with correct kinds and labels (RFC-0807)", () => {
|
|
39
|
+
const requests = findMetricSpec("warpgogol_back_requests_total");
|
|
40
|
+
expect(requests).toBeDefined();
|
|
41
|
+
expect(requests?.kind).toBe("counter");
|
|
42
|
+
expect(requests?.labelKeys).toEqual(["service", "status_class"]);
|
|
43
|
+
|
|
44
|
+
const up = findMetricSpec("warpgogol_back_up");
|
|
45
|
+
expect(up).toBeDefined();
|
|
46
|
+
expect(up?.kind).toBe("gauge");
|
|
47
|
+
expect(up?.labelKeys).toEqual(["service"]);
|
|
48
|
+
|
|
49
|
+
const lastRun = findMetricSpec("warpgogol_back_last_run_total");
|
|
50
|
+
expect(lastRun).toBeDefined();
|
|
51
|
+
expect(lastRun?.kind).toBe("counter");
|
|
52
|
+
expect(lastRun?.labelKeys).toEqual(["service", "status"]);
|
|
53
|
+
|
|
54
|
+
const lastError = findMetricSpec("warpgogol_back_last_error_total");
|
|
55
|
+
expect(lastError).toBeDefined();
|
|
56
|
+
expect(lastError?.kind).toBe("counter");
|
|
57
|
+
expect(lastError?.labelKeys).toEqual(["service"]);
|
|
58
|
+
|
|
59
|
+
const queueDepth = findMetricSpec("warpgogol_back_queue_depth");
|
|
60
|
+
expect(queueDepth).toBeDefined();
|
|
61
|
+
expect(queueDepth?.kind).toBe("gauge");
|
|
62
|
+
expect(queueDepth?.labelKeys).toEqual(["service"]);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
describe("isMetricNameValid", () => {
|
|
67
|
+
it("accepts valid factory metric names", () => {
|
|
68
|
+
expect(isMetricNameValid("warpgogol_factory_smoke_total")).toBe(true);
|
|
69
|
+
expect(isMetricNameValid("warpgogol_factory_command_duration_seconds")).toBe(true);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("accepts valid probe metric names", () => {
|
|
73
|
+
expect(isMetricNameValid("warpgogol_probe_up")).toBe(true);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("accepts valid delivery metric names", () => {
|
|
77
|
+
expect(isMetricNameValid("warpgogol_delivery_requests_total")).toBe(true);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("accepts valid workers metric names", () => {
|
|
81
|
+
expect(isMetricNameValid("warpgogol_workers_errors_total")).toBe(true);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("accepts valid back metric names (RFC-0807)", () => {
|
|
85
|
+
expect(isMetricNameValid("warpgogol_back_requests_total")).toBe(true);
|
|
86
|
+
expect(isMetricNameValid("warpgogol_back_up")).toBe(true);
|
|
87
|
+
expect(isMetricNameValid("warpgogol_back_last_run_total")).toBe(true);
|
|
88
|
+
expect(isMetricNameValid("warpgogol_back_last_error_total")).toBe(true);
|
|
89
|
+
expect(isMetricNameValid("warpgogol_back_queue_depth")).toBe(true);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("rejects names without the warpgogol_ prefix", () => {
|
|
93
|
+
expect(isMetricNameValid("factory_smoke_total")).toBe(false);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it("rejects names with wrong prefix domain", () => {
|
|
97
|
+
expect(isMetricNameValid("warpgogol_foo_smoke_total")).toBe(false);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it("rejects names with uppercase", () => {
|
|
101
|
+
expect(isMetricNameValid("warpgogol_factory_Smoke")).toBe(false);
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
describe("isLabelKeyForbidden", () => {
|
|
106
|
+
it("returns true for all forbidden keys", () => {
|
|
107
|
+
for (const key of FORBIDDEN_LABEL_KEYS) {
|
|
108
|
+
expect(isLabelKeyForbidden(key)).toBe(true);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it("returns false for allowed keys", () => {
|
|
113
|
+
expect(isLabelKeyForbidden("site_id")).toBe(false);
|
|
114
|
+
expect(isLabelKeyForbidden("status_class")).toBe(false);
|
|
115
|
+
expect(isLabelKeyForbidden("command")).toBe(false);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import fc from "fast-check";
|
|
3
|
+
import { convertAccumulatedToOtlp, type AccumulatedPoint } from "../otlp-converter.ts";
|
|
4
|
+
|
|
5
|
+
const START_TIME = "1751884500000000000";
|
|
6
|
+
|
|
7
|
+
const metricNameArb = fc.constantFrom(
|
|
8
|
+
"warpgogol_factory_smoke_total",
|
|
9
|
+
"warpgogol_factory_command_runs_total",
|
|
10
|
+
"warpgogol_probe_up",
|
|
11
|
+
"warpgogol_probe_ttfb_seconds",
|
|
12
|
+
"warpgogol_factory_command_duration_seconds",
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
const kindArb = fc.constantFrom<"counter" | "gauge" | "histogram">("counter", "gauge", "histogram");
|
|
16
|
+
|
|
17
|
+
const pointArb: fc.Arbitrary<AccumulatedPoint> = fc.record({
|
|
18
|
+
name: metricNameArb,
|
|
19
|
+
labels: fc.dictionary(fc.string({ maxLength: 10 }), fc.string({ maxLength: 20 })),
|
|
20
|
+
value: fc.double({ min: 0, max: 1000, noDefaultInfinity: true, noNaN: true }),
|
|
21
|
+
kind: kindArb,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const pointsArb = fc.array(pointArb, { maxLength: 50 });
|
|
25
|
+
|
|
26
|
+
describe("convertAccumulatedToOtlp — property-based tests (DNA-41)", () => {
|
|
27
|
+
it("bucket counts sum equals total points per histogram metric", () => {
|
|
28
|
+
fc.assert(
|
|
29
|
+
fc.property(pointsArb, (points) => {
|
|
30
|
+
const result = convertAccumulatedToOtlp(points, START_TIME);
|
|
31
|
+
for (const otlp of result) {
|
|
32
|
+
if (otlp.kind === "histogram" && otlp.histogramPoints) {
|
|
33
|
+
const hp = otlp.histogramPoints[0]!;
|
|
34
|
+
const bucketSum = hp.bucketCounts.reduce((acc, c) => acc + Number(c), 0);
|
|
35
|
+
const histogramPoints = points.filter((p) => p.name === otlp.name);
|
|
36
|
+
expect(bucketSum).toBe(histogramPoints.length);
|
|
37
|
+
expect(hp.count).toBe(String(histogramPoints.length));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}),
|
|
41
|
+
);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("output metric names are a subset of input metric names", () => {
|
|
45
|
+
fc.assert(
|
|
46
|
+
fc.property(pointsArb, (points) => {
|
|
47
|
+
const result = convertAccumulatedToOtlp(points, START_TIME);
|
|
48
|
+
const inputNames = new Set(points.map((p) => p.name));
|
|
49
|
+
for (const otlp of result) {
|
|
50
|
+
expect(inputNames.has(otlp.name)).toBe(true);
|
|
51
|
+
}
|
|
52
|
+
}),
|
|
53
|
+
);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("each output metric appears exactly once (grouping is stable)", () => {
|
|
57
|
+
fc.assert(
|
|
58
|
+
fc.property(pointsArb, (points) => {
|
|
59
|
+
const result = convertAccumulatedToOtlp(points, START_TIME);
|
|
60
|
+
const outputNames = result.map((r) => r.name);
|
|
61
|
+
const uniqueNames = new Set(outputNames);
|
|
62
|
+
expect(outputNames.length).toBe(uniqueNames.size);
|
|
63
|
+
}),
|
|
64
|
+
);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("empty input always produces empty output", () => {
|
|
68
|
+
fc.assert(
|
|
69
|
+
fc.property(pointsArb, (points) => {
|
|
70
|
+
if (points.length === 0) {
|
|
71
|
+
const result = convertAccumulatedToOtlp(points, START_TIME);
|
|
72
|
+
expect(result).toEqual([]);
|
|
73
|
+
}
|
|
74
|
+
}),
|
|
75
|
+
);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { convertAccumulatedToOtlp, type AccumulatedPoint } from "../otlp-converter.ts";
|
|
3
|
+
|
|
4
|
+
const START_TIME = "1751884500000000000";
|
|
5
|
+
|
|
6
|
+
describe("convertAccumulatedToOtlp", () => {
|
|
7
|
+
it("returns empty array for empty input", () => {
|
|
8
|
+
const result = convertAccumulatedToOtlp([], START_TIME);
|
|
9
|
+
expect(result).toEqual([]);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("skips points with undeclared metric names", () => {
|
|
13
|
+
const points: AccumulatedPoint[] = [
|
|
14
|
+
{ name: "warpgogol_unknown_metric", labels: {}, value: 1, kind: "counter" },
|
|
15
|
+
];
|
|
16
|
+
const result = convertAccumulatedToOtlp(points, START_TIME);
|
|
17
|
+
expect(result).toEqual([]);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("converts a counter point to a sum metric", () => {
|
|
21
|
+
const points: AccumulatedPoint[] = [
|
|
22
|
+
{ name: "warpgogol_factory_smoke_total", labels: {}, value: 1, kind: "counter" },
|
|
23
|
+
];
|
|
24
|
+
const result = convertAccumulatedToOtlp(points, START_TIME);
|
|
25
|
+
expect(result).toHaveLength(1);
|
|
26
|
+
expect(result[0]!.kind).toBe("sum");
|
|
27
|
+
expect(result[0]!.name).toBe("warpgogol_factory_smoke_total");
|
|
28
|
+
expect(result[0]!.isMonotonic).toBe(true);
|
|
29
|
+
expect(result[0]!.sumPoints).toHaveLength(1);
|
|
30
|
+
expect(result[0]!.sumPoints![0]!.asDouble).toBe(1);
|
|
31
|
+
expect(result[0]!.sumPoints![0]!.startTimeUnixNano).toBe(START_TIME);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("groups multiple counter points by name into one sum metric", () => {
|
|
35
|
+
const points: AccumulatedPoint[] = [
|
|
36
|
+
{
|
|
37
|
+
name: "warpgogol_factory_command_runs_total",
|
|
38
|
+
labels: { command: "build.check", status: "pass" },
|
|
39
|
+
value: 1,
|
|
40
|
+
kind: "counter",
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: "warpgogol_factory_command_runs_total",
|
|
44
|
+
labels: { command: "build.check", status: "fail" },
|
|
45
|
+
value: 1,
|
|
46
|
+
kind: "counter",
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
const result = convertAccumulatedToOtlp(points, START_TIME);
|
|
50
|
+
expect(result).toHaveLength(1);
|
|
51
|
+
expect(result[0]!.sumPoints).toHaveLength(2);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("converts a gauge point to a gauge metric", () => {
|
|
55
|
+
const points: AccumulatedPoint[] = [
|
|
56
|
+
{
|
|
57
|
+
name: "warpgogol_probe_up",
|
|
58
|
+
labels: { site_id: "warpgogol-com", route: "/" },
|
|
59
|
+
value: 1,
|
|
60
|
+
kind: "gauge",
|
|
61
|
+
},
|
|
62
|
+
];
|
|
63
|
+
const result = convertAccumulatedToOtlp(points, START_TIME);
|
|
64
|
+
expect(result).toHaveLength(1);
|
|
65
|
+
expect(result[0]!.kind).toBe("gauge");
|
|
66
|
+
expect(result[0]!.gaugePoints).toHaveLength(1);
|
|
67
|
+
expect(result[0]!.gaugePoints![0]!.asDouble).toBe(1);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("converts histogram points with correct bucket counts", () => {
|
|
71
|
+
const points: AccumulatedPoint[] = [
|
|
72
|
+
{
|
|
73
|
+
name: "warpgogol_factory_command_duration_seconds",
|
|
74
|
+
labels: { command: "build.check" },
|
|
75
|
+
value: 0.3,
|
|
76
|
+
kind: "histogram",
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: "warpgogol_factory_command_duration_seconds",
|
|
80
|
+
labels: { command: "build.check" },
|
|
81
|
+
value: 1.5,
|
|
82
|
+
kind: "histogram",
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: "warpgogol_factory_command_duration_seconds",
|
|
86
|
+
labels: { command: "build.check" },
|
|
87
|
+
value: 700,
|
|
88
|
+
kind: "histogram",
|
|
89
|
+
},
|
|
90
|
+
];
|
|
91
|
+
const result = convertAccumulatedToOtlp(points, START_TIME);
|
|
92
|
+
expect(result).toHaveLength(1);
|
|
93
|
+
expect(result[0]!.kind).toBe("histogram");
|
|
94
|
+
const hp = result[0]!.histogramPoints![0]!;
|
|
95
|
+
expect(hp.count).toBe("3");
|
|
96
|
+
expect(hp.sum).toBe(701.8);
|
|
97
|
+
expect(hp.bucketCounts).toHaveLength(11);
|
|
98
|
+
expect(hp.explicitBounds).toEqual([0.5, 1, 2, 5, 10, 30, 60, 120, 300, 600]);
|
|
99
|
+
expect(hp.bucketCounts[0]).toBe("1");
|
|
100
|
+
expect(hp.bucketCounts[2]).toBe("1");
|
|
101
|
+
expect(hp.bucketCounts[10]).toBe("1");
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it("places value exactly on a bucket boundary in the lower bucket", () => {
|
|
105
|
+
const points: AccumulatedPoint[] = [
|
|
106
|
+
{
|
|
107
|
+
name: "warpgogol_factory_command_duration_seconds",
|
|
108
|
+
labels: { command: "build.check" },
|
|
109
|
+
value: 1,
|
|
110
|
+
kind: "histogram",
|
|
111
|
+
},
|
|
112
|
+
];
|
|
113
|
+
const result = convertAccumulatedToOtlp(points, START_TIME);
|
|
114
|
+
const hp = result[0]!.histogramPoints![0]!;
|
|
115
|
+
expect(hp.bucketCounts[1]).toBe("1");
|
|
116
|
+
expect(hp.bucketCounts[2]).toBe("0");
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it("handles mixed kinds in a single call", () => {
|
|
120
|
+
const points: AccumulatedPoint[] = [
|
|
121
|
+
{ name: "warpgogol_factory_smoke_total", labels: {}, value: 1, kind: "counter" },
|
|
122
|
+
{
|
|
123
|
+
name: "warpgogol_probe_up",
|
|
124
|
+
labels: { site_id: "warpgogol-com", route: "/" },
|
|
125
|
+
value: 1,
|
|
126
|
+
kind: "gauge",
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
name: "warpgogol_factory_command_duration_seconds",
|
|
130
|
+
labels: { command: "build.check" },
|
|
131
|
+
value: 2,
|
|
132
|
+
kind: "histogram",
|
|
133
|
+
},
|
|
134
|
+
];
|
|
135
|
+
const result = convertAccumulatedToOtlp(points, START_TIME);
|
|
136
|
+
expect(result).toHaveLength(3);
|
|
137
|
+
const kinds = result.map((r) => r.kind).sort();
|
|
138
|
+
expect(kinds).toEqual(["gauge", "histogram", "sum"]);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it("preserves label attributes in output points", () => {
|
|
142
|
+
const points: AccumulatedPoint[] = [
|
|
143
|
+
{
|
|
144
|
+
name: "warpgogol_probe_up",
|
|
145
|
+
labels: { site_id: "warpgogol-com", route: "/" },
|
|
146
|
+
value: 1,
|
|
147
|
+
kind: "gauge",
|
|
148
|
+
},
|
|
149
|
+
];
|
|
150
|
+
const result = convertAccumulatedToOtlp(points, START_TIME);
|
|
151
|
+
const attrs = result[0]!.gaugePoints![0]!.attributes!;
|
|
152
|
+
expect(attrs).toEqual([
|
|
153
|
+
{ key: "site_id", value: { stringValue: "warpgogol-com" } },
|
|
154
|
+
{ key: "route", value: { stringValue: "/" } },
|
|
155
|
+
]);
|
|
156
|
+
});
|
|
157
|
+
});
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { encodeOtlpMetrics, nowUnixNano, type OtlpMetricPoint } from "../otlp-json.ts";
|
|
3
|
+
import type { OtlpKeyValue } from "../conventions.ts";
|
|
4
|
+
|
|
5
|
+
const resourceAttrs: OtlpKeyValue[] = [
|
|
6
|
+
{ key: "service.name", value: { stringValue: "fleet-probe-runner" } },
|
|
7
|
+
{ key: "deployment.environment", value: { stringValue: "production" } },
|
|
8
|
+
{ key: "warpgogol.layer", value: { stringValue: "probe" } },
|
|
9
|
+
{ key: "warpgogol.site_id", value: { stringValue: "warpgogol-com" } },
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
describe("encodeOtlpMetrics", () => {
|
|
13
|
+
it("encodes a gauge metric", () => {
|
|
14
|
+
const points: OtlpMetricPoint[] = [
|
|
15
|
+
{
|
|
16
|
+
name: "warpgogol_probe_up",
|
|
17
|
+
kind: "gauge",
|
|
18
|
+
gaugePoints: [
|
|
19
|
+
{
|
|
20
|
+
asDouble: 1,
|
|
21
|
+
timeUnixNano: "1751884800000000000",
|
|
22
|
+
attributes: [{ key: "site_id", value: { stringValue: "warpgogol-com" } }],
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
];
|
|
27
|
+
const env = encodeOtlpMetrics(resourceAttrs, points, "@warpgogol/werkstatt-shared/observability", "1");
|
|
28
|
+
expect(env.resourceMetrics).toHaveLength(1);
|
|
29
|
+
expect(env.resourceMetrics[0]!.resource.attributes).toEqual(resourceAttrs);
|
|
30
|
+
const scope = env.resourceMetrics[0]!.scopeMetrics[0]!;
|
|
31
|
+
expect(scope.scope.name).toBe("@warpgogol/werkstatt-shared/observability");
|
|
32
|
+
expect(scope.scope.version).toBe("1");
|
|
33
|
+
expect(scope.metrics).toHaveLength(1);
|
|
34
|
+
const metric = scope.metrics[0] as Record<string, unknown>;
|
|
35
|
+
expect(metric["name"]).toBe("warpgogol_probe_up");
|
|
36
|
+
expect(metric["gauge"]).toBeDefined();
|
|
37
|
+
const gauge = metric["gauge"] as { dataPoints: unknown[] };
|
|
38
|
+
expect(gauge.dataPoints).toHaveLength(1);
|
|
39
|
+
const dp = gauge.dataPoints[0] as Record<string, unknown>;
|
|
40
|
+
expect(dp["asDouble"]).toBe(1);
|
|
41
|
+
expect(dp["timeUnixNano"]).toBe("1751884800000000000");
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("encodes a delta sum (counter) with aggregationTemporality 1", () => {
|
|
45
|
+
const points: OtlpMetricPoint[] = [
|
|
46
|
+
{
|
|
47
|
+
name: "warpgogol_probe_http_status_class_total",
|
|
48
|
+
kind: "sum",
|
|
49
|
+
unit: "1",
|
|
50
|
+
isMonotonic: true,
|
|
51
|
+
sumPoints: [
|
|
52
|
+
{
|
|
53
|
+
asDouble: 3,
|
|
54
|
+
startTimeUnixNano: "1751884500000000000",
|
|
55
|
+
timeUnixNano: "1751884800000000000",
|
|
56
|
+
attributes: [{ key: "status_class", value: { stringValue: "2xx" } }],
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
];
|
|
61
|
+
const env = encodeOtlpMetrics(resourceAttrs, points, "@warpgogol/werkstatt-shared/observability", "1");
|
|
62
|
+
const metric = env.resourceMetrics[0]!.scopeMetrics[0]!.metrics[0] as Record<string, unknown>;
|
|
63
|
+
expect(metric["name"]).toBe("warpgogol_probe_http_status_class_total");
|
|
64
|
+
expect(metric["unit"]).toBe("1");
|
|
65
|
+
const sum = metric["sum"] as {
|
|
66
|
+
aggregationTemporality: number;
|
|
67
|
+
isMonotonic: boolean;
|
|
68
|
+
dataPoints: unknown[];
|
|
69
|
+
};
|
|
70
|
+
expect(sum.aggregationTemporality).toBe(1);
|
|
71
|
+
expect(sum.isMonotonic).toBe(true);
|
|
72
|
+
const dp = sum.dataPoints[0] as Record<string, unknown>;
|
|
73
|
+
expect(dp["asDouble"]).toBe(3);
|
|
74
|
+
expect(dp["startTimeUnixNano"]).toBe("1751884500000000000");
|
|
75
|
+
expect(dp["timeUnixNano"]).toBe("1751884800000000000");
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("encodes a delta histogram with correct bucketCounts and explicitBounds", () => {
|
|
79
|
+
const points: OtlpMetricPoint[] = [
|
|
80
|
+
{
|
|
81
|
+
name: "warpgogol_factory_command_duration_seconds",
|
|
82
|
+
kind: "histogram",
|
|
83
|
+
unit: "s",
|
|
84
|
+
histogramPoints: [
|
|
85
|
+
{
|
|
86
|
+
startTimeUnixNano: "1751884500000000000",
|
|
87
|
+
timeUnixNano: "1751884800000000000",
|
|
88
|
+
count: "3",
|
|
89
|
+
sum: 42.5,
|
|
90
|
+
bucketCounts: ["0", "1", "1", "1", "0", "0", "0", "0", "0", "0", "0"],
|
|
91
|
+
explicitBounds: [0.5, 1, 2, 5, 10, 30, 60, 120, 300, 600],
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
},
|
|
95
|
+
];
|
|
96
|
+
const env = encodeOtlpMetrics(resourceAttrs, points, "@warpgogol/werkstatt-shared/observability", "1");
|
|
97
|
+
const metric = env.resourceMetrics[0]!.scopeMetrics[0]!.metrics[0] as Record<string, unknown>;
|
|
98
|
+
expect(metric["name"]).toBe("warpgogol_factory_command_duration_seconds");
|
|
99
|
+
expect(metric["unit"]).toBe("s");
|
|
100
|
+
const hist = metric["histogram"] as { aggregationTemporality: number; dataPoints: unknown[] };
|
|
101
|
+
expect(hist.aggregationTemporality).toBe(1);
|
|
102
|
+
const dp = hist.dataPoints[0] as Record<string, unknown>;
|
|
103
|
+
expect(dp["count"]).toBe("3");
|
|
104
|
+
expect(dp["sum"]).toBe(42.5);
|
|
105
|
+
expect(dp["bucketCounts"]).toEqual(["0", "1", "1", "1", "0", "0", "0", "0", "0", "0", "0"]);
|
|
106
|
+
expect(dp["explicitBounds"]).toEqual([0.5, 1, 2, 5, 10, 30, 60, 120, 300, 600]);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
describe("nowUnixNano", () => {
|
|
111
|
+
it("returns a string of digits representing unix nanoseconds", () => {
|
|
112
|
+
const nano = nowUnixNano();
|
|
113
|
+
expect(typeof nano).toBe("string");
|
|
114
|
+
expect(nano).toMatch(/^\d+$/);
|
|
115
|
+
// Should be approximately Date.now() * 1e6
|
|
116
|
+
const approx = Date.now() * 1_000_000;
|
|
117
|
+
const parsed = Number(nano);
|
|
118
|
+
expect(Math.abs(parsed - approx)).toBeLessThan(5_000_000_000);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// @vitest-environment node
|
|
2
|
+
import { describe, it, expect } from "vitest";
|
|
3
|
+
import { createMetricsPusher } from "../pusher.ts";
|
|
4
|
+
|
|
5
|
+
describe("createMetricsPusher", () => {
|
|
6
|
+
it("returns null when endpoint is missing", () => {
|
|
7
|
+
const pusher = createMetricsPusher(
|
|
8
|
+
{ serviceName: "test", layer: "factory", environment: "ci" },
|
|
9
|
+
{ token: "abc" },
|
|
10
|
+
);
|
|
11
|
+
expect(pusher).toBeNull();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("returns null when token is missing", () => {
|
|
15
|
+
const pusher = createMetricsPusher(
|
|
16
|
+
{ serviceName: "test", layer: "factory", environment: "ci" },
|
|
17
|
+
{ endpoint: "https://ingest.example.com" },
|
|
18
|
+
);
|
|
19
|
+
expect(pusher).toBeNull();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("returns null when both are missing", () => {
|
|
23
|
+
const pusher = createMetricsPusher(
|
|
24
|
+
{ serviceName: "test", layer: "factory", environment: "ci" },
|
|
25
|
+
{},
|
|
26
|
+
);
|
|
27
|
+
expect(pusher).toBeNull();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("returns a pusher when both env vars are present", () => {
|
|
31
|
+
const pusher = createMetricsPusher(
|
|
32
|
+
{ serviceName: "test", layer: "factory", environment: "ci" },
|
|
33
|
+
{ endpoint: "https://ingest.example.com", token: "abc" },
|
|
34
|
+
);
|
|
35
|
+
expect(pusher).not.toBeNull();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("flush() resolves with delivered:true when no points accumulated", async () => {
|
|
39
|
+
const pusher = createMetricsPusher(
|
|
40
|
+
{ serviceName: "test", layer: "factory", environment: "ci" },
|
|
41
|
+
{ endpoint: "https://ingest.example.com", token: "abc" },
|
|
42
|
+
);
|
|
43
|
+
const result = await pusher!.flush();
|
|
44
|
+
expect(result.delivered).toBe(true);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("flush() never throws even on network failure", async () => {
|
|
48
|
+
const pusher = createMetricsPusher(
|
|
49
|
+
{ serviceName: "test", layer: "factory", environment: "ci" },
|
|
50
|
+
{ endpoint: "https://nonexistent.invalid.example", token: "abc" },
|
|
51
|
+
{ timeoutMs: 100 },
|
|
52
|
+
);
|
|
53
|
+
pusher!.counterAdd("warpgogol_factory_smoke_total", 1);
|
|
54
|
+
const result = await pusher!.flush();
|
|
55
|
+
expect(result.delivered).toBe(false);
|
|
56
|
+
expect(result.reason).toBeDefined();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("flush() honors timeout via AbortController", async () => {
|
|
60
|
+
// Use a hanging endpoint — we can't easily mock fetch, but we can test
|
|
61
|
+
// with a very short timeout against a real (slow) endpoint.
|
|
62
|
+
const pusher = createMetricsPusher(
|
|
63
|
+
{ serviceName: "test", layer: "factory", environment: "ci" },
|
|
64
|
+
{ endpoint: "https://10.255.255.1", token: "abc" },
|
|
65
|
+
{ timeoutMs: 50 },
|
|
66
|
+
);
|
|
67
|
+
pusher!.counterAdd("warpgogol_factory_smoke_total", 1);
|
|
68
|
+
const start = Date.now();
|
|
69
|
+
const result = await pusher!.flush();
|
|
70
|
+
const elapsed = Date.now() - start;
|
|
71
|
+
expect(result.delivered).toBe(false);
|
|
72
|
+
// Should abort within a reasonable window of the timeout
|
|
73
|
+
expect(elapsed).toBeLessThan(5000);
|
|
74
|
+
});
|
|
75
|
+
});
|