Skip to content

feat(ncps): convert fsck.go to Ent - #1212

Merged
kalbasit merged 1 commit into
mainfrom
feat-ncps-fsck-to-ent
May 23, 2026
Merged

kalbasit merged 1 commit into
mainfrom
feat-ncps-fsck-to-ent

Conversation

@kalbasit

Copy link
Copy Markdown
Owner

§11.6 third batch: rewrite pkg/ncps/fsck.go to use the Ent fluent API on
*database.Client for every direct query, update, and delete. The legacy
database.Querier parameter is preserved on each helper signature so CLI
plumbing keeps compiling; only the call sites change.

Notable changes:

  • fsckResults now holds *ent.NarInfo, *ent.NarFile, *ent.Chunk slices.
  • "Narinfos without nar_files" / "Orphaned nar_files" / "Orphaned chunks"
    use Not(HasXxx())/HasXxx() predicates over the junction edges.
  • CDC size-mismatch (file_size != nar_size where total_chunks > 0) eager-
    loads NarInfoNarFiles -> Narinfo and compares in-memory because Ent has
    no cross-table column comparison in the predicate API.
  • GetChunksByNarFileID is replaced by a small helper that queries
    NarFileChunk ordered by chunk_index and projects the WithChunk edge.
  • UpdateNarFileVerifiedAt -> NarFile.UpdateOneID(...).SetVerifiedAt(now).

Co-Authored-By: Claude Opus 4.7 [email protected]

@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. enhancement New feature or request go Pull requests that update go code labels May 21, 2026
This was referenced May 21, 2026
@kalbasit

kalbasit commented May 21, 2026 •

Copy link
Copy Markdown
Owner Author

This change is part of the following stack:

Change managed by git-spice.

@kalbasit
kalbasit force-pushed the feat-ncps-migrate-queries-to-ent branch from 4ef99f1 to 5312379 Compare May 22, 2026 21:29
@kalbasit
kalbasit force-pushed the feat-ncps-fsck-to-ent branch from 4a1c647 to aa76a92 Compare May 22, 2026 21:29
kalbasit added a commit that referenced this pull request May 22, 2026
queryCDCNarFilesWithSizeMismatch's `seen` map was redundant: Ent's
All(ctx) returns one row per NarFile, and the inner loop already breaks
after recording the first mismatch, so each NarFile can only be appended
to mismatched once.

Addresses gemini-code-assist comment on PR #1212 (PRRT_kwDONV6tZs6D3P8r).

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@kalbasit
kalbasit force-pushed the feat-ncps-migrate-queries-to-ent branch from 5312379 to 41fd989 Compare May 22, 2026 21:42
@kalbasit
kalbasit force-pushed the feat-ncps-fsck-to-ent branch from aa76a92 to 78e574c Compare May 22, 2026 21:42
kalbasit added a commit that referenced this pull request May 22, 2026
queryCDCNarFilesWithSizeMismatch's `seen` map was redundant: Ent's
All(ctx) returns one row per NarFile, and the inner loop already breaks
after recording the first mismatch, so each NarFile can only be appended
to mismatched once.

Addresses gemini-code-assist comment on PR #1212 (PRRT_kwDONV6tZs6D3P8r).

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@kalbasit
kalbasit force-pushed the feat-ncps-migrate-queries-to-ent branch from 41fd989 to d47eb48 Compare May 22, 2026 21:54
@kalbasit
kalbasit force-pushed the feat-ncps-fsck-to-ent branch from 78e574c to f7e7636 Compare May 22, 2026 21:54
kalbasit added a commit that referenced this pull request May 22, 2026
queryCDCNarFilesWithSizeMismatch's `seen` map was redundant: Ent's
All(ctx) returns one row per NarFile, and the inner loop already breaks
after recording the first mismatch, so each NarFile can only be appended
to mismatched once.

Addresses gemini-code-assist comment on PR #1212 (PRRT_kwDONV6tZs6D3P8r).

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@kalbasit
kalbasit force-pushed the feat-ncps-migrate-queries-to-ent branch from d47eb48 to c6241cf Compare May 22, 2026 23:02
@kalbasit
kalbasit force-pushed the feat-ncps-fsck-to-ent branch from f7e7636 to 1b54800 Compare May 22, 2026 23:02
kalbasit added a commit that referenced this pull request May 22, 2026
queryCDCNarFilesWithSizeMismatch's `seen` map was redundant: Ent's
All(ctx) returns one row per NarFile, and the inner loop already breaks
after recording the first mismatch, so each NarFile can only be appended
to mismatched once.

Addresses gemini-code-assist comment on PR #1212 (PRRT_kwDONV6tZs6D3P8r).

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@kalbasit
kalbasit force-pushed the feat-ncps-migrate-queries-to-ent branch from c6241cf to 26f6a50 Compare May 22, 2026 23:16
@kalbasit
kalbasit force-pushed the feat-ncps-fsck-to-ent branch from 1b54800 to 4f7b9a1 Compare May 22, 2026 23:16
kalbasit added a commit that referenced this pull request May 22, 2026
queryCDCNarFilesWithSizeMismatch's `seen` map was redundant: Ent's
All(ctx) returns one row per NarFile, and the inner loop already breaks
after recording the first mismatch, so each NarFile can only be appended
to mismatched once.

Addresses gemini-code-assist comment on PR #1212 (PRRT_kwDONV6tZs6D3P8r).

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@kalbasit
kalbasit force-pushed the feat-ncps-migrate-queries-to-ent branch from 26f6a50 to 86fef06 Compare May 22, 2026 23:28
@kalbasit
kalbasit force-pushed the feat-ncps-fsck-to-ent branch from 4f7b9a1 to 38fdd71 Compare May 22, 2026 23:28
kalbasit added a commit that referenced this pull request May 22, 2026
queryCDCNarFilesWithSizeMismatch's `seen` map was redundant: Ent's
All(ctx) returns one row per NarFile, and the inner loop already breaks
after recording the first mismatch, so each NarFile can only be appended
to mismatched once.

Addresses gemini-code-assist comment on PR #1212 (PRRT_kwDONV6tZs6D3P8r).

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@kalbasit
kalbasit force-pushed the feat-ncps-migrate-queries-to-ent branch from 86fef06 to c94cf8c Compare May 22, 2026 23:54
@kalbasit
kalbasit force-pushed the feat-ncps-fsck-to-ent branch from 38fdd71 to dd18472 Compare May 22, 2026 23:54
kalbasit added a commit that referenced this pull request May 22, 2026
queryCDCNarFilesWithSizeMismatch's `seen` map was redundant: Ent's
All(ctx) returns one row per NarFile, and the inner loop already breaks
after recording the first mismatch, so each NarFile can only be appended
to mismatched once.

Addresses gemini-code-assist comment on PR #1212 (PRRT_kwDONV6tZs6D3P8r).

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@kalbasit
kalbasit force-pushed the feat-ncps-migrate-queries-to-ent branch from c94cf8c to 82672f6 Compare May 23, 2026 00:07
@kalbasit
kalbasit force-pushed the feat-ncps-fsck-to-ent branch from dd18472 to c83722c Compare May 23, 2026 00:07
kalbasit added a commit that referenced this pull request May 23, 2026
queryCDCNarFilesWithSizeMismatch's `seen` map was redundant: Ent's
All(ctx) returns one row per NarFile, and the inner loop already breaks
after recording the first mismatch, so each NarFile can only be appended
to mismatched once.

Addresses gemini-code-assist comment on PR #1212 (PRRT_kwDONV6tZs6D3P8r).

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@kalbasit
kalbasit force-pushed the feat-ncps-migrate-queries-to-ent branch from 82672f6 to 899306a Compare May 23, 2026 00:35
@kalbasit
kalbasit force-pushed the feat-ncps-fsck-to-ent branch from c83722c to a519808 Compare May 23, 2026 00:35
kalbasit added a commit that referenced this pull request May 23, 2026
queryCDCNarFilesWithSizeMismatch's `seen` map was redundant: Ent's
All(ctx) returns one row per NarFile, and the inner loop already breaks
after recording the first mismatch, so each NarFile can only be appended
to mismatched once.

Addresses gemini-code-assist comment on PR #1212 (PRRT_kwDONV6tZs6D3P8r).

Co-Authored-By: Claude Opus 4.7 <[email protected]>
§11.6 third batch: rewrite pkg/ncps/fsck.go to use the Ent fluent API on
*database.Client for every direct query, update, and delete. The legacy
database.Querier parameter is preserved on each helper signature so CLI
plumbing keeps compiling; only the call sites change.

Notable changes:
* fsckResults now holds *ent.NarInfo, *ent.NarFile, *ent.Chunk slices.
* "Narinfos without nar_files" / "Orphaned nar_files" / "Orphaned chunks"
  use Not(HasXxx())/HasXxx() predicates over the junction edges.
* CDC size-mismatch (file_size != nar_size where total_chunks > 0) eager-
  loads NarInfoNarFiles -> Narinfo and compares in-memory because Ent has
  no cross-table column comparison in the predicate API.
* GetChunksByNarFileID is replaced by a small helper that queries
  NarFileChunk ordered by chunk_index and projects the WithChunk edge.
* UpdateNarFileVerifiedAt -> NarFile.UpdateOneID(...).SetVerifiedAt(now).

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@codecov

codecov Bot commented May 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 5.68%. Comparing base (727d46c) to head (75ea137).

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #1212   +/-   ##
=====================================
  Coverage   5.68%   5.68%           
=====================================
  Files          6       6           
  Lines        387     387           
=====================================
  Hits          22      22           
  Misses       361     361           
  Partials       4       4           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant