Skip to content

chore(value): scope ObjectSource.deprecated field to pub(crate)#61

Merged
jdx merged 1 commit intomainfrom
chore/scope-deprecated-field
Apr 26, 2026
Merged

chore(value): scope ObjectSource.deprecated field to pub(crate)#61
jdx merged 1 commit intomainfrom
chore/scope-deprecated-field

Conversation

@jdx
Copy link
Copy Markdown
Owner

@jdx jdx commented Apr 26, 2026

Summary

The deprecated map added in #58 is only read by the evaluator's private field-access helper. Marking the field pub(crate) keeps that working and removes it from pklr's public API.

cargo-semver-checks will still flag this as a break in the strict sense (constructible_struct_adds_private_fieldObjectSource is no longer externally constructible via a struct literal). In practice no one downstream constructs ObjectSource literally — it's an internal-ish struct describing evaluator state — so the plan is to override the release-plz auto-bump and ship 0.4.2 manually instead of 0.5.0 from #59.

Test plan

🤖 Generated with Claude Code


Note

Low Risk
Low risk, single-field visibility change with no runtime behavior impact; only potential risk is breaking external code that constructed or accessed ObjectSource directly.

Overview
Makes ObjectSource.deprecated pub(crate) so deprecation metadata remains usable by the evaluator but is no longer part of the public API (and can’t be read/constructed via struct literals outside the crate).

Reviewed by Cursor Bugbot for commit e960737. Bugbot is set up for automated code reviews on this repo. Configure here.

The `deprecated` map added in #58 is only read by the evaluator's
private field-access helper. Marking the field `pub(crate)` keeps
that intact while removing the field from pklr's public API.

cargo-semver-checks still flags this as a break in the strict sense
(`constructible_struct_adds_private_field`: ObjectSource is no
longer externally constructible via a struct literal). In practice
no one downstream constructs `ObjectSource` literally — it's an
internal-ish struct describing evaluator state — so we override the
release-plz major bump and ship 0.4.2 manually.
@gemini-code-assist
Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 26, 2026

Greptile Summary

Scopes the deprecated field on ObjectSource from pub to pub(crate), removing it from the public API. The companion doc-comment update clearly explains the rationale. The PR description transparently acknowledges the semver implication (constructible_struct_adds_private_field) and the plan to ship 0.4.2 manually.

Confidence Score: 5/5

Safe to merge — single visibility narrowing with no behavioural changes.

The change is a one-line visibility restriction with an updated doc comment. No logic is altered, all 238 tests pass, and clippy is clean. The semver implication is acknowledged and handled intentionally in the release plan.

No files require special attention.

Important Files Changed

Filename Overview
src/value.rs Single field visibility narrowed from pub to pub(crate); doc comment updated accordingly. No logic changes.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[ObjectSource struct] --> B[pub entries: Vec<Entry>]
    A --> C[pub scope: IndexMap]
    A --> D[pub is_open: bool]
    A --> E[pub type_name: Option<String>]
    A --> F["pub(crate) deprecated: IndexMap (was pub)"]
    F --> G[Evaluator — crate-internal reader/writer]
    style F fill:#f9f,stroke:#333
Loading

Reviews (1): Last reviewed commit: "chore(value): scope ObjectSource.depreca..." | Re-trigger Greptile

@jdx jdx mentioned this pull request Apr 26, 2026
@jdx jdx merged commit 04456eb into main Apr 26, 2026
8 checks passed
@jdx jdx deleted the chore/scope-deprecated-field branch April 26, 2026 22:01
jdx added a commit that referenced this pull request Apr 26, 2026
## 🤖 Release

* `pklr`: 0.4.1 → 0.4.2

The `deprecated` field added in
[#58](#58) is scoped to `pub(crate)`
([#61](#61)) so `ObjectSource` no longer
exposes new public surface. cargo-semver-checks still flags the struct
as no-longer-externally-constructible-via-literal, but in practice
nothing downstream constructs `ObjectSource` literally — it's an
internal-ish struct describing evaluator state — so this ships as a
patch release. The release-plz auto-detected major bump is overridden
here manually.

### Changelog

#### Fixed

- *(eval)* make @deprecated lazy — only warn on access
([#58](#58))
- *(value)* scope `ObjectSource.deprecated` field to `pub(crate)`
([#61](#61))

---
This PR was originally opened by
[release-plz](https://github.com/release-plz/release-plz/) as 0.5.0;
manually retargeted to 0.4.2.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Low risk: this PR only updates release metadata (version numbers and
changelog) with no functional code changes.
> 
> **Overview**
> Publishes release `v0.4.2` by bumping the crate version from `0.4.1`
to `0.4.2` in `Cargo.toml`/`Cargo.lock`.
> 
> Updates `CHANGELOG.md` with the `0.4.2` entry noting the fix to make
`@Deprecated` warnings lazy (warn only on access).
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
5ebfa23. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@jdx jdx mentioned this pull request Apr 26, 2026
jdx added a commit to jdx/hk that referenced this pull request Apr 26, 2026
Closes hk discussion #878.

The auto-generated pkl/Builtins.pkl had bindings of the form

  check_byte_order_marker = Builtins["builtins/check_byte_order_marker.pkl"].check_byte_order_marker

whose RHS reads a property annotated @deprecated. With pklr's old
eager handling those warnings fired on every load; even after pklr
0.4.2's lazy @deprecated, the field-access on the deprecated stub
still warns at module-evaluation time because the Builtins.pkl
binding itself performs that access.

Two coordinated changes:

- bump pklr to 0.4.2 (lazy @deprecated, warning fires only on field
  access — see jdx/pklr#58, jdx/pklr#61).
- have scripts/gen_builtins.py special-case the deprecated aliases:
  skip them in the auto-generated loop and emit them as @deprecated
  bindings that point at the canonical byte_order_marker step. The
  Builtins.pkl bindings no longer access a deprecated property at
  load, so the warning only fires when a user references
  Builtins.check_byte_order_marker / .fix_byte_order_marker
  directly — preserving the migration nudge.

End-to-end with HK_PKL_BACKEND=pklr:
- import Builtins.pkl, no use of deprecated aliases → silent.
- use Builtins.check_byte_order_marker → warning fires.
jdx added a commit to jdx/hk that referenced this pull request Apr 26, 2026
…#880)

## Summary

- Closes [discussion #878](#878).
- With `HK_PKL_BACKEND=pklr`, every load of `Builtins.pkl` printed
`[pklr] WARNING: property 'check_byte_order_marker' is deprecated` and
the same for `fix_byte_order_marker`, even when the user's `hk.pkl` did
not reference those aliases.
- Combine the upstream pklr fix with a generator change so the warning
only fires when a user actually references the deprecated aliases.

## Two coordinated changes

1. **Bump `pklr` 0.4.1 → 0.4.2**
([jdx/pklr#58](jdx/pklr#58),
[jdx/pklr#61](jdx/pklr#61)). pklr now treats
`@Deprecated` lazily — the warning fires on field access, not on module
evaluation.
2. **`scripts/gen_builtins.py`**: special-case the deprecated aliases.
Skip them in the auto-loop and emit them as `@Deprecated` bindings that
point at the canonical `byte_order_marker` step. With this,
`Builtins.pkl`'s own bindings no longer access a deprecated property at
load, so even the lazy field-access warning stays silent until the user
explicitly references `Builtins.check_byte_order_marker` /
`.fix_byte_order_marker`.

The deprecated stub files (`pkl/builtins/check_byte_order_marker.pkl`,
`pkl/builtins/fix_byte_order_marker.pkl`) keep their `@Deprecated`
annotations untouched — the migration nudge is preserved for direct
importers.

## Test plan

- [x] `mise run test:cargo` — 145 passed.
- [x] End-to-end with `HK_PKL_BACKEND=pklr`:
- import `Builtins.pkl` without using deprecated aliases → **silent**
(was 2× warnings per load).
- access `Builtins.check_byte_order_marker` → warning fires once per
evaluation.
- [x] `hk` pre-commit hooks pass.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Low risk: changes are limited to a dependency patch bump and
generation/mapping of builtin aliases to reduce deprecation warnings,
with no impact on core hook execution logic beyond alias resolution.
> 
> **Overview**
> Stops `Builtins.pkl` from triggering deprecation warnings on load when
using the `pklr` backend.
> 
> This bumps `pklr` from `0.4.1` to `0.4.2` and updates
`scripts/gen_builtins.py` to *skip* generating deprecated builtin
bindings in the main loop, then re-add them as explicit `@Deprecated`
aliases pointing to the canonical `byte_order_marker` builtin.
> 
> The pre-commit migration map is updated so `check-byte-order-marker`
and `fix-byte-order-marker` now resolve directly to
`Builtins.byte_order_marker` instead of the deprecated alias names.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
549c070. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
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.

1 participant