Skip to content

feat(init): infer the preset from .talm-preset.lock - #266

Open
Asish (NopeCharon) wants to merge 1 commit into
cozystack:mainfrom
NopeCharon:feat/infer-preset-from-lock
Open

Asish (NopeCharon) wants to merge 1 commit into
cozystack:mainfrom
NopeCharon:feat/infer-preset-from-lock

Conversation

@NopeCharon

@NopeCharon Asish (NopeCharon) commented Nov 14, 2026 •

Copy link
Copy Markdown

Closes #220.

talm init --update without --preset only looked at Chart.yaml dependencies, which an init'd project does not record, so the bare form always failed. The preset pinned in .talm-preset.lock is now the last link of the chain: --preset → Chart.yaml dependencies → lock.

  • The fallback applies only when Chart.yaml is readable but names no preset. An unreadable or malformed Chart.yaml still errors, and a project without a lock keeps the previous error and hint.
  • A locked preset the binary does not embed is rejected before any write, like an unknown Chart.yaml preset.
  • CheckChartDrift reads the lock best-effort and puts the real preset name in its remediation hint instead of <preset>. A missing, corrupt or preset-less lock keeps the placeholder and never fails the check.
  • Docs: docs/operations/upgrading.md and the manual test plan describe the new chain.

Tests: TestInitUpdate_PresetFromLock, TestInitUpdate_UnknownLockPreset_FailsBeforeWrites, TestCheckChartDrift_LockNamesPreset_HintCarriesPreset, TestCheckChartDrift_UnusableLock_HintKeepsPlaceholder. go test ./pkg/commands/ passes.

Summary by CodeRabbit

  • New Features
    • talm init --update can now use the preset recorded in the project’s lock file when no preset option or chart dependency is provided.
    • Chart drift guidance now includes the recorded preset in the suggested update command, or shows a preset placeholder when one can’t be determined.
  • Documentation
    • Updated upgrade instructions and test guidance to explain preset selection and lock-file behavior.

`talm init --update` without --preset resolved the preset only from
Chart.yaml dependencies, which an init'd project does not record, so
the bare form always failed and every remediation hint had to carry a
literal `<preset>` placeholder.

The preset pinned in .talm-preset.lock now serves as the last link of
the inference chain: --preset flag, then Chart.yaml dependencies, then
the lock. The fallback applies only when Chart.yaml is readable but
names no preset; an unreadable or malformed Chart.yaml still errors,
and a project without a lock keeps the previous error and hint. A
locked preset unknown to the binary is rejected before any write, like
an unknown Chart.yaml preset.

CheckChartDrift reads the lock best-effort and substitutes the real
preset name into its remediation hint, matching the preset-drift
message. A missing, corrupt or preset-less lock leaves the placeholder
and never fails the check.

Docs (upgrading guide, manual test plan) describe the new chain.

Closes cozystack#220

Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

talm init --update now falls back to .talm-preset.lock when no preset flag or Chart.yaml dependency provides a preset. Chart-drift hints include the recorded preset when available. Tests and upgrade documentation describe these behaviors.

Changes: Preset resolution

Layer / File(s) Summary
Update preset inference
pkg/commands/init.go, pkg/commands/init_test.go, docs/operations/upgrading.md, docs/manual-test-plan.md
When --preset is absent and Chart.yaml has no preset dependency, init --update checks .talm-preset.lock. Tests cover a valid and unknown locked preset. Documentation describes the lookup order and test conditions.
Chart-drift remediation hint
pkg/commands/chart_drift.go, pkg/commands/chart_drift_test.go, docs/operations/upgrading.md
The drift hint uses the locked preset when available and retains --preset <preset> when the lock is missing, invalid, unreadable, or has no preset. Tests cover both cases.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant Init as talm init --update
  participant Chart as Chart.yaml
  participant Lock as .talm-preset.lock
  participant Update as Preset update
  Init->>Chart: Check for preset dependency
  Chart-->>Init: No preset dependency
  Init->>Lock: Read recorded preset
  Lock-->>Init: Return preset name
  Init->>Update: Update using recorded preset
Loading

Suggested reviewers: lexfrei

Merge Risk: Minimal · up to a3b25

The change lets talm init --update infer the preset from .talm-preset.lock and names that preset in chart-drift hints. Projects without a lock keep their current behavior. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "feat(init): infer the preset from .talm-preset.lock" matches the main change. The PR adds .talm-preset.lock as the final fallback for preset inference in talm init --update, after the --pre…
Linked Issues check Passed Directly linked issue #220 has two coding requirements. (1) talm init --update must infer the preset in the order --preset flag, then Chart.yaml dependencies, then .talm-preset.lock. The PR summ…
Out of Scope Changes check Passed All changed areas map to #220. pkg/commands/init.go and init_test.go implement and test the init --update lock fallback. pkg/commands/chart_drift.go and chart_drift_test.go implement and test …
Full details: Title check

Explanation

The title "feat(init): infer the preset from .talm-preset.lock" matches the main change. The PR adds .talm-preset.lock as the final fallback for preset inference in talm init --update, after the --preset flag and Chart.yaml dependencies. The PR also updates CheckChartDrift to name the lock's preset in its hint, which the title does not mention. That is a secondary change, so the title is still accurate.

Full details: Linked Issues check

Explanation

Directly linked issue #220 has two coding requirements. (1) talm init --update must infer the preset in the order --preset flag, then Chart.yaml dependencies, then .talm-preset.lock. The PR summary says readChartYamlPreset returns the shared errPresetNotInChart sentinel when Chart.yaml names no preset. init.go then falls back to the lock preset, and keeps the original error when no lock preset exists. TestInitUpdate_PresetFromLock covers the lock-based update, and TestInitUpdate_UnknownLockPreset_FailsBeforeWrites covers rejection before writes. (2) CheckChartDrift must read the lock best-effort and put the real preset name in its hint. The summary says a missing, corrupt, or preset-less lock keeps the &lt;preset&gt; placeholder and does not fail the check. TestCheckChartDrift_LockNamesPreset_HintCarriesPreset and TestCheckChartDrift_UnusableLock_HintKeepsPlaceholder cover these cases. Projects without a lock keep the previous behavior. Evidence limit: the init.go diff and the updateTalmLibraryChart body could not be read in full (diff unavailable; file read truncated), so the error-propagation claim for unreadable or malformed Chart.yaml rests on the PR description and summary.

Full details: Out of Scope Changes check

Explanation

All changed areas map to #220. pkg/commands/init.go and init_test.go implement and test the init --update lock fallback. pkg/commands/chart_drift.go and chart_drift_test.go implement and test the drift hint preset name. docs/operations/upgrading.md and docs/manual-test-plan.md describe the new inference chain and the drift hint, which matches the behavior the issue asks for. No unrelated code, refactoring, or API changes appear in the summary; the summary lists no changes to exported declarations. Evidence limit: the full diff could not be read, so this rests on the PR summary.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9005cc5c-83e7-4c3b-9846-2b5a273438b3
Commits

Reviewing files that changed from the base of the PR and between d4ef1df and a3b252e.

Files selected for processing: 6

  • docs/manual-test-plan.md
  • docs/operations/upgrading.md
  • pkg/commands/chart_drift.go
  • pkg/commands/chart_drift_test.go
  • pkg/commands/init.go
  • pkg/commands/init_test.go

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

This branch has not been deployed

No deployments
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.

feat(init,commands): infer the preset from .talm-preset.lock

1 participant