Skip to content

refactor(cache): scope stale-lock orphan query to known candidate IDs - #1229

Merged
kalbasit merged 15 commits into
mainfrom
gs-comments-1208-1228
May 23, 2026
Merged

kalbasit merged 15 commits into
mainfrom
gs-comments-1208-1228

Conversation

@kalbasit

Copy link
Copy Markdown
Owner

refactor(cache): scope stale-lock orphan query to known candidate IDs

Restrict the orphan-check query inside cleanupStaleLockChunks to the chunk
IDs we already know about from staleLockChunks, instead of pulling every
orphan in the database and filtering them in memory. The post-filter
if _, ok := staleByID[oc.ID]; !ok is no longer needed since the query
already returns only candidates.

Addresses gemini-code-assist comment on PR #1209 (PRRT_kwDONV6tZs6D3VF-).

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

refactor(fsck): drop redundant seen map in CDC size-mismatch check

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]

test(database): use t.Context() in freshSchemaSQLite helper

Replace context.Background() with t.Context() so the schema-create call
is bound to the test lifetime. Drops the now-unused context import.

Addresses gemini-code-assist comment from PR #1214
(PRRT_kwDONV6tZs6D3PyX); the original test_schema_parity file was folded
into client_test.go but the same pattern lives in freshSchemaSQLite.

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

refactor(cache): explicit not-found vs error split in migration double-check

After acquiring the migration lock, distinguish ent.IsNotFound (the
expected "not yet migrated" case, fall through to migrate) from other DB
errors (log at warn level instead of silently swallowing). The migration
still attempts on any error so a transient lookup glitch doesn't block
progress; if the DB is genuinely broken the upsert below will surface
the failure.

Addresses gemini-code-assist comment on PR #1216 (PRRT_kwDONV6tZs6D3YoD).

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

refactor(analytics): scan SUM(file_size) into a single sql.NullInt64

Ent's Aggregate(ent.Sum(...)) emits a raw SUM(...) expression without an
alias; scanning into []struct{ Sum sql.NullInt64 `sql:"sum"` } relied
on tag-name resolution that may not match the column header. Scan
positionally into a single sql.NullInt64 instead, which is more robust
and also correctly handles the NULL result that SUM returns on an empty
table.

Addresses gemini-code-assist comments on PR #1217
(PRRT_kwDONV6tZs6D3Um1, PRRT_kwDONV6tZs6D3Um6).

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

docs(database): correct IsNotFoundError comment about delegation

The previous wording referenced a "well-known Ent sentinel below" that
doesn't exist in this file — IsNotFoundError simply delegates to
isEntNotFound (declared in ent_errors.go) which keeps the ent import
isolated to a single file.

Addresses gemini-code-assist comment on PR #1218 (PRRT_kwDONV6tZs6D3WsX).

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

build(formatter): re-include ent/generate.go in the formatter glob

ent/generate.go is hand-written (carries the //go:generate directive)
but the broad ent/*.go exclusion swept it into the codegen-only group.
Add an explicit !ent/generate.go negation so it stays formattable
without re-introducing diff loops against the codegen drift check.

Addresses gemini-code-assist comment on PR #1221 (PRRT_kwDONV6tZs6D3zlq).

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

docs(atlas-sum-check): correct doc comment about exit behavior

The package doc claimed the binary exits non-zero on the first mismatch.
The implementation actually iterates every dialect and only exits at the
end, reporting all offending directories at once. Update the doc to
match.

Addresses gemini-code-assist comment on PR #1222 (PRRT_kwDONV6tZs6D31Je).

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

build(checks): quote $src paths in schema-equivalence preCheck

Quote the path expansions when sourcing the pre/post-check helper
scripts in schema-equivalence-check. Nix store paths don't contain
spaces in practice, but quoting is shell best practice and silences
shellcheck-style nitpicks on the inherited shell content.

Addresses gemini-code-assist comment on PR #1223 (PRRT_kwDONV6tZs6D32tm).

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

docs(claude): use host:port/database in URL examples + clarify migrate down

  • Bring the Common Commands DSN examples in line with the Database section
    by using the full host:port/database placeholder for postgresql/mysql.
  • Replace "there is no migrate down command" with the accurate phrasing:
    the command is implemented (pkg/ncps/migrate.go:107) but returns an
    error pointing at the expand-contract policy.

Addresses gemini-code-assist comments on PR #1224 (PRRT_kwDONV6tZs6D37b-,
PRRT_kwDONV6tZs6D37cD). The third sqlfluff suggestion is intentionally
skipped — migrations/ is sealed by atlas.sum so sqlfluff isn't run
against it, and the only SQL outside migrations/ is already covered by
nix fmt.

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

docs(ent-schema): A2 is the OnDelete invariant, not enum naming

Both .agent/skills/ent-schema/SKILL.md and CLAUDE.md described A2 as the
snake_case enum-type convention, which contradicted cmd/ent-lint/main.go
(line 286+) and openspec/specs/ent-schema-lint/spec.md — both of which
treat A2 as the "OnDelete on edge.From is forbidden" check.

Reword A2 in both docs to match the actual linter invariant, and move
the snake_case enum-type rule into its own section labelled as a
convention enforced by code review until the schema tree gains its
first field.Enum(...) declaration.

Addresses gemini-code-assist comment on PR #1225 (PRRT_kwDONV6tZs6D34eU).

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

docs(changelog): mention task migrations:gen and clarify row-count check

  • Lead with the Taskfile entrypoint (task migrations:gen NAME=...) for
    generating new migrations, since it regenerates the Ent client first
    via task ent:generate. Mention the underlying go run invocation in
    parentheses for users who want the raw command.
  • The schema_migrations adoption verifies row-count consistency, not
    parity — the new table intentionally adds a sentinel row, so the
    expected post-count is preCount + 1. Reword to make that explicit.

Addresses gemini-code-assist comments on PR #1226
(PRRT_kwDONV6tZs6D3756, PRRT_kwDONV6tZs6D376E).

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

docs(openspec): align migration + lint specs with actual implementation

Four wording corrections so the OpenSpec specs match what the code does:

  • Fresh-install seeding text claimed the Go side passes a time.Now()
    to schema_migrations.tstamp. Goose's database.InsertRequest exposes
    only Version, so the tstamp column relies on the database's default
    timestamp function. Reword the Requirement and Scenario lines to
    match.
  • The "Forbidden DDL" scenario claimed cmd/ent-lint SHALL fail on a
    forbidden DDL statement. The linter has not yet been wired up for
    that check (see cmd/ent-lint/main.go:21 deferral comment and the
    scope note already documented in ent-schema-lint/spec.md). Update
    the THEN clause to describe the current manual-review enforcement,
    retaining the future-cmd/ent-lint intent.
  • The example output in ent-schema-lint/spec.md no longer matches
    cmd/ent-lint/main.go:511-515 — the real output includes the source
    line number and a fuller "Ent will fabricate a phantom FK column"
    trailer. Update the example accordingly.

Addresses gemini-code-assist comments on PR #1228
(PRRT_kwDONV6tZs6D4drm, PRRT_kwDONV6tZs6D4dr2, PRRT_kwDONV6tZs6D4dsA,
PRRT_kwDONV6tZs6D4dsG).

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

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label May 21, 2026
kalbasit added a commit that referenced this pull request May 22, 2026
PR #1217 swapped the working []struct{Sum sql.NullInt64 \`sql:"sum"\`}
pattern for &sql.NullInt64, but Ent's Select.Scan calls sql.ScanSlice
which rejects non-slice destinations ("expected slice as an argument"),
so the gauge callback was effectively broken.

Confirmed against a live SQLite database:
- []sql.NullInt64 fails: scanStruct can't map SUM(...) to NullInt64
  fields (the Int64/Valid fields don't carry the tag).
- []*int64 (the suggestion in PR #1229's review) fails on NULL — when
  SUM returns NULL on an empty table the driver errors with
  "converting NULL to int64 is unsupported".
- []struct{ Sum sql.NullInt64 \`sql:"sum"\` } works: scanStruct splits
  the column name at "(" and lowercases the leading token, so
  "SUM(file_size)" → "sum" matches the field tag, and NullInt64
  captures the NULL/empty-table case via sql.Scanner.

This is the same pattern already in use at pkg/cache/cache.go:711.

Addresses gemini-code-assist comments on PR #1229
(PRRT_kwDONV6tZs6D5Lec, PRRT_kwDONV6tZs6D5Lem) — the underlying bug is
fixed even though the specific []*int64 suggestion would not have
worked.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@kalbasit
kalbasit force-pushed the docs-openspec-archive-migrate-to branch from e385a99 to 5bc3549 Compare May 22, 2026 23:02
@kalbasit
kalbasit force-pushed the gs-comments-1208-1228 branch from 4873832 to 2dd750b Compare May 22, 2026 23:02
kalbasit added a commit that referenced this pull request May 22, 2026
For a very large NAR file split into small CDC chunks, the
staleLockChunks slice can hold many thousands of partial-chunk IDs, and
a single Chunk.Query().Where(IDIn(ids...)) would exceed older SQLite's
≤ 999 placeholder ceiling. Batch the IDIn call using the existing
cdcCleanupHashBatchSize (500), matching the HashIn pattern already used
by runCDCDeletedCleanup.

Addresses gemini-code-assist comment on PR #1229 (PRRT_kwDONV6tZs6D5LeW).

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

coderabbitai Bot commented May 23, 2026

Copy link
Copy Markdown

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
{"name":"HttpError","status":401,"request":{"method":"PATCH","url":"https://api.github.com/repos/kalbasit/ncps/issues/comments/4521544527","headers":{"accept":"application/vnd.github.v3+json","user-agent":"octokit.js/0.0.0-development octokit-core.js/7.0.6 Node.js/24","authorization":"token [REDACTED]","content-type":"application/json; charset=utf-8"},"body":{"body":"<!-- This is an auto-generated comment: summarize by coderabbit.ai -->\n<!-- This is an auto-generated comment: rate limited by coderabbit.ai -->\n\n> [!WARNING]\n> ## Review limit reached\n> \n> `@kalbasit`, we couldn't start this review because you've used your available PR reviews for now.\n> \n> Your plan currently allows 5 reviews/hour. Refill in 5 seconds.\n> \n> Your organization has run out of usage credits. Purchase more in the [billing tab](https://app.coderabbit.ai/settings/subscription?tab=usage&tenantId=32762653-f2c3-46d1-950f-ea0cf172d376).\n> \n> <details>\n> <summary>⌛ How to resolve this issue?</summary>\n> \n> After more review capacity refills, a review can be triggered using the `@coderabbitai review` command as a PR comment. Alternatively, push new commits to this PR.\n> \n> We recommend that you space out your commits to avoid hitting the rate limit.\n> \n> </details>\n> \n> \n> <details>\n> <summary>🚦 How do rate limits work?</summary>\n> \n> CodeRabbit enforces hourly rate limits for each developer per organization.\n> \n> Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time.\n> \n> Please see our [FAQ](https://docs.coderabbit.ai/faq) for further information.\n> \n> </details>\n> \n> <details>\n> <summary>ℹ️ Review info</summary>\n> \n> <details>\n> <summary>⚙️ Run configuration</summary>\n> \n> **Configuration used**: Organization UI\n> \n> **Review profile**: CHILL\n> \n> **Plan**: Pro\n> \n> **Run ID**: `e5cb0ba9-534f-407e-a13d-adcbdb7efa97`\n> \n> </details>\n> \n> <details>\n> <summary>📥 Commits</summary>\n> \n> Reviewing files that changed from the base of the PR and between 2390284c7eca9476a790b80e833d460f790564a0 and 7e5619916036aacef0df04f53882e7cafbcf8708.\n> \n> </details>\n> \n> <details>\n> <summary>📒 Files selected for processing (13)</summary>\n> \n> * `.agent/skills/ent-schema/SKILL.md`\n> * `CHANGELOG.md`\n> * `CLAUDE.md`\n> * `cmd/atlas-sum-check/main.go`\n> * `nix/checks/flake-module.nix`\n> * `nix/formatter/flake-module.nix`\n> * `openspec/specs/database-migrations/spec.md`\n> * `openspec/specs/ent-schema-lint/spec.md`\n> * `pkg/analytics/analytics.go`\n> * `pkg/cache/cache.go`\n> * `pkg/database/client_test.go`\n> * `pkg/database/errors.go`\n> * `pkg/ncps/fsck.go`\n> \n> </details>\n> \n> </details>\n\n<!-- end of auto-generated comment: rate limited by coderabbit.ai -->\n\n<!-- tips_start -->\n\n---\n\n\n\n\n<sub>Comment `@coderabbitai help` to get the list of available commands and usage tips.</sub>\n\n<!-- tips_end -->"},"request":{"retryCount":1,"signal":{}}},"response":{"url":"https://api.github.com/repos/kalbasit/ncps/issues/comments/4521544527","status":401,"headers":{"access-control-allow-origin":"*","access-control-expose-headers":"ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset","connection":"close","content-security-policy":"default-src 'none'","content-type":"application/json; charset=utf-8","date":"Sat, 23 May 2026 06:54:47 GMT","referrer-policy":"origin-when-cross-origin, strict-origin-when-cross-origin","server":"github.com","strict-transport-security":"max-age=31536000; includeSubdomains; preload","vary":"Accept-Encoding, Accept, X-Requested-With","x-content-type-options":"nosniff","x-frame-options":"deny","x-github-media-type":"github.v3; format=json","x-github-request-id":"9F08:AD04C:917442:229E62E:6A114F36","x-xss-protection":"0"},"data":{"message":"Bad credentials","documentation_url":"https://docs.github.com/rest","status":"401"}}}

@kalbasit

Copy link
Copy Markdown
Owner Author

Automated stack merge failed during the rebase step. The merge-stack label has been removed from all PRs in the stack. Please resolve conflicts locally, push, and re-apply the label on the top-most PR to retry. Run: https://github.com/kalbasit/ncps/actions/runs/26326665317

@coderabbitai

coderabbitai Bot commented May 23, 2026

Copy link
Copy Markdown

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
{"name":"HttpError","status":401,"request":{"method":"PATCH","url":"https://api.github.com/repos/kalbasit/ncps/issues/comments/4521544527","headers":{"accept":"application/vnd.github.v3+json","user-agent":"octokit.js/0.0.0-development octokit-core.js/7.0.6 Node.js/24","authorization":"token [REDACTED]","content-type":"application/json; charset=utf-8"},"body":{"body":"<!-- This is an auto-generated comment: summarize by coderabbit.ai -->\n<!-- This is an auto-generated comment: rate limited by coderabbit.ai -->\n\n> [!WARNING]\n> ## Review limit reached\n> \n> `@kalbasit`, we couldn't start this review because you've used your available PR reviews for now.\n> \n> Your plan currently allows 5 reviews/hour. Refill in 6 minutes and 49 seconds.\n> \n> Your organization has run out of usage credits. Purchase more in the [billing tab](https://app.coderabbit.ai/settings/subscription?tab=usage&tenantId=32762653-f2c3-46d1-950f-ea0cf172d376).\n> \n> <details>\n> <summary>⌛ How to resolve this issue?</summary>\n> \n> After more review capacity refills, a review can be triggered using the `@coderabbitai review` command as a PR comment. Alternatively, push new commits to this PR.\n> \n> We recommend that you space out your commits to avoid hitting the rate limit.\n> \n> </details>\n> \n> \n> <details>\n> <summary>🚦 How do rate limits work?</summary>\n> \n> CodeRabbit enforces hourly rate limits for each developer per organization.\n> \n> Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time.\n> \n> Please see our [FAQ](https://docs.coderabbit.ai/faq) for further information.\n> \n> </details>\n> \n> <details>\n> <summary>ℹ️ Review info</summary>\n> \n> <details>\n> <summary>⚙️ Run configuration</summary>\n> \n> **Configuration used**: Organization UI\n> \n> **Review profile**: CHILL\n> \n> **Plan**: Pro\n> \n> **Run ID**: `ca0e590a-9ef9-4b7d-9b67-fec2aab00df1`\n> \n> </details>\n> \n> <details>\n> <summary>📥 Commits</summary>\n> \n> Reviewing files that changed from the base of the PR and between dd93eb6833c37838da265503a92382a526072466 and 9caaac1238d861ed094e1c1e620fe3b09bc256c5.\n> \n> </details>\n> \n> <details>\n> <summary>📒 Files selected for processing (13)</summary>\n> \n> * `.agent/skills/ent-schema/SKILL.md`\n> * `CHANGELOG.md`\n> * `CLAUDE.md`\n> * `cmd/atlas-sum-check/main.go`\n> * `nix/checks/flake-module.nix`\n> * `nix/formatter/flake-module.nix`\n> * `openspec/specs/database-migrations/spec.md`\n> * `openspec/specs/ent-schema-lint/spec.md`\n> * `pkg/analytics/analytics.go`\n> * `pkg/cache/cache.go`\n> * `pkg/database/client_test.go`\n> * `pkg/database/errors.go`\n> * `pkg/ncps/fsck.go`\n> \n> </details>\n> \n> </details>\n\n<!-- end of auto-generated comment: rate limited by coderabbit.ai -->\n\n<!-- tips_start -->\n\n---\n\n\n\n\n<sub>Comment `@coderabbitai help` to get the list of available commands and usage tips.</sub>\n\n<!-- tips_end -->"},"request":{"retryCount":1,"signal":{}}},"response":{"url":"https://api.github.com/repos/kalbasit/ncps/issues/comments/4521544527","status":401,"headers":{"access-control-allow-origin":"*","access-control-expose-headers":"ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset","connection":"close","content-security-policy":"default-src 'none'","content-type":"application/json; charset=utf-8","date":"Sat, 23 May 2026 15:05:38 GMT","referrer-policy":"origin-when-cross-origin, strict-origin-when-cross-origin","server":"github.com","strict-transport-security":"max-age=31536000; includeSubdomains; preload","vary":"Accept-Encoding, Accept, X-Requested-With","x-content-type-options":"nosniff","x-frame-options":"deny","x-github-media-type":"github.v3; format=json","x-github-request-id":"3F8E:17A09D:AD978A:29BE728:6A11C242","x-xss-protection":"0"},"data":{"message":"Bad credentials","documentation_url":"https://docs.github.com/rest","status":"401"}}}

kalbasit and others added 15 commits May 23, 2026 17:39
Restrict the orphan-check query inside cleanupStaleLockChunks to the chunk
IDs we already know about from staleLockChunks, instead of pulling every
orphan in the database and filtering them in memory. The post-filter
`if _, ok := staleByID[oc.ID]; !ok` is no longer needed since the query
already returns only candidates.

Addresses gemini-code-assist comment on PR #1209 (PRRT_kwDONV6tZs6D3VF-).

Co-Authored-By: Claude Opus 4.7 <[email protected]>
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]>
Replace context.Background() with t.Context() so the schema-create call
is bound to the test lifetime. Drops the now-unused context import.

Addresses gemini-code-assist comment from PR #1214
(PRRT_kwDONV6tZs6D3PyX); the original test_schema_parity file was folded
into client_test.go but the same pattern lives in freshSchemaSQLite.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
…e-check

After acquiring the migration lock, distinguish ent.IsNotFound (the
expected "not yet migrated" case, fall through to migrate) from other DB
errors (log at warn level instead of silently swallowing). The migration
still attempts on any error so a transient lookup glitch doesn't block
progress; if the DB is genuinely broken the upsert below will surface
the failure.

Addresses gemini-code-assist comment on PR #1216 (PRRT_kwDONV6tZs6D3YoD).

Co-Authored-By: Claude Opus 4.7 <[email protected]>
Ent's Aggregate(ent.Sum(...)) emits a raw SUM(...) expression without an
alias; scanning into []struct{ Sum sql.NullInt64 \`sql:"sum"\` } relied
on tag-name resolution that may not match the column header. Scan
positionally into a single sql.NullInt64 instead, which is more robust
and also correctly handles the NULL result that SUM returns on an empty
table.

Addresses gemini-code-assist comments on PR #1217
(PRRT_kwDONV6tZs6D3Um1, PRRT_kwDONV6tZs6D3Um6).

Co-Authored-By: Claude Opus 4.7 <[email protected]>
The previous wording referenced a "well-known Ent sentinel below" that
doesn't exist in this file — IsNotFoundError simply delegates to
isEntNotFound (declared in ent_errors.go) which keeps the ent import
isolated to a single file.

Addresses gemini-code-assist comment on PR #1218 (PRRT_kwDONV6tZs6D3WsX).

Co-Authored-By: Claude Opus 4.7 <[email protected]>
ent/generate.go is hand-written (carries the //go:generate directive)
but the broad ent/*.go exclusion swept it into the codegen-only group.
Add an explicit !ent/generate.go negation so it stays formattable
without re-introducing diff loops against the codegen drift check.

Addresses gemini-code-assist comment on PR #1221 (PRRT_kwDONV6tZs6D3zlq).

Co-Authored-By: Claude Opus 4.7 <[email protected]>
The package doc claimed the binary exits non-zero on the first mismatch.
The implementation actually iterates every dialect and only exits at the
end, reporting all offending directories at once. Update the doc to
match.

Addresses gemini-code-assist comment on PR #1222 (PRRT_kwDONV6tZs6D31Je).

Co-Authored-By: Claude Opus 4.7 <[email protected]>
Quote the path expansions when sourcing the pre/post-check helper
scripts in schema-equivalence-check. Nix store paths don't contain
spaces in practice, but quoting is shell best practice and silences
shellcheck-style nitpicks on the inherited shell content.

Addresses gemini-code-assist comment on PR #1223 (PRRT_kwDONV6tZs6D32tm).

Co-Authored-By: Claude Opus 4.7 <[email protected]>
…e down

- Bring the Common Commands DSN examples in line with the Database section
  by using the full host:port/database placeholder for postgresql/mysql.
- Replace "there is no migrate down command" with the accurate phrasing:
  the command is implemented (pkg/ncps/migrate.go:107) but returns an
  error pointing at the expand-contract policy.

Addresses gemini-code-assist comments on PR #1224 (PRRT_kwDONV6tZs6D37b-,
PRRT_kwDONV6tZs6D37cD). The third sqlfluff suggestion is intentionally
skipped — migrations/ is sealed by atlas.sum so sqlfluff isn't run
against it, and the only SQL outside migrations/ is already covered by
nix fmt.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
Both .agent/skills/ent-schema/SKILL.md and CLAUDE.md described A2 as the
snake_case enum-type convention, which contradicted cmd/ent-lint/main.go
(line 286+) and openspec/specs/ent-schema-lint/spec.md — both of which
treat A2 as the "OnDelete on edge.From is forbidden" check.

Reword A2 in both docs to match the actual linter invariant, and move
the snake_case enum-type rule into its own section labelled as a
convention enforced by code review until the schema tree gains its
first field.Enum(...) declaration.

Addresses gemini-code-assist comment on PR #1225 (PRRT_kwDONV6tZs6D34eU).

Co-Authored-By: Claude Opus 4.7 <[email protected]>
- Lead with the Taskfile entrypoint (task migrations:gen NAME=...) for
  generating new migrations, since it regenerates the Ent client first
  via task ent:generate. Mention the underlying go run invocation in
  parentheses for users who want the raw command.
- The schema_migrations adoption verifies row-count consistency, not
  parity — the new table intentionally adds a sentinel row, so the
  expected post-count is preCount + 1. Reword to make that explicit.

Addresses gemini-code-assist comments on PR #1226
(PRRT_kwDONV6tZs6D3756, PRRT_kwDONV6tZs6D376E).

Co-Authored-By: Claude Opus 4.7 <[email protected]>
Four wording corrections so the OpenSpec specs match what the code does:

- Fresh-install seeding text claimed the Go side passes a time.Now()
  to schema_migrations.tstamp. Goose's database.InsertRequest exposes
  only Version, so the tstamp column relies on the database's default
  timestamp function. Reword the Requirement and Scenario lines to
  match.
- The "Forbidden DDL" scenario claimed cmd/ent-lint SHALL fail on a
  forbidden DDL statement. The linter has not yet been wired up for
  that check (see cmd/ent-lint/main.go:21 deferral comment and the
  scope note already documented in ent-schema-lint/spec.md). Update
  the THEN clause to describe the current manual-review enforcement,
  retaining the future-cmd/ent-lint intent.
- The example output in ent-schema-lint/spec.md no longer matches
  cmd/ent-lint/main.go:511-515 — the real output includes the source
  line number and a fuller "Ent will fabricate a phantom FK column"
  trailer. Update the example accordingly.

Addresses gemini-code-assist comments on PR #1228
(PRRT_kwDONV6tZs6D4drm, PRRT_kwDONV6tZs6D4dr2, PRRT_kwDONV6tZs6D4dsA,
PRRT_kwDONV6tZs6D4dsG).

Co-Authored-By: Claude Opus 4.7 <[email protected]>
For a very large NAR file split into small CDC chunks, the
staleLockChunks slice can hold many thousands of partial-chunk IDs, and
a single Chunk.Query().Where(IDIn(ids...)) would exceed older SQLite's
≤ 999 placeholder ceiling. Batch the IDIn call using the existing
cdcCleanupHashBatchSize (500), matching the HashIn pattern already used
by runCDCDeletedCleanup.

Addresses gemini-code-assist comment on PR #1229 (PRRT_kwDONV6tZs6D5LeW).

Co-Authored-By: Claude Opus 4.7 <[email protected]>
PR #1217 swapped the working []struct{Sum sql.NullInt64 \`sql:"sum"\`}
pattern for &sql.NullInt64, but Ent's Select.Scan calls sql.ScanSlice
which rejects non-slice destinations ("expected slice as an argument"),
so the gauge callback was effectively broken.

Confirmed against a live SQLite database:
- []sql.NullInt64 fails: scanStruct can't map SUM(...) to NullInt64
  fields (the Int64/Valid fields don't carry the tag).
- []*int64 (the suggestion in PR #1229's review) fails on NULL — when
  SUM returns NULL on an empty table the driver errors with
  "converting NULL to int64 is unsupported".
- []struct{ Sum sql.NullInt64 \`sql:"sum"\` } works: scanStruct splits
  the column name at "(" and lowercases the leading token, so
  "SUM(file_size)" → "sum" matches the field tag, and NullInt64
  captures the NULL/empty-table case via sql.Scanner.

This is the same pattern already in use at pkg/cache/cache.go:711.

Addresses gemini-code-assist comments on PR #1229
(PRRT_kwDONV6tZs6D5Lec, PRRT_kwDONV6tZs6D5Lem) — the underlying bug is
fixed even though the specific []*int64 suggestion would not have
worked.

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.50%. Comparing base (917f946) to head (8c8c24b).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #1229   +/-   ##
=====================================
  Coverage   5.50%   5.50%           
=====================================
  Files          6       6           
  Lines        400     400           
=====================================
  Hits          22      22           
  Misses       374     374           
  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

documentation Improvements or additions to documentation 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