Repository navigation
feat(email): the action and rules API, with one visibility rule (EA-4) - #638
Open
privatejoel wants to merge 1 commit into
Open
privatejoel wants to merge 1 commit into
privatejoel wants to merge 1 commit into
Conversation
GET /api/email_actions with filters, GET and PATCH /api/email_actions/<id> (transitions, hand-off and reassign, corrections with a reason, business outcome, manual due time, optimistic version), /api/email_rules (tenant rules for email.rules, own rules for any writer). A user sees an action they own, back up, or whose message reached their mailbox; email.view_all sees all. email.view_all, email.reassign, email.verify and email.rules on both the server and the client tables. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This was referenced Oct 23, 2026
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Summary
EA-4 of the email accountability plan (#634, sections 6.5 and 6.8). This PR adds the API for email actions and rules, with one visibility rule and four new server actions.
Stacked on #637 (EA-3) ← #636 ← #635 ← #619. Merge in that order.
email-accountability/access.js). A user sees an action in four cases: they own it, they back it up, a mailbox they own received the message (connection_idorseen_connection_ids), or they holdemail.view_all. Anyone else gets 404, so they cannot learn that the action exists. The list and the detail use the same rule.viewerandcustomer_supporthave no access, because the rows carry mail subjects and senders.GET /api/email_actions:mailbox,owner(nonemeans unassigned),priority(1-4 or a label),customer,order,state(a status,openby default,closed,overdueorescalated),due_before,due_afterandscope=mine.overdueandescalatedflags.GET /api/email_actions/<id>returns the action and its history fromaudit_events.PATCH /api/email_actions/<id>takes{ version, ... }:status: only a move instore.TRANSITIONS.performedis refused with "record evidence instead" (EA-5).awaiting_verificationbelongs to the verifier only. A cancel and a reopen need a reason. A reopen starts a new cycle:reopen_count + 1andescalation_level = 0. When a reviewed action is confirmed, it goes to the person who confirms it, and its business status moves toawaiting_internal.assignee_user_id: the owner can hand the action off. Anyone else needsemail.reassign. The new owner must be an approved member. Only a manager can leave an action with no owner.backup_user_id, apriorityoraction_typecorrection (with a reason; the requirement follows the type),business_status, and a manualdue_at(with a reason;due_source 'manual').versioniswork_items.version. A stale version is 409 before any write. The write itself is also guarded by the version, so a write that lands between the read and the update is not overwritten.audit_eventswith the before and after values and the reason./api/email_rules:me). Tenant rules needemail.rules.due_hoursfrom 1 to 720.auth.jsSERVER_ACTIONS andrbac.tsACTIONS with the same roles:email.view_all,email.reassignandemail.verify: sales_manager and admin.email.rules: admin.No migration. No new npm package.
Deploy notes
Tests
src/v3-app/api-email-actions-api.test.js(21 tests):scope=minenarrows the list to the manager's own.viewerandcustomer_supportget 403.seen_connection_ids), customer, closed and escalated. A row carries the names, the PO number and the derived flags, and the critical rows come first.performedorawaiting_verificationby hand.rbac.tsACTIONS agree for the 4 actions, and a sales engineer holds none of them.Mutation check: I broke each rule, ran the file and restored the code. All 21 mutations failed the tests:
Two of these mutations first survived. I made those tests stronger: the error message for "performed", and the race between the read and the update.
Gates:
npm run check: pass.npm run lint: 0 errors. The new files add no warnings.npm run build: pass.npm run verify: pass. I restored the unrelated rewrites of the audit docs.npm run eval:golden: pass.NODE_OPTIONS=--no-experimental-webstorage npx vitest run: 630 files, 7,574 tests, all pass.installRbac.Not covered
🤖 Generated with Claude Code