Skip to content

D-1: Resolve SystemTypeUris name collision between model.ts and constants.ts #136

Closed

Description

@Sam-Bolling

Task

Rename the internal SystemTypeUris constant in formats/constants.ts to SYSTEM_TYPE_RECOGNITION_VALUES to eliminate the name collision with the public SystemTypeUris in model.ts.

Finding Reference: D-1 from CSAPI-CODE-AUDIT-PHASE-6.md, investigated in F70 Design Findings Investigation
Severity: Moderate
Category: Naming collision / API-surface ambiguity
Implementation Branch: phase-6


Problem Statement

Two different modules export the same symbol name SystemTypeUris with different values:

  • model.ts (line ~81): 5 entries — full URI forms only (http://www.w3.org/ns/sosa/Sensor, etc.)
  • formats/constants.ts (line ~120): 10 entries — both CURIE forms (sosa:Sensor) AND full URI forms

The barrel file (csapi/index.ts) only re-exports the model.ts version, so the collision is not consumer-facing today. However, the identical naming creates maintainer confusion and is a latent hazard if the barrel ever changes.

Evidence:

// model.ts — 5 entries, full URIs only (PUBLIC via barrel)
export const SystemTypeUris = [
  'http://www.w3.org/ns/sosa/Sensor',
  'http://www.w3.org/ns/sosa/Actuator',
  'http://www.w3.org/ns/sosa/Platform',
  'http://www.w3.org/ns/sosa/Sampler',
  'http://www.w3.org/ns/sosa/System',
] as const;

// constants.ts — 10 entries, CURIEs + full URIs (INTERNAL only)
export const SystemTypeUris = [
  'sosa:Sensor', 'http://www.w3.org/ns/sosa/Sensor',
  'sosa:Platform', 'http://www.w3.org/ns/sosa/Platform',
  // ... 6 more
] as const;

Impact: Maintainer confusion — two SystemTypeUris with different values/purposes. Latent consumer-facing risk if barrel exports change. Code audit Priority 2 (#4).

Files to Create or Modify

File Action Est. Lines Purpose
src/ogc-api/csapi/formats/constants.ts Modify ~5 changed Rename SystemTypeUris → SYSTEM_TYPE_RECOGNITION_VALUES and SystemTypeUri → SystemTypeRecognitionValue
Internal consumers of SystemTypeUris from constants.ts Modify ~2-5 per file Update import references

Proposed Fix

Rename the internal constant in constants.ts:

// Before
export const SystemTypeUris = ['sosa:Sensor', 'http://...', ...] as const;
export type SystemTypeUri = (typeof SystemTypeUris)[number];

// After
export const SYSTEM_TYPE_RECOGNITION_VALUES = ['sosa:Sensor', 'http://...', ...] as const;
export type SystemTypeRecognitionValue = (typeof SYSTEM_TYPE_RECOGNITION_VALUES)[number];

Then update all internal import sites (grep for SystemTypeUris in formats/ to find them — likely geojson.ts, classification.ts, or similar).

Why this approach:

  • Zero public API change — the barrel export stays SystemTypeUris from model.ts
  • Self-documenting — SYSTEM_TYPE_RECOGNITION_VALUES communicates "matching table, not canonical type set"
  • SCREAMING_CASE convention signals module-internal constant (consistent with SIMPLE_COMPONENT_TYPES, CSAPI_CONTENT_TYPES already in constants.ts)
  • model.ts and the public barrel are untouched

Scope — What NOT to Touch

  • ❌ Do NOT modify model.ts — its SystemTypeUris is the public API and is correct
  • ❌ Do NOT modify csapi/index.ts (the barrel) — the public re-export is unaffected
  • ❌ Do NOT consolidate the two into a single definition — they serve different purposes (public type discrimination vs internal parsing recognition)
  • ❌ Do NOT modify files outside the formats/ directory tree
  • ❌ Do NOT change any CSAPI business logic — this is a rename only

Acceptance Criteria

  • constants.ts no longer exports SystemTypeUris — renamed to SYSTEM_TYPE_RECOGNITION_VALUES
  • All internal import sites updated — zero TypeScript compilation errors (npx tsc --noEmit)
  • The public barrel (csapi/index.ts) still exports SystemTypeUris from model.ts — no change
  • Existing tests still pass (npm run test:browser)
  • No lint errors (npm run lint)
  • All modified files pass npx prettier --check
  • git grep 'SystemTypeUris' src/ogc-api/csapi/formats/ returns 0 matches (old name fully eliminated from formats/)

Dependencies

Blocked by: Nothing
Blocks: Nothing


Operational Constraints

⚠️ MANDATORY: Before starting work on this issue, review docs/governance/AI_OPERATIONAL_CONSTRAINTS.md and the CSAPI Code Audit.

Key constraints:

  • Precedence: OGC specifications → AI Collaboration Agreement → This issue description → Existing code → Conversational context
  • No scope expansion: Rename the collision, nothing more
  • Minimal diffs: Only rename + update import references
  • Zero business logic changes: The recognition logic is unchanged — only the symbol name changes

References

# Document What It Provides
1 CSAPI Code Audit — D-1 Finding definition and recommendation
2 F70 Investigation Report Fact-check and evidence for D-1
3 D-1/D-3/D-4 Fix Recommendations Detailed fix approach
4 src/ogc-api/csapi/formats/constants.ts File containing the collision

Activity

  1. Sam-Bolling commented on Feb 25, 2026

    @Sam-Bolling
    Author

    Provenance Analysis: The constants.ts SystemTypeUris Was Deliberately Engineered

    Follow-up research reveals that the content of the constants.ts SystemTypeUris (both CURIE and full URI forms) was a deliberate engineering response to real server behavior differences discovered during live testing — not an accidental duplication. The name collision with model.ts was the accident; the dual-form content was intentional.

    Evidence Chain

    1. Live server testing proved both URI forms exist in the wild

    Smoke Test #10 (Phase 3.1, live-server-smoke-test-post-phase-3.1.md) — Vocabulary Inventory:

    Server featureType form Example
    OSH (OpenSensorHub) Full URIs only http://www.w3.org/ns/sosa/Sensor
    52North Mixed CURIEs + full URIs sosa:Sensor (CURIE) for procedures, http://www.w3.org/ns/sosa/Deployment (full URI) for deployments

    Finding F44 documented this explicitly: "52North uses both CURIE and full URI forms... The handler's toSosaLocalName() function correctly handles both forms."

    2. The constants.ts version was created specifically to satisfy this need

    Issue #29 (Phase 3, "Format Constants") specified both forms:

    "Per the Guide, CSAPI also accepts compact sosa: prefixed forms."

    The JSDoc on constants.ts itself states: "CSAPI featureType values use either the full URI form or the compact CURIE prefix form. Both are equivalent."

    3. The timeline explains the collision

    • Phase 2 (Issue Phase 2.1: Systems Methods #5): model.ts defined SystemTypeUris with 5 full URIs — the canonical OGC spec values for the public type system.
    • Phase 3 (Issue Phase 3, Task 16: Format Constants #29): After live server testing revealed 52N returns CURIEs, constants.ts was created with 10 entries (CURIEs + full URIs) as an internal recognition vocabulary. Same name was used without noticing the collision.

    4. The actual classification logic uses neither array directly

    geojson.ts uses a more robust toSosaLocalName() function that strips namespace prefixes, handling both forms inherently — matching against local name sets like Set(['System', 'Sensor', ...]). Neither SystemTypeUris array feeds directly into classification.

    Implications for This Issue

    The rename approach in this issue is still correct:

    • The constants.ts array serves a real purpose (internal recognition vocabulary for both CURIE and full URI forms)
    • The content must be preserved exactly as-is
    • Only the name needs to change to SYSTEM_TYPE_RECOGNITION_VALUES to reflect its actual purpose
    • The "Scope — What NOT to Touch" section correctly says: "Do NOT consolidate the two into a single definition — they serve different purposes"

    This provenance context should be preserved so future implementers understand why two arrays with overlapping values exist — the content divergence is by design, only the naming collision is technical debt.

    Cross-References

  2. added a commit that references this issue on Feb 25, 2026
    a426e87
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions