Repository navigation
fix: workspace rules state lives outside the project - #1669
Merged
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
No public issue on purpose: this fixes a security bug in the released v0.12.9, and it is tracked internally until a fixed release ships. A maintainer can confirm.
Type of change
What does this PR do?
The workspace rules state was read from
.altimate-code/learn/workspace-rules/rules.jsonin the working tree and acted on with the signed-in person's credential:The file is git-ignored, but a branch, a merge or a pull can still bring one in. A state with no scope was adopted as is. In a workspace owner's client, a planted outbox entry or approval became an active team rule for every member. This affects
mainsince #1605 and the v0.12.9 release.The fix stops trusting anything about workspace rules that comes from the repository:
$XDG_STATE_HOME/altimate-code/workspace-rules/<sha256 of the project's real path>.json(usually~/.local/state/...). The file is0600and its directory0700. Arules.jsonin the project is never read.rules/state-path.ts, which the store loads lazily, because importing@/globalat load time is circular.RulesStore.vouchedbuilds each rule's lesson (wording, pin, tags, paths) from the state, and delivery gives those. Theworkspace-rules/approved.jsoncopy in the project decides nothing that is delivered. A resumed session keeps a cached team rule only while the state still holds its id.pulled_with). Rules are vouched for only while that credential is signed in, so a sign-out or a switch to another account stops them at once instead of at the next sync.session/prompt.ts: the "can this project have team rules" check looks for the state file in its new location.No migration, on purpose. An old in-project
rules.jsonis exactly what must not be trusted. After upgrading, a client re-pulls its team rules on the next sync. These, stored by v0.12.9 in the old location, are not carried over:/rulesis back on the workspace setting;Not covered here:
learn showstill read the project's team-rules copy. A planted copy can only affect local analysis: it can make a correction topic look covered, which suppresses a proposal, andlearn showwould list it. It is never sent or delivered..sessionssnapshots and recurrence signals. A branch that commits snapshots can inflate the "applied" and "corrected again" counts sent with the person's credential. Counts only: nothing is proposed, approved or delivered.The Claude Code and Codex plugin PRs (AltimateAI/altimate-claude-plugin#13, AltimateAI/altimate-codex-plugin#7) depend on this fix, and #1626 rebases onto it.
How did you verify your code works?
bun run typecheckand the marker guard (analyze.ts --markers --strict).pushmakes no request (everyfetchcounted);mayHaveWorkspaceRulescounts a state in the new location, with no workspace binding, and ignores arules.jsonin the project;mainlocally or pass alone (timeouts under load):experimentalandmcpHttpApi,--time-budget,serves read routes,held-back promotion.Cost side effects
None. No model calls, queries or cloud resources are added. The credential check reads the local credential file.
Screenshots / recordings
Not a UI change.
Checklist
🤖 Generated with Claude Code
Summary by CodeRabbit
/ruleslearning choice are stored in user state outside the project.