Skip to content

feat(fsck): repair narinfos advertising a non-producible compression - #1395

Merged
kalbasit merged 3 commits into
mainfrom
fix/repair-narinfo-compression-desync
Jun 11, 2026
Merged

kalbasit merged 3 commits into
mainfrom
fix/repair-narinfo-compression-desync

Conversation

@kalbasit

Copy link
Copy Markdown
Owner

Summary

Stacked on #1394. After the serve-side fixes (#1393, #1394) ncps tolerates most narinfo↔nar_file compression drift at serve time by transcoding. The one case it still cannot serve is a narinfo advertising a compression ncps has no compressor for (xz) whose backing NAR is stored otherwise (none/zstd/chunks) — ~59 such pairs on the live cache. These pre-existing drifted rows cannot be healed at request time, so they need a one-shot data repair.

Add repairNarInfoCompressionDesync, invoked from repairFsckIssues under --repair: find narinfos advertising xz with no matching xz nar_file but a backing non-xz nar_file, and rewrite each to the servable none form (URL: nar/<hash>.nar, Compression: none, FileHash/FileSize cleared), reusing the advertised hash so the resolve-by-hash serve path (#1393) decompresses the stored bytes. Healthy narinfos are untouched; the repair is idempotent.

Test plan

  • New TestRepairNarInfoCompressionDesync: a desynced xz-advertised/none-stored narinfo is rewritten to none; a healthy xz/xz pair is untouched; a second run is a no-op.
  • task fmt/lint green; targeted fsck tests pass.

Refs #1392

@kalbasit

kalbasit commented Jun 11, 2026 •

Copy link
Copy Markdown
Owner Author

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jun 11, 2026
@dosubot dosubot Bot added enhancement New feature or request go Pull requests that update go code labels Jun 11, 2026
@coderabbitai

coderabbitai Bot commented Jun 11, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: dd0ab918-8ff8-456f-8eff-c10d1ac90e92

📥 Commits

Reviewing files that changed from the base of the PR and between f4fa370 and 125f3f2.

📒 Files selected for processing (1)
  • pkg/ncps/fsck.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/ncps/fsck.go

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • fsck --repair can now detect and rewrite package metadata that advertises non-producible compression into a servable uncompressed form; repairs are safe and idempotent and report how many entries were rewritten.
  • Documentation

    • Added design, proposal, spec, and task guidance describing repair behavior, goals, safety checks, and verification criteria.
  • Tests

    • Added tests validating detection, correct rewrite, idempotency, and that healthy entries remain unchanged.
  • Chores

    • Added change metadata for tracking.

Walkthrough

This PR adds a repair mechanism to fsck that rewrites narinfo rows advertising non-producible compressions (e.g., xz) to the servable Compression: none form when the backing NAR exists under a different compression, normalizing URL and clearing FileHash/FileSize; the repair is idempotent.

Changes

Narinfo Compression Desync Repair

Layer / File(s) Summary
Specification & Design Requirements
openspec/changes/archive/2026-06-10-repair-narinfo-compression-desync/.openspec.yaml, openspec/changes/archive/2026-06-10-repair-narinfo-compression-desync/design.md, openspec/changes/archive/2026-06-10-repair-narinfo-compression-desync/proposal.md, openspec/changes/archive/2026-06-10-repair-narinfo-compression-desync/specs/narinfo-compression-repair/spec.md, openspec/changes/archive/2026-06-10-repair-narinfo-compression-desync/tasks.md, openspec/specs/narinfo-compression-repair/spec.md
Formal specs, design, and tasks define the repair predicate (xz-advertising narinfos lacking a matching xz nar_file), the rewrite target (Compression: none, normalized URL, cleared FileHash/FileSize), guard conditions, and idempotency expectations for ncps fsck --repair.
Repair Implementation
pkg/ncps/fsck.go
Adds integration into repairFsckIssues, repairNarInfoCompressionDesync to enumerate candidates, and repairOneNarInfoCompressionDesync to perform guarded per-row rewrites to Compression: none while preserving query parameters and clearing file metadata.
Test Validation
pkg/ncps/fsck_narinfo_compression_repair_internal_test.go
TestRepairNarInfoCompressionDesync seeds desynced and healthy fixtures, runs the repair, asserts exactly one narinfo rewritten to none form with normalized URL and cleared metadata, verifies the healthy pair stays unchanged, and confirms idempotency on a second run.

Sequence Diagram

sequenceDiagram
    participant fsck as fsck --repair
    participant repairFsck as repairFsckIssues
    participant repairFunc as repairNarInfoCompressionDesync
    participant db as Database
    participant perRow as repairOneNarInfoCompressionDesync
    fsck->>repairFsck: initiate repair
    repairFsck->>repairFunc: call repair function
    repairFunc->>db: query nar_info with xz compression
    db-->>repairFunc: return desynced narinfos
    loop for each desynced narinfo
        repairFunc->>perRow: reconcile narinfo
        perRow->>db: check xz nar_file exists
        db-->>perRow: no xz file found / backing NAR presence
        perRow->>db: update to Compression: none, normalize URL, clear FileHash/FileSize
        db-->>perRow: narinfo rewritten
        perRow-->>repairFunc: return repaired=true
    end
    repairFunc-->>repairFsck: return count of repairs
    repairFsck-->>fsck: log repair summary
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • kalbasit/ncps#1335: Extends fsck repair flows for narinfo/NAR compression inconsistencies; overlaps in repair approach and normalization logic.
  • kalbasit/ncps#1364: Changes fsck CDC mode detection which affects whether the new repair phase is executed.

Poem

🐰 I found a narinfo, its compression awry,
It shouted "xz!" though the NAR said "none" nearby.
Fsck hopped in kindly, rewrote with a grin,
Cleared hashes and sizes — now the bytes can swim.
One quiet repair, idempotent and neat.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: adding fsck repair functionality for narinfos advertising a non-producible compression (xz), which is the core objective of this PR.
Description check ✅ Passed The description is well-related to the changeset, explaining the problem context, the repair mechanism, and test coverage. It provides meaningful information about what the PR accomplishes.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a one-shot fsck repair mechanism to resolve compression desync issues where a narinfo advertises xz compression but the backing physical NAR is stored under a different compression. These desynced entries are rewritten to the servable 'none' form with cleared FileHash and FileSize fields to allow transparent decompression at serve time. The feedback identifies a potential performance bottleneck in the database query within repairNarInfoCompressionDesync and suggests optimizing the query to filter out healthy xz entries directly in the database, avoiding N+1 query issues.

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.

Comment thread pkg/ncps/fsck.go Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pkg/ncps/fsck.go (1)

564-566: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Compression-desync repair is gated off in normal --repair flows.

At Line [564], fsck exits early when no pre-collected issues exist, so desync-only datasets never reach repairFsckIssues. At Line [1623], repairFsckIssues returns before the new repair when CDC/chunk-store is unavailable, even though this repair is independent of chunk mode.

Suggested fix direction
--- a/pkg/ncps/fsck.go
+++ b/pkg/ncps/fsck.go
@@
-           if results.totalIssues() == 0 {
+           if results.totalIssues() == 0 && !repair {
                return nil
            }
@@
-   if !results.cdcMode || chunkStore == nil {
-       return nil
-   }
+   // Run narinfo compression desync repair regardless of CDC/chunk-store mode.
+   repairedCompression, err := repairNarInfoCompressionDesync(ctx, dbClient)
+   if err != nil {
+       return fmt.Errorf("repair narinfo compression desync: %w", err)
+   }
+   if repairedCompression > 0 {
+       logger.Info().
+           Int("count", repairedCompression).
+           Msg("repaired narinfos advertising a non-producible compression")
+   }
+
+   if !results.cdcMode || chunkStore == nil {
+       return nil
+   }
@@
-   repairedCompression, err := repairNarInfoCompressionDesync(ctx, dbClient)
-   if err != nil {
-       return fmt.Errorf("repair narinfo compression desync: %w", err)
-   }
-
-   if repairedCompression > 0 {
-       logger.Info().
-           Int("count", repairedCompression).
-           Msg("repaired narinfos advertising a non-producible compression")
-   }

Also applies to: 1623-1625, 1718-1730

🤖 Prompt for 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.

In `@pkg/ncps/fsck.go` around lines 564 - 566, The early return in fsck (the check
if results.totalIssues() == 0) prevents compression-desync-only datasets from
reaching repairFsckIssues; remove or change this guard so fsck always invokes
repairFsckIssues (or invoke repairFsckIssues when either totalIssues()>0 OR a
compression-desync condition is present). Inside repairFsckIssues, do not
short-circuit the entire function when CDC/chunk-store is unavailable—separate
the CDC/chunk-store dependent repairs from the compression-desync repair and
ensure the compression-desync repair path still runs even if chunk-store/CDC is
disabled, keeping any chunk-mode checks only around the chunk-dependent code.
🧹 Nitpick comments (1)
pkg/ncps/fsck_narinfo_compression_repair_internal_test.go (1)

19-105: ⚡ Quick win

Add command-path coverage for this repair.

This test validates the helper directly, but not ncps fsck --repair execution. Add an integration case with only compression-desync rows so regressions in command/repair gating are caught.

🤖 Prompt for 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.

In `@pkg/ncps/fsck_narinfo_compression_repair_internal_test.go` around lines 19 -
105, Add a command-path integration test that exercises "ncps fsck --repair"
(instead of directly calling repairNarInfoCompressionDesync) to ensure the CLI
repair gating is covered: create a new test (e.g.,
TestFsckRepairCompressionDesyncCommandPath) that sets up the same
desynced/healthy rows as in TestRepairNarInfoCompressionDesync, then invoke the
CLI entrypoint or command runner used by the ncps fsck code path (the code that
parses args and calls repairNarInfoCompressionDesync) and assert the repaired
count and idempotency just like the helper test; reference
repairNarInfoCompressionDesync, the existing TestRepairNarInfoCompressionDesync
setup for row creation, and the CLI entry function (the fsck command handler /
main command runner) to locate where to call the command.
🤖 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.

Outside diff comments:
In `@pkg/ncps/fsck.go`:
- Around line 564-566: The early return in fsck (the check if
results.totalIssues() == 0) prevents compression-desync-only datasets from
reaching repairFsckIssues; remove or change this guard so fsck always invokes
repairFsckIssues (or invoke repairFsckIssues when either totalIssues()>0 OR a
compression-desync condition is present). Inside repairFsckIssues, do not
short-circuit the entire function when CDC/chunk-store is unavailable—separate
the CDC/chunk-store dependent repairs from the compression-desync repair and
ensure the compression-desync repair path still runs even if chunk-store/CDC is
disabled, keeping any chunk-mode checks only around the chunk-dependent code.

---

Nitpick comments:
In `@pkg/ncps/fsck_narinfo_compression_repair_internal_test.go`:
- Around line 19-105: Add a command-path integration test that exercises "ncps
fsck --repair" (instead of directly calling repairNarInfoCompressionDesync) to
ensure the CLI repair gating is covered: create a new test (e.g.,
TestFsckRepairCompressionDesyncCommandPath) that sets up the same
desynced/healthy rows as in TestRepairNarInfoCompressionDesync, then invoke the
CLI entrypoint or command runner used by the ncps fsck code path (the code that
parses args and calls repairNarInfoCompressionDesync) and assert the repaired
count and idempotency just like the helper test; reference
repairNarInfoCompressionDesync, the existing TestRepairNarInfoCompressionDesync
setup for row creation, and the CLI entry function (the fsck command handler /
main command runner) to locate where to call the command.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: afaa278a-1ffa-4834-99ed-924497000a00

📥 Commits

Reviewing files that changed from the base of the PR and between 4d48899 and 5bc522d.

📒 Files selected for processing (8)
  • openspec/changes/archive/2026-06-10-repair-narinfo-compression-desync/.openspec.yaml
  • openspec/changes/archive/2026-06-10-repair-narinfo-compression-desync/design.md
  • openspec/changes/archive/2026-06-10-repair-narinfo-compression-desync/proposal.md
  • openspec/changes/archive/2026-06-10-repair-narinfo-compression-desync/specs/narinfo-compression-repair/spec.md
  • openspec/changes/archive/2026-06-10-repair-narinfo-compression-desync/tasks.md
  • openspec/specs/narinfo-compression-repair/spec.md
  • pkg/ncps/fsck.go
  • pkg/ncps/fsck_narinfo_compression_repair_internal_test.go

@kalbasit

Copy link
Copy Markdown
Owner Author

Done — narrowed the query with the suggested predicate (advertised xz, has a linked nar_file, no linked xz nar_file) so only the desynced rows are loaded. Kept the per-row repairOneNarInfoCompressionDesync verification (by advertised hash) as a precise re-check before rewriting.

kalbasit added a commit that referenced this pull request Jun 11, 2026
Filter the candidate set in SQL to only desynced rows — advertised xz,
backed by a nar_file, but not backed by an xz nar_file — so a cache with
many healthy xz narinfos loads only the few desynced ones and does no
per-row work for healthy entries. The per-row verification is retained
as a precise re-check before rewriting.

Addresses PR #1395 review thread PRRT_kwDONV6tZs6Ip9J6.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@kalbasit
kalbasit force-pushed the fix/repair-narinfo-compression-desync branch from 5bc522d to 0b7e679 Compare June 11, 2026 00:58
kalbasit added a commit that referenced this pull request Jun 11, 2026
Filter the candidate set in SQL to only desynced rows — advertised xz,
backed by a nar_file, but not backed by an xz nar_file — so a cache with
many healthy xz narinfos loads only the few desynced ones and does no
per-row work for healthy entries. The per-row verification is retained
as a precise re-check before rewriting.

Addresses PR #1395 review thread PRRT_kwDONV6tZs6Ip9J6.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@kalbasit
kalbasit force-pushed the fix/repair-narinfo-compression-desync branch from 0b7e679 to 8ffb231 Compare June 11, 2026 05:14
Base automatically changed from fix/serve-zstd-from-chunks to main June 11, 2026 06:25
kalbasit and others added 2 commits June 11, 2026 06:25
After the serve-side fixes (#1393, serve-zstd-from-chunks) ncps
tolerates most narinfo<->nar_file compression drift at serve time by
transcoding. The one case it still cannot serve is a narinfo
advertising a compression ncps has no compressor for (xz) whose
backing NAR is stored under a different compression (none/zstd/chunks)
-- ~59 such pairs on the live cache. These pre-existing drifted rows
cannot be healed at request time, so they need a one-shot data repair.

Add repairNarInfoCompressionDesync, invoked from repairFsckIssues under
--repair: find narinfos advertising xz with no matching xz nar_file but
a backing non-xz nar_file, and rewrite each to the servable none form
(URL nar/<hash>.nar, Compression: none, FileHash/FileSize cleared),
reusing the advertised hash so the resolve-by-hash serve path (#1393)
decompresses the stored bytes. Healthy narinfos are untouched and the
repair is idempotent.

Refs #1392

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Filter the candidate set in SQL to only desynced rows — advertised xz,
backed by a nar_file, but not backed by an xz nar_file — so a cache with
many healthy xz narinfos loads only the few desynced ones and does no
per-row work for healthy entries. The per-row verification is retained
as a precise re-check before rewriting.

Addresses PR #1395 review thread PRRT_kwDONV6tZs6Ip9J6.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@kalbasit
kalbasit force-pushed the fix/repair-narinfo-compression-desync branch from 8ffb231 to f4fa370 Compare June 11, 2026 06:26
@kalbasit
kalbasit enabled auto-merge (squash) June 11, 2026 06:26

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pkg/ncps/fsck.go (1)

564-566: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

--repair can exit before running the new narinfo compression repair.

Line 564 returns immediately when results.totalIssues() == 0. Because compression-desync rows are not part of fsckResults, repairFsckIssues (and Line 1721) is skipped when this is the only inconsistency, so ncps fsck --repair does nothing for the PR’s target case.

Suggested fix
-			if results.totalIssues() == 0 {
-				return nil
-			}
+			if results.totalIssues() == 0 {
+				// Still run targeted narinfo compression desync repair under --repair.
+				if repair {
+					repairedCompression, err := repairNarInfoCompressionDesync(ctx, dbClient)
+					if err != nil {
+						return fmt.Errorf("repair narinfo compression desync: %w", err)
+					}
+					if repairedCompression > 0 {
+						logger.Info().
+							Int("count", repairedCompression).
+							Msg("repaired narinfos advertising a non-producible compression")
+					}
+				}
+				return nil
+			}
🤖 Prompt for 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.

In `@pkg/ncps/fsck.go` around lines 564 - 566, The early return in the function
that checks if results.totalIssues() == 0 causes repairFsckIssues (and the new
narinfo compression repair logic) to be skipped because compression-desync rows
are not counted in fsckResults; update the control flow so that repairFsckIssues
(or the compression-desync repair path at/near Line 1721) still runs when
compression-desync inconsistencies are present — either by including
compression-desync in results.totalIssues() or by changing the if-condition to
also check a new flag/function (e.g., hasCompressionDesync or
compressionDesyncFound) before returning; ensure the code that calls
repairFsckIssues remains reachable when such desyncs exist.
🧹 Nitpick comments (1)
pkg/ncps/fsck_narinfo_compression_repair_internal_test.go (1)

39-104: ⚡ Quick win

Add one query-preservation assertion to lock the URL rewrite contract.

Current coverage uses empty query strings only. Since the repair intentionally preserves advertised.Query, add a case with a non-empty query and assert it remains after rewriting to Compression:none.

Suggested test tweak
-		SetURL("nar/" + driftedHash + ".nar.xz").
+		SetURL("nar/" + driftedHash + ".nar.xz?download=1").
...
-	assert.Equal(t, "nar/"+driftedHash+".nar", *got.URL, "URL must drop the .xz extension")
+	assert.Equal(t, "nar/"+driftedHash+".nar?download=1", *got.URL, "URL must drop .xz and preserve query")
🤖 Prompt for 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.

In `@pkg/ncps/fsck_narinfo_compression_repair_internal_test.go` around lines 39 -
104, Modify the test to include a non-empty query on the desynced nar_file and
assert it is preserved after repair: when creating the desynced nar_file
(driftedNF) call SetQuery with a non-empty value (e.g. "v=1") instead of
SetQuery(""), run repairNarInfoCompressionDesync(ctx, dbClient), then after
fetching got via dbClient.Ent().NarInfo.Get(ctx, driftedNI.ID) assert that
*got.URL equals "nar/"+driftedHash+".nar?v=1" (i.e. the .xz extension is dropped
but the original query string from the NarFile remains) so the URL rewrite
contract is locked; reference driftedNF, driftedNI, SetQuery and
repairNarInfoCompressionDesync in the change.
🤖 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 `@pkg/ncps/fsck.go`:
- Around line 1816-1818: The existence check for backing currently only tests
any NarFile linked to the narinfo (hasBacking) which is too broad; update the
query that sets hasBacking (the call starting with
dbClient.Ent().NarFile.Query().Where(entnarfile.HasNarInfoNarFilesWith(entnarinfonarfile.NarinfoIDEQ(ni.ID))))
to require a NarFile row that matches the advertised content address (include
the nar file hash and query used by the narinfo) — e.g., add the
entnarfile.HashEQ(ni.Hash) and the appropriate query field predicate (e.g.,
entnarfile.QueryEQ(ni.Query) or equivalent) to the Where clause so you only
treat backing as present when a NarFile with the same hash+query and narinfo_id
exists before rewriting Compression/URL.

---

Outside diff comments:
In `@pkg/ncps/fsck.go`:
- Around line 564-566: The early return in the function that checks if
results.totalIssues() == 0 causes repairFsckIssues (and the new narinfo
compression repair logic) to be skipped because compression-desync rows are not
counted in fsckResults; update the control flow so that repairFsckIssues (or the
compression-desync repair path at/near Line 1721) still runs when
compression-desync inconsistencies are present — either by including
compression-desync in results.totalIssues() or by changing the if-condition to
also check a new flag/function (e.g., hasCompressionDesync or
compressionDesyncFound) before returning; ensure the code that calls
repairFsckIssues remains reachable when such desyncs exist.

---

Nitpick comments:
In `@pkg/ncps/fsck_narinfo_compression_repair_internal_test.go`:
- Around line 39-104: Modify the test to include a non-empty query on the
desynced nar_file and assert it is preserved after repair: when creating the
desynced nar_file (driftedNF) call SetQuery with a non-empty value (e.g. "v=1")
instead of SetQuery(""), run repairNarInfoCompressionDesync(ctx, dbClient), then
after fetching got via dbClient.Ent().NarInfo.Get(ctx, driftedNI.ID) assert that
*got.URL equals "nar/"+driftedHash+".nar?v=1" (i.e. the .xz extension is dropped
but the original query string from the NarFile remains) so the URL rewrite
contract is locked; reference driftedNF, driftedNI, SetQuery and
repairNarInfoCompressionDesync in the change.
🪄 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: 8a8ea059-7e3b-4f1a-8ee9-e1e5e0465a9c

📥 Commits

Reviewing files that changed from the base of the PR and between 8ffb231 and f4fa370.

📒 Files selected for processing (8)
  • openspec/changes/archive/2026-06-10-repair-narinfo-compression-desync/.openspec.yaml
  • openspec/changes/archive/2026-06-10-repair-narinfo-compression-desync/design.md
  • openspec/changes/archive/2026-06-10-repair-narinfo-compression-desync/proposal.md
  • openspec/changes/archive/2026-06-10-repair-narinfo-compression-desync/specs/narinfo-compression-repair/spec.md
  • openspec/changes/archive/2026-06-10-repair-narinfo-compression-desync/tasks.md
  • openspec/specs/narinfo-compression-repair/spec.md
  • pkg/ncps/fsck.go
  • pkg/ncps/fsck_narinfo_compression_repair_internal_test.go
✅ Files skipped from review due to trivial changes (4)
  • openspec/changes/archive/2026-06-10-repair-narinfo-compression-desync/.openspec.yaml
  • openspec/changes/archive/2026-06-10-repair-narinfo-compression-desync/proposal.md
  • openspec/specs/narinfo-compression-repair/spec.md
  • openspec/changes/archive/2026-06-10-repair-narinfo-compression-desync/tasks.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • openspec/changes/archive/2026-06-10-repair-narinfo-compression-desync/specs/narinfo-compression-repair/spec.md

Comment thread pkg/ncps/fsck.go Resolved
The compression-desync repair's backing guard checked for any nar_file
linked to the narinfo, so a stale/mismatched link could pass and rewrite
the narinfo to Compression:none for a hash with no servable bytes (a
404). Require the backing nar_file to match the advertised hash+query
(the xz row is already excluded earlier, so a match is a non-xz row the
serve path can produce none from). Legitimately-backed narinfos are
linked by the relink repair earlier in the same fsck pass.

Addresses PR #1395 review thread PRRT_kwDONV6tZs6Itsvd.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@kalbasit

Copy link
Copy Markdown
Owner Author

Good catch — tightened the backing guard to require a nar_file matching the advertised hash+query (still linked to the narinfo), so a stale/mismatched link can no longer cause a rewrite to a non-servable none URL. The advertised xz row is excluded just above, so a match here is a non-xz row the serve path can produce none from; and the relink repair runs earlier in the same fsck --repair pass, so legitimately-backed narinfos are linked by the time this runs.

@kalbasit
kalbasit merged commit a4712f5 into main Jun 11, 2026
38 checks passed
@kalbasit
kalbasit deleted the fix/repair-narinfo-compression-desync branch June 11, 2026 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request go Pull requests that update go code merge-stack size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant