Skip to content

Conversation

@edolstra
Copy link
Collaborator

@edolstra edolstra commented Dec 8, 2025

Motivation

In the future, we may want to add other types of active operations (like substitutions or waits for locks). So let's make this an internally tagged enum (in serde terminology) that can be extended later.

Context

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced validation to enforce proper data format requirements for incoming data.
  • Chores

    • Improved data format consistency for system components.

✏️ Tip: You can customize this high-level summary in your review settings.

In the future, we may want to add other types of active operations
(like substitutions or waits for locks). So let's make this an
internally tagged enum (in serde terminology) that can be extended
later.
@coderabbitai
Copy link

coderabbitai bot commented Dec 8, 2025

Walkthrough

The changes add serialization validation to ActiveBuild by introducing a "type" field in JSON. During deserialization, the code verifies the field contains "build" and raises an error if absent or incorrect. During serialization, the field is emitted with value "build". No public API modifications occur.

Changes

Cohort / File(s) Summary
JSON Serialization Validation
src/libstore/active-builds.cc
Added "type" field validation in ActiveBuild::from_json() to enforce discriminant check; throws error if missing or not "build". Added "type" field emission in ActiveBuild::to_json() with constant value "build".

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Straightforward validation logic with a single new field check in deserialization
  • Simple constant field addition in serialization path
  • Verify error handling behavior and error message clarity on type mismatch

Poem

🐰 A type field hops into the stream,
Building blocks now know their dream.
JSON whispers "build" so true,
Validation guards both old and new!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add type field to ActiveBuild record' directly and clearly summarizes the main change: adding a type field to the ActiveBuild record, which matches the core modifications to input/output validation in the implementation.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch nix-ps-user

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

@edolstra edolstra changed the title Nix ps user Add type field to ActiveBuild record Dec 8, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/libstore/active-builds.cc (1)

120-120: LGTM – Type field pairs with validation.

The addition of the "type" field to the JSON output correctly pairs with the deserialization validation at lines 102-104. This is forward-compatible as older readers will simply ignore the additional field.

Optional: Consider extracting the "build" string literal (used here and at line 103) into a named constant to ensure consistency and ease future maintenance.

// At file or namespace scope
static constexpr const char* ACTIVE_BUILD_TYPE = "build";

Then use ACTIVE_BUILD_TYPE at lines 103 and 120.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7bcc712 and 8f739c9.

📒 Files selected for processing (1)
  • src/libstore/active-builds.cc (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build_aarch64-darwin / build
  • GitHub Check: build_x86_64-linux / build
🔇 Additional comments (1)
src/libstore/active-builds.cc (1)

102-104: No action needed—this is not a breaking change.

The "type" field addition does not create a backward compatibility issue. ActiveBuild JSON is used exclusively in the worker protocol's QueryActiveBuilds feature, which is behind a feature flag (featureQueryActiveBuilds). Old clients and daemons that lack this feature will not attempt to deserialize this JSON; they fail earlier with "remote store does not support querying active builds". Since both client and daemon are updated together in the same release, there is no persistent storage or version mismatch concern. The j.at("type") call is appropriate for a required field in a versioned protocol.

Likely an incorrect or invalid review comment.

@github-actions
Copy link

github-actions bot commented Dec 8, 2025

@github-actions github-actions bot temporarily deployed to pull request December 8, 2025 14:54 Inactive
Copy link
Member

@cole-h cole-h left a comment

Choose a reason for hiding this comment

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

LGTM.


ActiveBuild adl_serializer<ActiveBuild>::from_json(const json & j)
{
auto type = j.at("type").get<std::string>();
Copy link
Member

Choose a reason for hiding this comment

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

This could also be used to version (e.g. build-v2 type with different fields) (paraphrased from a convo with Eelco)

@edolstra edolstra added this pull request to the merge queue Dec 8, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 8, 2025
@edolstra edolstra added this pull request to the merge queue Dec 8, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 8, 2025
@cole-h cole-h added this pull request to the merge queue Dec 8, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 8, 2025
@edolstra edolstra added this pull request to the merge queue Dec 8, 2025
Merged via the queue into main with commit 38a9007 Dec 8, 2025
30 checks passed
@edolstra edolstra deleted the nix-ps-user branch December 8, 2025 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants