8000 fix(mfile,mctx): say what a dot state key names, and fit the state-dir message to its cause by bryan-minimal · Pull Request #3605 · gominimal/minimal · GitHub
[go: up one dir, main page]

Skip to content

fix(mfile,mctx): say what a dot state key names, and fit the state-dir message to its cause - #3605

Merged
bryan-minimal merged 2 commits into
mainfrom
fix/state-key-load-followup
Nov 19, 2026
Merged

bryan-minimal merged 2 commits into
mainfrom
fix/state-key-load-followup

Conversation

@bryan-minimal
@bryan-minimal bryan-minimal commented Nov 18, 2026 •
Copy link
Copy Markdown
Member

What

Four follow-ups to #3520, each from a review note there.

Refs #3520

1. The run-time message fits what can still go wrong

After #3520 a state key that reaches the run has already passed the one-name check. What can still fail is the state directory itself: its path resolves outside the state base, or cannot be resolved. The message told the person to choose a key that is one directory name, which they already had. It now names the task, the key and the path's problem, and says to check that path for a symlink or a permission problem.

2. A real reason for . and ..

For these two keys the reason was the value again, so the refusal read: sets state_key to "..", and it is "..". The reason now says what the key names: the current directory or the parent directory. The same reason is used at load, at run time and by the package graph's state-dir check.

3. The untested branch has a test

The branch of make_env that names the task and says where to set state_key had no test. make_env takes the key as an argument, so a unit test reaches it directly.

4. One doc

The doc on from_dir_for_graph now names both refusals it skips.

Testing

  • make_env_names_the_task_for_a_state_key_that_is_not_one_name
  • make_env_refuses_a_state_directory_behind_a_symlink
  • a_dot_state_key_is_refused_with_what_it_names
  • state_dir_parent_component_is_rejected now expects the new reason.

Workspace lint, tests and the native end-to-end script pass on this commit.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • State-directory errors now identify the related task and state key, and suggest checking for symlink or permission issues.
    • Invalid state keys receive clearer explanations, including when they refer to the current or parent directory. Invalid keys continue to be refused separately from errors resolving valid state directories.
  • Documentation
    • Clarified which loading checks apply to graph layers and which apply to the project’s own file.

…r message to its cause

For the keys `.` and `..` the reason a state key is refused was the value
again, so the load refusal printed the key twice ("sets `state_key` to
"..", and it is ".."") and the run-time message did the same. The reason
now says what the key names: the current or the parent directory. The
package graph's state-dir prefix message reads the same reason.

When the state directory is composed, a key that passed the one-name
check can only fail because the directory's path resolves outside the
state base or cannot be resolved. The message told the person to choose a
one-name key, which they already had. It now names the task, the key and
the path's problem, and says to check that path for a symlink or a
permission problem.

Tests: the load refusal for `.` and `..` is pinned whole, and both
run-time messages of `make_env` are pinned, reached by passing the key
directly and by a symlinked state directory. The doc on
`from_dir_for_graph` names the state-key refusal it skips.

Refs #3520

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bryan-minimal
bryan-minimal requested a review from a team as a code owner November 18, 2026 23:00
@coderabbitai
coderabbitai Bot commented Nov 18, 2026 •
Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

File loading now reports whether . or .. names the current or parent directory. Environment creation reports unresolved state directories with the task name and state key, while retaining a separate refusal for invalid keys.

Changes: State-key error handling

Layer / File(s) Summary
Load-time state-key validation
crates/mfile/src/lib.rs
Validation reports when a state key names the current or parent directory. The graph-loading documentation and tests reflect the validation behavior.
Runtime state-directory errors
crates/mctx/src/lib.rs
Environment creation reports state-directory resolution failures with the task name and state key, separately from invalid-key refusals. Tests check invalid keys and a symlink-backed state directory.

Estimated code review effort: 2 (Simple) | ~12 minutes

Possibly related PRs

Suggested reviewers: mitodrummer, norrietaylor

Merge Risk: Minimal · up to 309ef

This change improves the error messages shown when a task's state key or state directory cannot be used. It does not alter which keys are accepted or refused. The risk of merging is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title uses the Conventional Commit form with scope mfile and mctx and names both changes: the dot state key explanation and the state-dir message. It is specific, lower-case, has no trailing perio…
Description check Passed The description follows the template. It has a What section that explains four follow-ups to #3520 and links it with Refs #3520. It has a Testing section that lists the new and updated tests and state…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title uses the Conventional Commit form with scope mfile and mctx and names both changes: the dot state key explanation and the state-dir message. It is specific, lower-case, has no trailing period, and matches the changeset. It is 91 characters, which is long, but the content is accurate.

Full details: Description check

Explanation

The description follows the template. It has a What section that explains four follow-ups to #3520 and links it with Refs #3520. It has a Testing section that lists the new and updated tests and states that lint, tests, and the native end-to-end script pass. It does not paste the relevant command output as evidence, which the template asks for. The Checklist is absent, so it is unclear whether the docs update item applies or was checked. The Summary heading is replaced by a What heading. These gaps are minor, so the description is mostly complete.

Finishing Touches

Generate unit tests (beta)

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

A rabbit checks the state-key trail,
. marks where the current paths prevail.
.. names the parent, clear and bright,
Symlink paths now raise a warning right.
Task and key appear in view,
The tests check each refusal too.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: dd922f1e-1bb4-4a5c-9c99-433a3f60bdbe
Commits

Reviewing files that changed from the base of the PR and between 9a9101e and 309efef.

Files selected for processing: 1

  • crates/mctx/src/lib.rs
Files skipped from review as they are similar to previous changes: 1

  • crates/mctx/src/lib.rs

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

@minimal-foundry
minimal-foundry Bot commented Nov 18, 2026 •
Copy link
Copy Markdown
Contributor

Approved: no findings at 309efefced9f.

Nothing to do.

Clobber: none seen.

@minimal-foundry minimal-foundry Bot left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

minimal-review — advisory review

Verdict COMMENT — 1 finding, 1 inline.

Panel: 3 of 3 personas ran (correctness, security, supply-chain).

Comment thread crates/mctx/src/lib.rs Resolved
…right

The run-time message set the reason straight after "The state directory
for task ... and state key ...". That read well for "resolves to X, which
is outside the state base Y" and wrongly for the two "cannot resolve ..."
reasons, which made the state directory the subject of a sentence about
the state base. The message now says the state directory cannot be used,
then the reason after a colon.

Refs #3520

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@norrietaylor norrietaylor left a comment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I checked the four follow-ups against the PR head and they hold. validate_state_component now gives . and .. a reason that says what they name. That reason flows unchanged to the load refusal (InvalidStateKey), to make_env and to the graph's state-dir prefix check in graph/src/env_setup.rs, and nothing else in the tree still pins the old it is ".." text. make_env uses validate_state_component to choose between its two messages, so a key that is not one name still gets the "set state_key" remedy. Only a real path-resolution failure gets the new symlink/permission message. The symlink test does build that path: the state base does not exist when durable_state_dir is first called, then the project directory is made a symlink out of it, so the second call resolves outside the base. I found no new issues. The open low note from minimal-foundry still applies: two of the three reasons from state_dir_encoded (cannot resolve the state base ... and cannot resolve ... under the state base ...) read ungrammatically after "The state directory for task ... and state key ...". Fixing it is cheap and doesn't need to block the merge.


Generated by Claude Code

@minimal-foundry minimal-foundry Bot left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

minimal-review — approved

Verdict APPROVE — No findings.

Panel: 3 of 3 personas ran (correctness, security, supply-chain).

@minimal-foundry minimal-foundry Bot added the review:approved minimal-review approved the current head label Nov 19, 2026
@bryan-minimal
bryan-minimal added this pull request to the merge queue Nov 19, 2026
Merged via the queue into main with commit 2265c35 Nov 19, 2026
40 checks passed
@bryan-minimal
bryan-minimal deleted the fix/state-key-load-followup branch November 19, 2026 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review:approved minimal-review approved the current head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0