AI helpers on staff screens
The small one-shot AI calls behind buttons like Suggest, Triage, and Rewrite, and the rule they all follow.
Rover is the chat. Most of the AI a staff member meets is not. It is a button on an ordinary screen: Triage on the enquiries list, a draft button on the department form, a plain-English filter on the audit log. Each one is a single request that waits for one answer. There is no thread, no tool calling, and no graph.
Use this page when you touch one of those buttons, or when you want to add another.
The rule every helper follows
The server works out the facts. The model only words them or picks from a list the server supplied. Nothing is saved by the helper.
That splits each helper into three steps:
- The server route checks the caller, loads the rows, and computes any numbers. For example,
ClassroomDigestService.computeStatscounts the roster and gradebook gaps itself. - The server sends those facts to the worker over the
naalya-workerRabbitMQ queue with aMICRO_AI_PATTERNSmessage and waits. The worker'sMicroAiControllercalls the model. - The server checks the reply against what it sent. A model answer outside the allowed set is dropped. Then it returns a proposal. The Hub shows it, and the person applies it through the normal endpoint for that resource.
Step 3 is why the helpers are safe to add. In AssistProposalService.parseAuditFilter, an audit type, action, or resourceType the model invented is deleted and a warning such as "x" is not a known action; ignored. is added. triageEnquiries keeps only enquiry ids it was given and drops an assignee id that is not on the staff list it sent. suggestAlignment keeps only curriculum ids from the registry and returns at most three.
The helpers
Every route is POST /api/v1/naalya-ai/... and requires a staff token. A successful call answers 201. The table is grouped by the screen that uses it.
| Path | operationId | Extra permission | What comes back | Hub screen |
|---|---|---|---|---|
summaries/class-setup | summariseClassSetup | Read on class | A plain-English summary of classes, levels, streams, and capacity for one campus | Campus Classes list |
proposals/class-setup | proposeClassSetup | Create on class | Classes and streams to create, from a typed request. Nothing is created | Campus Classes list, setup dialog |
summaries/classroom-digest | digestClassroom | None on the route. The classroom access rules apply | Roster, capacity, subject-teacher cover, and, with a termId, gradebook gaps, plus a short narration | Stream workspace in Classrooms |
parse-filter | parseMicroAiFilter | List on audit log | Audit-log filters, a reading of the request, and warnings | Audit logs table |
proposals/enquiry-triage | proposeEnquiryTriage | Update on enquiry | A priority, an optional assignee, and a reason per enquiry | School Enquiries list |
proposals/subject-alignment | proposeSubjectAlignment | Update on subject | Up to three national curriculum matches with confidence and a reason | Subject page, Align surface |
proposals/department-permissions | proposeDepartmentPermissions | Update on department | A permission set from the registry | Department page, school and campus |
proposals/kb-public-review | reviewKnowledgeBaseForPublic | None on the route | Flags for staff-only or unfinished content before a document goes public | Knowledge base document |
draft | draftMicroAiText | None on the route | A short field draft from a template name and context | Department create and settings, knowledge base document |
rewrite | rewriteText | None on the route | The same passage in a chosen tone | Head teacher remarks on report-card approval |
suggestions | suggestPrompts | AI chat feature flag | Up to four prompt suggestions for the Rover box | Rover chat |
draft accepts two templates in the worker's TEMPLATES map: department-description and knowledge-base-document. Any other name makes the worker throw Unknown draft template.
rewrite offers the tones in REWRITE_TONES: polite, professional, casual, encouraging, concise, and warm. The comment on that constant says it is shared with the Hub. The Hub does not import it. It keeps the same six values in its own RewriteTone type in naalya-ai.query.ts, so a new tone has to be added in both places. The route trims the reply to 600 characters. If the worker fails or sends back nothing, the route answers 502 with The rewrite could not be produced. Try again in a moment. It never returns the original text as if it were a rewrite.
suggestions is the exception to the rest. It runs while someone pauses typing, so it never fails. When suggestions are unavailable it answers 201 with an empty list, and the Hub keeps its own starters.
Time limits and failures
The server stops waiting after a fixed time:
| Wait | Helpers |
|---|---|
| 30 seconds | Class setup summary, classroom digest, draft, rewrite |
| 45 seconds | Parse filter, enquiry triage, subject alignment, knowledge base review, class setup proposal, department permissions |
Apart from rewrite and suggestions, the routes do not catch a worker failure or a timeout. It reaches the client as an error from the shared exception filter. Two refusals happen before the model is called: Subject not found and The curriculum registry is empty on subject alignment, and Department not found on department permissions.
Add a helper
- Add a pattern to
MICRO_AI_PATTERNSinlibs/shared/src/micro-ai/micro-ai.constants.ts, with request and reply types next to it. - In the worker, add a method to the service in
apps/worker/src/micro-ai/that fits, and a@MessagePatternhandler onMicroAiController. Use structured output when the answer is a choice. - On the server, add a service under
apps/server/src/app/naalya-ai/summaries/that loads and computes the facts, calls the worker with atimeout, and filters the reply against what it sent. - Add the route to
NaalyaAiControllerwith anoperationId, a staff user-type check, and the permission the proposal would need to be applied. - In the Hub, call it through
NaalyaAiQueryand apply the result through the resource's own mutation.
Steps 3 and 4 are where a mistake costs the most. A helper that skips the filter can show staff an id that does not exist. A route without the right permission can describe rows the caller could not otherwise read.
Sources
Read in code, not run against a live model.
Naalya-APIatfbb63d5178bcfe171292daebb19b6cbdac025a44:apps/server/src/app/naalya-ai/naalya-ai.controller.ts(NaalyaAiController,MAX_REWRITE_LENGTH),apps/server/src/app/naalya-ai/summaries/*.service.ts(WORKER_TIMEOUT_MSin each),apps/worker/src/micro-ai/micro-ai.controller.ts,assist.service.ts,draft.service.ts(TEMPLATES),libs/shared/src/micro-ai/micro-ai.constants.ts(MICRO_AI_PATTERNS,REWRITE_TONES).Education-Hubat9e84f4c33d5f1a9b9ae84bd7f1e6663598504073:src/queries/naalya-ai/,src/components/ai/(nl-filter.tsx,enquiry-triage.tsx,class-setup-proposal.dialog.tsx,department-permission-proposal.dialog.tsx,kb-public-review.dialog.tsx,classroom-digest.tsx,draft-field-button.tsx,kb-draft.tsx),src/components/surfaces/subject/align-subject.surface.tsx, anduse-tone-rewrite.tsxon the report-card approval route.