---
id: 11196
title: PullRequestService archive-write path refactor for lazy ordinal chunking (#11187 AC4)
state: CLOSED
labels:
  - enhancement
  - ai
  - architecture
assignees: []
createdAt: '2026-05-11T09:17:48Z'
updatedAt: '2026-05-11T12:04:36Z'
githubUrl: 'https://github.com/neomjs/neo/issues/11196'
author: neo-gemini-pro
commentsCount: 0
parentIssue: 11187
subIssues: []
subIssuesCompleted: 0
subIssuesTotal: 0
blockedBy: []
blocking: []
closedAt: '2026-05-11T12:04:36Z'
---
# PullRequestService archive-write path refactor for lazy ordinal chunking (#11187 AC4)

## Context
Part of Epic #11187 Phase 1 execution. We are converging on the Option E''+S architecture for GitHub workflow data archiving: active tiers retain their deterministic ID-range chunking, while archive tiers move to a unified root with density-tuned lazy ordinal chunking.

## The Problem
The current `PullRequestService` and `PullRequestSyncer` write archive data to an asymmetric structure (`pr-archive/pr-XXxx/`). They lack a version-layer grouping and use density-blind 100-ID-range chunking for archives, which differs from the newly converged standard.

## The Architectural Reality
- `ai/services/github-workflow/PullRequestService.mjs` handles file operations for Pull Requests.
- The active tier must retain `LocalFileService` deterministic `Math.floor(id/100)*100` routing for O(1) lookups.
- The archive tier must switch to using the new `archivePath()` helper (AC2) pointing to the unified `archiveRoot` specified in the configuration (AC1).

## The Fix
Refactor `PullRequestService` to direct archived Pull Requests to `archive/pulls/vN.M.K/` using the lazy ordinal chunking helper. Ensure the active write path strictly preserves the `pr-XXxx` ID-range semantic.

## Contract Ledger Matrix

| Target Surface | Source of Authority | Proposed Behavior | Fallback | Docs | Evidence |
|---|---|---|---|---|---|
| `PullRequestService` archive paths | Epic #11187 | Routes to `archive/pulls/vN.M.K/{flat|chunk-N}/` | N/A | Inline code comments | Unit test verifying active vs archive pathing |

## Acceptance Criteria
- [ ] Ensure active-tier PR writes continue to use the deterministic `pr-XXxx` ID-range chunking.
- [ ] Refactor archive-tier PR writes to use the new `archivePath()` helper.
- [ ] Ensure `pr-archive/` references are removed from `PullRequestService` in favor of dynamic `archiveRoot` usage for the archive tier.

## Out of Scope
- Actually migrating existing `pr-archive/` data (Phase 3).
- Modifying `IssueService` (AC3) or `DiscussionService` (AC5).
- Any modifications to the `archivePath` helper itself (AC2).

## Avoided Traps
- Changing the active tier to ordinal chunking. As validated in Epic #11187, active-tier ordinal chunking destroys O(1) lookups. Active-tier PRs MUST retain `pr-XXxx` logic.

## Origin Session ID
Origin Session ID: 57502eb2-7f7b-4b9b-a849-49f016b08c95
Retrieval Hint: "Epic 11187 Phase 1 PullRequestService Refactor"

## Timeline

- 2026-05-11T09:17:50Z @neo-gemini-pro added the `enhancement` label
- 2026-05-11T09:17:50Z @neo-gemini-pro added the `ai` label
- 2026-05-11T09:17:51Z @neo-gemini-pro added the `architecture` label
- 2026-05-11T09:18:07Z @neo-gemini-pro added parent issue #11187
- 2026-05-11T09:20:56Z @neo-opus-ada cross-referenced by #11198
- 2026-05-11T09:51:06Z @neo-gemini-pro cross-referenced by PR #11199
- 2026-05-11T09:58:39Z @neo-opus-ada cross-referenced by #10164
- 2026-05-11T12:04:36Z @tobiu closed this issue

