Skip to content

Consolidate the duplicated helpers across Infrastructure projects #754

Closed

Description

@JSdotNet

Several small helpers exist as verbatim copies across Infrastructure, and one copy has already drifted into a bug (the culture-sensitive timestamp parse, issue #723). Backlog.SharedKernel holds only Results, Handlers and Ai, so there is no natural home yet. Found in the 2026-09-27 repository review.

Context

Verified identical bodies:

  • TrimForMessage three times: AzureFoundryChatClient.cs line 261, AzureFoundryCostClient.cs line 256, AzureFoundryEmbeddingsClient.cs line 125 (all under src/Infrastructure/Backlog.Infrastructure.AzureFoundry).
  • Rfc3339 three times: GitHubActivityBaselineClient.cs line 166, GitHubActivityClient.cs line 1037, ClaudeUsageClient.cs line 366.
  • Timestamp(JsonElement, string) four times (collapsed by Parse GitHub timestamps with the invariant culture in GitHubClient #723 if that lands first).
  • PullRoute, Retired and WatermarkAfter three times each across TaskSyncClient/TaskSyncSession, Sessions/SessionSync* and Annotations/AnnotationSync* in src/Infrastructure/Backlog.Infrastructure.Sync, differing only by route constant or timestamp property.
  • Unavailable/Expired exception factories three times across the Cosmos replicas in src/Infrastructure/Backlog.Infrastructure.Cosmos.
  • OpenAsync plus PRAGMA journal_mode = WAL plus CREATE TABLE IF NOT EXISTS boilerplate three times: SqliteTaskRepository.cs line 268, Inbox/SqliteInboxRepository.cs line 287, Roadmap/SqliteRoadmapPlanRepository.cs line 157, and each runs the DDL on every open.
  1. Add Backlog.SharedKernel/Text (or a per-project Internal static where the helper is truly project-local) for TrimForMessage, Rfc3339 and the timestamp parse.
  2. Make the sync replica's route/retired/watermark trio one generic ReplicaRoutes<T> with a selector.
  3. Extract a SqliteSchema.EnsureAsync(connection, ddl) that runs once per process per path, and one OpenAsync that sets WAL.
  4. Add a test per extracted helper so behaviour is pinned before the copies are deleted.

Route through delivery:flow-code per CLAUDE.md.

Activity

  1. added
    enhancementNew feature or request
    triagedClassified by the issue sweep
    in-progressA worker session is actively working this issue
    on Sep 27, 2026
  2. self-assigned this
    on Sep 30, 2026
  3. JSdotNet commented on Sep 30, 2026

    @JSdotNet
    OwnerAuthor

    The issue sweep opened draft pull request #902 for this issue. Its body lists what could not be proved by a test.

  4. removed
    in-progressA worker session is actively working this issue
    on Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requesttriagedClassified by the issue sweep

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions