Repository navigation
feat: workspace rules — proposal card, owner review, approved rules in every session - #1605
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
Replaces #1438 (lesson sync), which is closed in favour of this redesign. Server side: AltimateAI/altimate-backend#7514 (
/datamates/{id}/rules) and AltimateAI/altimate-frontend#3603 (the workspace Rules tab).Type of change
What does this PR do?
In a project linked to a workspace, what the person teaches the agent can become a team rule. They confirm it on a card, the workspace owner reviews it, and approved rules reach every teammate's sessions. This replaces #1438's background lesson sync, which sent staged lessons without asking.
Proposal card, built once in the session server (
src/altimate/rules/proposal.ts,events.ts). It uses the same ask/reply shape asquestion:rule.proposal.askedgoes out on/event, and the client answers withPOST /rule-proposal/:id/reply. The TUI renders it now (plugin/tui/altimate/rules.tsx); the IDE extension can render the same event later with no logic of its own.eedits it (re-linted);n("Not a rule") suppresses the topic for 30 days.ato approve at once, which becomes "approve anyway" when the rule weakens verification.When a card appears (
trigger.ts), checked after each turn:training_savewithkind: "rule"and project scope now shows the card instead of writing training.One model call (the reflector, scoped to the triggering corrections) words the rule. If the drafter says the rule already covers it (HELPFUL), no card appears.
Rule or memory (
classify.ts). A preference ("I prefer…") or a fact ("our warehouse is…") is memory, saved without review:training_savesends the agent toaltimate_memory_write. When the wording says neither, the card asks "Save as: Memory · Team rule · Skip".Sync (
sync.ts,service.ts,store.ts):workspace-rulesstore (.altimate-code/learn/workspace-rules/; the name is reserved, and a store namedteamstays the person's own), so the existing delivery, recurrence andlearn showtreat them like any lesson. They reach the prompt's "Team rules" with theirapplies_toglobs as path triggers. They stop being delivered when the project is unlinked, the person signs out, access is refused, or workspaces are turned off.user:<id>), and sent on the next run under a cross-process push lock. Only an item the server refuses on its own leaves the queue; an account or workspace change drops it with a notice.Learning from sessions. In order: the learning kill switch,
ALTIMATE_LEARN_CAPTURE, alearn.captureset by a config layer above project files (organization policy: managed config, MDM, the account's config, inline config,OPENCODE_CONFIG_DIRor the home config), the person's/ruleschoice (kept in git-ignored rules state),learn.capturein the project file, then the workspace's "Learn from sessions".startCapturetakesforceso the rules service can start capture on the workspace's say-so.Also:
GET /rule-proposal,GET /altimate/rules/summary,GET /altimate/rulesandPOST /altimate/rules/sync./rulesand a sidebarrules:line.learn syncis new, andlearn statusshows a rules block with the last proposal check.learn statustext printsLearning from sessions: on|off (source)where it printedCapture:, and existing learn messages say "rule" where they said "lesson". The JSON output is unchanged apart from the addedrulesblock. In a linked project with a client showing cards,training_saveandaltimate_memory_writecan returnmetadata.actionproposed,memory,redirectorerror.learn bootstrapandlearn import-reviewssend what they find for review instead of staging a local candidate.api-clienterrors now carry the codeddetail.configure/learn.md.Not in this PR:
learn bootstrapis the path today);Beyond the backend contract
This PR also adds, beyond syncing rules with the workspace:
ctrl+x p), and/rules(team rules, your proposals, Sync now, your own learning on/off);POST /altimate/rules/learning, stored in the git-ignored rules state);learn bootstrap/learn import-reviewsoffering their staged rules to the owner's review, with a confirmation that names the workspace (--send-for-reviewfor scripts);training_savein a linked project proposing a team rule instead of saving project training (only when rules are enabled);Not in this PR (follow-up): proposals where no client renders cards —
altimate-code run, ACP, and the Claude Code / Codex plugins (there the save tools save as before cards). The VS Code extension renders cards through AltimateAI/vscode-altimate-mcp-server#540.How did you verify your code works?
bun run typecheck.test/altimate/rules/rules.test.ts(129 tests): classification,applies_to, learning precedence, the team mirror, the summary line, card actions per project, edit lint and the verification flag, dismissal, sync (push, pull, usage, scope changes, locks), card replies and their failure paths, "remember" fallbacks and crash recovery, and the after-turn check.httpapi-experimental/httpapi-mcptimeouts fail on a cleanmaintoo.Cost side effects
learn.modelor the session's model.Screenshots / recordings
"Remember this as a team rule" → card (owner view: Send, Approve now, Edit, Not a rule)

Corrected in 2 sessions → card on its own, with the evidence and the correction quote

After

e(edit wording)A rule that weakens verification: flagged, "Approve anyway"; the wording was unclear, so it also offers Memory

Rejection notice with the owner's reason

/rulesafter approval: team rules, your proposals, Sync now, learning on/off"I prefer CTEs" → saved to memory, no card

The same rules in the workspace's Rules tab (#3603)

Checklist
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
/rulesto browse team rules and proposals, manage personal learning settings, and sync. Thelearn synccommand is also available.Improvements