Repository navigation
docs(openspec): archive serve-whole-nar-in-flight - #1362
Conversation
|
This change is part of the following stack:
Change managed by git-spice. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (12)
✅ Files skipped from review due to trivial changes (6)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThis PR adds archive proposal/design, detailed inflight NAR staging and CDC/helm/streaming specs, and a tasks checklist describing implementation steps and rollout for a flag-gated cross-pod “in-flight NAR” staging mechanism. ChangesArchive Design & Proposal
Production Specification Updates
Possibly Related Issues
Possibly Related PRs
Estimated Code Review Effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
a628e01 to
25ab29a
Compare
|
Related Knowledge 1 document with suggested updates is ready for review. kalbasit's Space Cache and Storage Configuration FlagsView Suggested Changes@@ -525,6 +525,50 @@
- Otherwise, the NAR is skipped
This allows fsck to focus resources on files that haven't been verified recently, while maintaining confidence that all files are periodically checked. The optimization is especially beneficial for large caches with many chunked NARs, where chunk-level verification can be time-consuming.
+
+## In-Flight NAR Staging Configuration
+
+In-flight NAR staging enables serving complete, byte-correct NARs across replicas while the NAR is still being downloaded by the holding replica. When enabled, ncps stages NARs being downloaded to shared storage as ordered, immutable, fixed-size part-objects once cross-pod contention is detected. This allows other replicas to serve the NAR while the download is in progress. The feature is disabled by default and incurs zero overhead until cross-pod contention occurs.
+
+**Flags:**
+
+- `--cache-inflight-staging-enabled` (boolean): Enable in-flight NAR staging. Default: `false`
+ - Environment variable: `CACHE_INFLIGHT_STAGING_ENABLED`
+ - YAML key: `cache.inflight-staging.enabled`
+ - Purpose: When enabled, ncps stages NARs being downloaded to shared storage as ordered, immutable, fixed-size part-objects when cross-pod contention is detected. This allows other replicas to serve complete, byte-correct NARs while the NAR is still being downloaded by the holding replica. When disabled (default), the download and serve paths behave as before with no staging overhead.
+
+- `--cache-inflight-staging-part-size` (size in bytes): Fixed part size for staging part-objects. Default: `8 MiB`
+ - Environment variable: `CACHE_INFLIGHT_STAGING_PART_SIZE`
+ - YAML key: `cache.inflight-staging.part-size`
+ - Purpose: Configures the fixed part size for staging part-objects when in-flight NAR staging is active. The holder writes the NAR to shared storage as ordered, immutable parts of this size, backfilling already-downloaded bytes and appending further parts as bytes arrive.
+
+- `--cache-inflight-staging-retention` (duration): Grace period for retaining staging part-objects after completion. Default: configurable
+ - Environment variable: `CACHE_INFLIGHT_STAGING_RETENTION`
+ - YAML key: `cache.inflight-staging.retention`
+ - Purpose: Sets the grace period for retaining staging part-objects after the NAR's final representation (whole file or chunks) is committed. Staging part-objects and their staging_state record are garbage-collected after this retention period elapses, allowing in-flight readers to drain before deletion.
+
+**Behavior:**
+
+When in-flight staging is enabled, staging activates only when cross-pod contention is detected. A replica holding the download lock begins staging after it observes a cross-pod waiter for the same NAR hash. Replicas using the local (non-distributed) locker never stage, since no cross-pod waiter can exist. The holder writes the NAR to shared storage as ordered, immutable, fixed-size part-objects, first backfilling all already-downloaded bytes starting from offset zero, then appending further parts as bytes arrive. Waiting replicas tail these staging parts to reassemble and serve a complete, byte-correct NAR, regardless of whether CDC is disabled, lazy, or eager.
+
+During the eager-CDC chunking window (`total_chunks == 0`), when in-flight staging parts are available for a NAR hash, the read path prefers serving from the staging parts over progressive chunk streaming. Progressive chunk streaming remains the fallback used only when no staging parts are present.
+
+**CLI Example:**
+```bash
+ncps serve \
+ --cache-inflight-staging-enabled \
+ --cache-inflight-staging-part-size 8388608 \
+ --cache-inflight-staging-retention 1h
+```
+
+**YAML Example:**
+```yaml
+cache:
+ inflight-staging:
+ enabled: true
+ part-size: 8388608 # 8 MiB
+ retention: 1h
+```
## Summary Table of Storage Flags
| Purpose | CLI Flag | YAML Key | Helm Value | Required |
@@ -538,6 +582,9 @@
| S3 secret key | `--cache-storage-s3-secret-access-key`| `cache.storage.s3.secret-access-key` | N/A | Yes** |
| S3 force path style | `--cache-storage-s3-force-path-style` | `cache.storage.s3.force-path-style` | N/A | No |
| LRU schedule timezone | `--cache-lru-schedule-timezone` | `cache.lru.schedule.timezone` | N/A | No |
+| In-flight staging enabled | `--cache-inflight-staging-enabled` | `cache.inflight-staging.enabled` | N/A | No (default: `false`) |
+| In-flight staging part size | `--cache-inflight-staging-part-size` | `cache.inflight-staging.part-size` | N/A | No (default: `8 MiB`) |
+| In-flight staging retention | `--cache-inflight-staging-retention` | `cache.inflight-staging.retention` | N/A | No |
| CDC lazy recovery schedule | `--cache-cdc-lazy-recovery-schedule` | `cache.cdc.lazy-recovery-schedule` | `config.cdc.lazyRecoverySchedule` | No (default: `@every 5m`) |
| CDC lazy recovery batch size | `--cache-cdc-lazy-recovery-batch-size` | `cache.cdc.lazy-recovery-batch-size` | `config.cdc.lazyRecoveryBatchSize` | No (default: `100`) |
| CDC lazy cleanup schedule | `--cache-cdc-lazy-cleanup-schedule` | `cache.cdc.lazy-cleanup-schedule` | `config.cdc.lazyCleanupSchedule` | No (default: `@every 1h`) | |
3d58a1f to
011a449
Compare
There was a problem hiding this comment.
Code Review
This pull request introduces a contention-activated in-flight staging copy of NARs in shared storage to enable cross-pod serving during active downloads across all CDC modes, resolving issues #660 and #1289. It implements database-backed staging_state tracking, ordered immutable part-object storage, holder-side activation/backfill, and reader-side tailing. Additionally, the Helm chart's HA validation is updated to accept either CDC or in-flight staging, and the obsolete iLoveTimeouts bypass flag is removed. Feedback on the documentation highlights a contradiction in the proposal regarding whether the iLoveTimeouts bypass flag is retained or removed.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@openspec/changes/archive/2026-06-07-serve-whole-nar-in-flight/design.md`:
- Line 70: Update the design text to match the task contract's liveness
criteria: change the sweep selection description to use staging_state.updated_at
staleness as the primary holder-death detection criterion (with
staging_state.created_at as a fallback), and keep status and
inflight-staging-retention grace handling unchanged; refer to the existing terms
staging_state.updated_at, staging_state.created_at, status, and
inflight-staging-retention when editing the sentence about the periodic sweep.
In `@openspec/changes/archive/2026-06-07-serve-whole-nar-in-flight/proposal.md`:
- Line 23: The capability text contradicts itself: `iLoveTimeouts` is described
as "stays as the risk-accept bypass" on the `helm-ha-staging-validation` line
while earlier the proposal removes `iLoveTimeouts`; update the proposal so the
`helm-ha-staging-validation` capability definition consistently reflects removal
of `iLoveTimeouts` (or explicitly state it's retained) and align the
operator/migration guidance accordingly—edit the `helm-ha-staging-validation`
sentence to either remove the reference to `iLoveTimeouts` or change it to
explain how CDC and in-flight staging satisfy the HA guard without relying on
`iLoveTimeouts`, and ensure any mentions of `iLoveTimeouts` elsewhere (e.g.,
capability list) match this decision.
In
`@openspec/changes/archive/2026-06-07-serve-whole-nar-in-flight/specs/inflight-nar-staging/spec.md`:
- Around line 73-74: Update the orphan-sweep requirement to use the
holder-liveness signal based on staging_state.updated_at staleness (with
staging_state.created_at as a fallback) rather than only
staging_state.created_at and status; modify the normative sentence that
currently says "keyed off `staging_state.created_at` and `status`" to state that
the periodic sweep SHALL reclaim staging records whose holder died by checking
`staging_state.updated_at` for staleness (falling back to
`staging_state.created_at` when `updated_at` is absent) and `status`, and ensure
mention of the configurable retention window
(`--cache-inflight-staging-retention`) remains intact.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 9b459565-1bf0-45f5-8fcf-4785f5995569
📒 Files selected for processing (12)
openspec/changes/archive/2026-06-07-serve-whole-nar-in-flight/.openspec.yamlopenspec/changes/archive/2026-06-07-serve-whole-nar-in-flight/design.mdopenspec/changes/archive/2026-06-07-serve-whole-nar-in-flight/proposal.mdopenspec/changes/archive/2026-06-07-serve-whole-nar-in-flight/specs/cdc-chunking/spec.mdopenspec/changes/archive/2026-06-07-serve-whole-nar-in-flight/specs/helm-ha-staging-validation/spec.mdopenspec/changes/archive/2026-06-07-serve-whole-nar-in-flight/specs/inflight-nar-staging/spec.mdopenspec/changes/archive/2026-06-07-serve-whole-nar-in-flight/specs/nar-concurrent-streaming/spec.mdopenspec/changes/archive/2026-06-07-serve-whole-nar-in-flight/tasks.mdopenspec/specs/cdc-chunking/spec.mdopenspec/specs/helm-ha-staging-validation/spec.mdopenspec/specs/inflight-nar-staging/spec.mdopenspec/specs/nar-concurrent-streaming/spec.md
25ab29a to
78c0fc1
Compare
Address review feedback on PR #1362: - proposal.md capability list said "iLoveTimeouts stays as the risk-accept bypass", contradicting the BREAKING removal stated earlier in the same file. Corrected to "no bypass (iLoveTimeouts is removed)" (PRRT_kwDONV6tZs6Hr3mh, PRRT_kwDONV6tZs6Hsj6u). - design.md D7 and the inflight-nar-staging spec (both the archived delta and the synced main spec) described the orphan sweep as keyed off staging_state.created_at; aligned them with the implementation, which keys off updated_at staleness (created_at fallback) since a live holder advances updated_at as it stages (PRRT_kwDONV6tZs6Hsj6s, PRRT_kwDONV6tZs6Hsj6v). Co-Authored-By: Claude Opus 4.8 <[email protected]>
Address review feedback on PR #1362: - proposal.md capability list said "iLoveTimeouts stays as the risk-accept bypass", contradicting the BREAKING removal stated earlier in the same file. Corrected to "no bypass (iLoveTimeouts is removed)" (PRRT_kwDONV6tZs6Hr3mh, PRRT_kwDONV6tZs6Hsj6u). - design.md D7 and the inflight-nar-staging spec (both the archived delta and the synced main spec) described the orphan sweep as keyed off staging_state.created_at; aligned them with the implementation, which keys off updated_at staleness (created_at fallback) since a live holder advances updated_at as it stages (PRRT_kwDONV6tZs6Hsj6s, PRRT_kwDONV6tZs6Hsj6v). Co-Authored-By: Claude Opus 4.8 <[email protected]>
257ff75 to
cb18d0e
Compare
f390ef0 to
34ea258
Compare
Address review feedback on PR #1362: - proposal.md capability list said "iLoveTimeouts stays as the risk-accept bypass", contradicting the BREAKING removal stated earlier in the same file. Corrected to "no bypass (iLoveTimeouts is removed)" (PRRT_kwDONV6tZs6Hr3mh, PRRT_kwDONV6tZs6Hsj6u). - design.md D7 and the inflight-nar-staging spec (both the archived delta and the synced main spec) described the orphan sweep as keyed off staging_state.created_at; aligned them with the implementation, which keys off updated_at staleness (created_at fallback) since a live holder advances updated_at as it stages (PRRT_kwDONV6tZs6Hsj6s, PRRT_kwDONV6tZs6Hsj6v). Co-Authored-By: Claude Opus 4.8 <[email protected]>
cb18d0e to
6bb5a90
Compare
34ea258 to
f2b17f2
Compare
Address review feedback on PR #1362: - proposal.md capability list said "iLoveTimeouts stays as the risk-accept bypass", contradicting the BREAKING removal stated earlier in the same file. Corrected to "no bypass (iLoveTimeouts is removed)" (PRRT_kwDONV6tZs6Hr3mh, PRRT_kwDONV6tZs6Hsj6u). - design.md D7 and the inflight-nar-staging spec (both the archived delta and the synced main spec) described the orphan sweep as keyed off staging_state.created_at; aligned them with the implementation, which keys off updated_at staleness (created_at fallback) since a live holder advances updated_at as it stages (PRRT_kwDONV6tZs6Hsj6s, PRRT_kwDONV6tZs6Hsj6v). Co-Authored-By: Claude Opus 4.8 <[email protected]>
6bb5a90 to
88c0f32
Compare
f2b17f2 to
5225aea
Compare
88c0f32 to
b1ceb92
Compare
Address review feedback on PR #1362: - proposal.md capability list said "iLoveTimeouts stays as the risk-accept bypass", contradicting the BREAKING removal stated earlier in the same file. Corrected to "no bypass (iLoveTimeouts is removed)" (PRRT_kwDONV6tZs6Hr3mh, PRRT_kwDONV6tZs6Hsj6u). - design.md D7 and the inflight-nar-staging spec (both the archived delta and the synced main spec) described the orphan sweep as keyed off staging_state.created_at; aligned them with the implementation, which keys off updated_at staleness (created_at fallback) since a live holder advances updated_at as it stages (PRRT_kwDONV6tZs6Hsj6s, PRRT_kwDONV6tZs6Hsj6v). Co-Authored-By: Claude Opus 4.8 <[email protected]>
5225aea to
bb728ce
Compare
Address review feedback on PR #1362: - proposal.md capability list said "iLoveTimeouts stays as the risk-accept bypass", contradicting the BREAKING removal stated earlier in the same file. Corrected to "no bypass (iLoveTimeouts is removed)" (PRRT_kwDONV6tZs6Hr3mh, PRRT_kwDONV6tZs6Hsj6u). - design.md D7 and the inflight-nar-staging spec (both the archived delta and the synced main spec) described the orphan sweep as keyed off staging_state.created_at; aligned them with the implementation, which keys off updated_at staleness (created_at fallback) since a live holder advances updated_at as it stages (PRRT_kwDONV6tZs6Hsj6s, PRRT_kwDONV6tZs6Hsj6v). Co-Authored-By: Claude Opus 4.8 <[email protected]>
b1ceb92 to
44f7276
Compare
bb728ce to
0698e7f
Compare
Address review feedback on PR #1362: - proposal.md capability list said "iLoveTimeouts stays as the risk-accept bypass", contradicting the BREAKING removal stated earlier in the same file. Corrected to "no bypass (iLoveTimeouts is removed)" (PRRT_kwDONV6tZs6Hr3mh, PRRT_kwDONV6tZs6Hsj6u). - design.md D7 and the inflight-nar-staging spec (both the archived delta and the synced main spec) described the orphan sweep as keyed off staging_state.created_at; aligned them with the implementation, which keys off updated_at staleness (created_at fallback) since a live holder advances updated_at as it stages (PRRT_kwDONV6tZs6Hsj6s, PRRT_kwDONV6tZs6Hsj6v). Co-Authored-By: Claude Opus 4.8 <[email protected]>
44f7276 to
037682c
Compare
0698e7f to
da1ab82
Compare
Address review feedback on PR #1362: - proposal.md capability list said "iLoveTimeouts stays as the risk-accept bypass", contradicting the BREAKING removal stated earlier in the same file. Corrected to "no bypass (iLoveTimeouts is removed)" (PRRT_kwDONV6tZs6Hr3mh, PRRT_kwDONV6tZs6Hsj6u). - design.md D7 and the inflight-nar-staging spec (both the archived delta and the synced main spec) described the orphan sweep as keyed off staging_state.created_at; aligned them with the implementation, which keys off updated_at staleness (created_at fallback) since a live holder advances updated_at as it stages (PRRT_kwDONV6tZs6Hsj6s, PRRT_kwDONV6tZs6Hsj6v). Co-Authored-By: Claude Opus 4.8 <[email protected]>
037682c to
c006644
Compare
Address review feedback on PR #1362: - proposal.md capability list said "iLoveTimeouts stays as the risk-accept bypass", contradicting the BREAKING removal stated earlier in the same file. Corrected to "no bypass (iLoveTimeouts is removed)" (PRRT_kwDONV6tZs6Hr3mh, PRRT_kwDONV6tZs6Hsj6u). - design.md D7 and the inflight-nar-staging spec (both the archived delta and the synced main spec) described the orphan sweep as keyed off staging_state.created_at; aligned them with the implementation, which keys off updated_at staleness (created_at fallback) since a live holder advances updated_at as it stages (PRRT_kwDONV6tZs6Hsj6s, PRRT_kwDONV6tZs6Hsj6v). Co-Authored-By: Claude Opus 4.8 <[email protected]>
c006644 to
9b952b7
Compare
Final branch of the stack (group 14). Archives the OpenSpec change serve-whole-nar-in-flight to openspec/changes/archive/ and syncs its delta specs into the main specs: - New capabilities: inflight-nar-staging (6 requirements) and helm-ha-staging-validation (3 requirements). - cdc-chunking: ADDED read-path precedence — prefer in-flight staging over progressive chunk streaming during the chunking window. - nar-concurrent-streaming: MODIFIED the lock-loss requirement to include serving from in-flight staging, plus the staging-serve scenario. All implementation tasks (groups 1-13) are complete and verified; this is the only branch that commits openspec/. openspec validate --specs passes (38/38).
Address review feedback on PR #1362: - proposal.md capability list said "iLoveTimeouts stays as the risk-accept bypass", contradicting the BREAKING removal stated earlier in the same file. Corrected to "no bypass (iLoveTimeouts is removed)" (PRRT_kwDONV6tZs6Hr3mh, PRRT_kwDONV6tZs6Hsj6u). - design.md D7 and the inflight-nar-staging spec (both the archived delta and the synced main spec) described the orphan sweep as keyed off staging_state.created_at; aligned them with the implementation, which keys off updated_at staleness (created_at fallback) since a live holder advances updated_at as it stages (PRRT_kwDONV6tZs6Hsj6s, PRRT_kwDONV6tZs6Hsj6v). Co-Authored-By: Claude Opus 4.8 <[email protected]>
9b952b7 to
a272a5b
Compare
Final branch of the stack (group 14). Archives the OpenSpec change
serve-whole-nar-in-flight to openspec/changes/archive/ and syncs its delta
specs into the main specs:
helm-ha-staging-validation (3 requirements).
progressive chunk streaming during the chunking window.
serving from in-flight staging, plus the staging-serve scenario.
All implementation tasks (groups 1-13) are complete and verified; this is the
only branch that commits openspec/. openspec validate --specs passes (38/38).