Context
Part of Epic #11187 Phase 1 execution. We are converging on the Option E''+S architecture for GitHub workflow data archiving: discussions need to be collapsed to a flat structure in the active tier, and use the new lazy ordinal chunking in the archive tier.
The Problem
The current DiscussionService and DiscussionSyncer write to sparse XXxx directories because the type-density for discussions is very low (~68 total items). A 100-ID chunking model produces 1-5 item folders, which is a structural anti-pattern. Moreover, no formal discussion-archive/ layer currently exists.
The Architectural Reality
ai/services/github-workflow/DiscussionService.mjs handles file operations for Discussions.
- The active tier must abandon sparse
XXxx chunking and write directly to a flat discussions/ directory.
- The archive tier must use the new
archivePath() helper (AC2) pointing to the unified archiveRoot specified in the config (AC1). Given the current density, the helper will inherently yield a flat folder (archive/discussions/vN.M.K/), but the hook enables future scaling.
LocalFileService.mjs currently lacks native support for discussion lookups (unlike getIssueById), which is now required to resolve the active vs archive tier splits.
The Fix
Refactor DiscussionService to collapse active discussion paths to a flat directory. Wire the archive-write path to use the archivePath() helper, establishing the formal archive destination for discussions. Add getDiscussionById to LocalFileService.mjs to support querying the new dual-tier structure.
Contract Ledger Matrix
| Target Surface |
Source of Authority |
Proposed Behavior |
Fallback |
Docs |
Evidence |
DiscussionService active paths |
Epic #11187 |
Routes to discussions/discussion-NNNN.md (flat) |
N/A |
Inline comments |
Unit tests verifying flat routing |
DiscussionService archive paths |
Epic #11187 |
Routes to `archive/discussions/vN.M.K/{flat |
chunk-N}/` |
N/A |
Inline comments |
LocalFileService.getDiscussionById |
Epic #11187 |
Resolves flat active paths & recursive archive paths |
N/A |
Inline comments |
Verified pathing |
Acceptance Criteria
Out of Scope
- Actually migrating existing
XXxx discussion files to flat structure (Phase 2 AC6).
- Actually creating the historical archive for discussions (Phase 3 AC9).
- Modifying
IssueService (AC3) or PullRequestService (AC4).
Avoided Traps
- Using ordinal chunking for the active tier. Even though we are flattening it, if it ever scales, the active tier must use deterministic ID-range chunking, never insertion-order ordinals. For now, flat is correct for its density.
Origin Session ID
Origin Session ID: 57502eb2-7f7b-4b9b-a849-49f016b08c95
Retrieval Hint: "Epic 11187 Phase 1 DiscussionService Refactor"
Context
Part of Epic #11187 Phase 1 execution. We are converging on the Option E''+S architecture for GitHub workflow data archiving: discussions need to be collapsed to a flat structure in the active tier, and use the new lazy ordinal chunking in the archive tier.
The Problem
The current
DiscussionServiceandDiscussionSyncerwrite to sparseXXxxdirectories because the type-density for discussions is very low (~68 total items). A 100-ID chunking model produces 1-5 item folders, which is a structural anti-pattern. Moreover, no formaldiscussion-archive/layer currently exists.The Architectural Reality
ai/services/github-workflow/DiscussionService.mjshandles file operations for Discussions.XXxxchunking and write directly to a flatdiscussions/directory.archivePath()helper (AC2) pointing to the unifiedarchiveRootspecified in the config (AC1). Given the current density, the helper will inherently yield a flat folder (archive/discussions/vN.M.K/), but the hook enables future scaling.LocalFileService.mjscurrently lacks native support for discussion lookups (unlikegetIssueById), which is now required to resolve the active vs archive tier splits.The Fix
Refactor
DiscussionServiceto collapse active discussion paths to a flat directory. Wire the archive-write path to use thearchivePath()helper, establishing the formal archive destination for discussions. AddgetDiscussionByIdtoLocalFileService.mjsto support querying the new dual-tier structure.Contract Ledger Matrix
DiscussionServiceactive pathsdiscussions/discussion-NNNN.md(flat)DiscussionServicearchive pathsLocalFileService.getDiscussionByIdAcceptance Criteria
XXxxchunking.archivePath()helper.LocalFileService.getDiscussionByIdto correctly resolve flat active discussions and fallback to archive resolution.Out of Scope
XXxxdiscussion files to flat structure (Phase 2 AC6).IssueService(AC3) orPullRequestService(AC4).Avoided Traps
Origin Session ID
Origin Session ID: 57502eb2-7f7b-4b9b-a849-49f016b08c95 Retrieval Hint: "Epic 11187 Phase 1 DiscussionService Refactor"