Repository navigation
Collaboration: Expense Review routine (mail-triggered, reviews approval requests against guideline documents) - #3211
Merged
Conversation
Contributor
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
…d-only memory - Routine runs get their own baseline (CollaborationPrompts.routinePrompt) instead of the chat prompt, with where the answer goes per delivery; the run message now carries only name, time, documents, skills and task. - Routines can save email drafts with SaveDraft (never sent, Settings draft folder); chats are refused it. - Memory is read only in routines: Remember and Forget are left out and refused. - Delivery reaches the room as the server-owned collaboration_routine_delivery option. - Routine guide and CreateRoutine allow naming who a draft is for.
…' into collaboration-expense-routine
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
Adds a new system routine, Expense Review, to Collaboration Routines. When an email whose subject starts with
Meeting ApprovalorBusiness Approvalreaches the owner's inbox, the routine reads the request, checks it against the guideline documents the owner uploaded, and emails the owner a Deloitte-styled HTML memo with a suggested decision. It never replies to the requester; the owner still responds in MES.Unlike the daily brief and weekly agendas, this routine runs off the mail import instead of a schedule, so
WorkRoutinelearns about unscheduled kinds.What changed
New routine kind
WorkExpenseRoutine(idexpense-review, tableWORK_EXPENSE_ROUTINE, automationexpense-review.automation.json, result nodereview).enabledandtimezone. Subject prefixes are a constant (SUBJECTS). Matching is case-insensitive, skips leading gateway tags such as[EXT], and never matchesRE:/FW:replies.collaboration/routines/e8f3a1c2-5b6d-4a7e-9c0f-1d2e3b4a5f60, and are copied into the run room'sdocuments/folder before the agent starts (same path custom routines use).WorkRoutineDocuments.requireRoutineaccepts that id besides stored custom routine ids.WorkGetExpenseRoutine(),WorkSaveExpenseRoutine(settings=[{enabled, timezone}]),WorkRunExpenseRoutine(threadId=[...], messageKey=[...]).gather(Python, reads each request thread as clean text) ->review(Collaboration agent withcollaborationRoutine, documents in the room) ->deliver(Python, Deloitte email shell, decision paragraph highlighted, Outlook link back to the request). Review order per request: Suggested decision, Before you respond, Guideline check table, Request table.Trigger path
BrainMailImport.Run.inboundrecords[messageKey, threadId, subject]of each newly imported message to the owner (from someone else, or a note the owner sent themselves;toMenow covers a self sender on To/Cc).BrainSync.runandBrainSync.importHeaders(webhook and pull paths) callWorkExpenseRoutine.onNewMailafter the ingest lock. Matching mail from one import batch becomes one run. Only mail Brain has never seen triggers; mail that arrived while the routine was off is never reviewed.WorkRoutine.trigger(kind, owner, pixel, delay)fires the routine's durable Quartz job with a per-firing Pixel (JobDataMapoverride;RunPixelJobFromDBreads the merged map andSchedulerResource.executePixelruns the posted Pixel). It callsSchedulerDatabaseUtility.startSchedulerfirst, because Quartz stands by after a restart until a schedule is saved.WorkExpenseRoutine.runsettles a lost run first, claims withnow=true, and when another review is still running schedules a one-shot retry two minutes later.WorkRoutine engine
Kind.scheduled()= the kind has atimedefault. Unscheduled kinds skip time/days validation, keep a never-firing cron (0 0 0 1 1 ? 2099) sosavestill creates the durable job and recipes row, report nonextRunAt, and get their ownfailed()wording.run(...)overload that merges trigger-supplied inputs (thread_ids,message_keys).Daily inbox brief
WorkInboxRoutine.inputspassesskip_reply_subjects = WorkExpenseRoutine.SUBJECTS; the brief'sgatherskips reply drafts for those threads (new_requesthelper strips Re:/Fw:/bracket tags). The brief must not draft an approval of spend; the request still shows in priorities and action items. New start global ininbox-daily-brief.automation.json.Plumbing
CollaborationOwlCreatortable loop andCollaborationDbUtilsunique owner index includeWORK_EXPENSE_ROUTINE.WorkRoutineRoom.openmaps the new id (open a result as a chat).BrainResetUtilsdeletes the routine's runs.