Naalya Handbook
AI system

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:

  1. The server route checks the caller, loads the rows, and computes any numbers. For example, ClassroomDigestService.computeStats counts the roster and gradebook gaps itself.
  2. The server sends those facts to the worker over the naalya-worker RabbitMQ queue with a MICRO_AI_PATTERNS message and waits. The worker's MicroAiController calls the model.
  3. 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.

PathoperationIdExtra permissionWhat comes backHub screen
summaries/class-setupsummariseClassSetupRead on classA plain-English summary of classes, levels, streams, and capacity for one campusCampus Classes list
proposals/class-setupproposeClassSetupCreate on classClasses and streams to create, from a typed request. Nothing is createdCampus Classes list, setup dialog
summaries/classroom-digestdigestClassroomNone on the route. The classroom access rules applyRoster, capacity, subject-teacher cover, and, with a termId, gradebook gaps, plus a short narrationStream workspace in Classrooms
parse-filterparseMicroAiFilterList on audit logAudit-log filters, a reading of the request, and warningsAudit logs table
proposals/enquiry-triageproposeEnquiryTriageUpdate on enquiryA priority, an optional assignee, and a reason per enquirySchool Enquiries list
proposals/subject-alignmentproposeSubjectAlignmentUpdate on subjectUp to three national curriculum matches with confidence and a reasonSubject page, Align surface
proposals/department-permissionsproposeDepartmentPermissionsUpdate on departmentA permission set from the registryDepartment page, school and campus
proposals/kb-public-reviewreviewKnowledgeBaseForPublicNone on the routeFlags for staff-only or unfinished content before a document goes publicKnowledge base document
draftdraftMicroAiTextNone on the routeA short field draft from a template name and contextDepartment create and settings, knowledge base document
rewriterewriteTextNone on the routeThe same passage in a chosen toneHead teacher remarks on report-card approval
suggestionssuggestPromptsAI chat feature flagUp to four prompt suggestions for the Rover boxRover 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:

WaitHelpers
30 secondsClass setup summary, classroom digest, draft, rewrite
45 secondsParse 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

  1. Add a pattern to MICRO_AI_PATTERNS in libs/shared/src/micro-ai/micro-ai.constants.ts, with request and reply types next to it.
  2. In the worker, add a method to the service in apps/worker/src/micro-ai/ that fits, and a @MessagePattern handler on MicroAiController. Use structured output when the answer is a choice.
  3. On the server, add a service under apps/server/src/app/naalya-ai/summaries/ that loads and computes the facts, calls the worker with a timeout, and filters the reply against what it sent.
  4. Add the route to NaalyaAiController with an operationId, a staff user-type check, and the permission the proposal would need to be applied.
  5. In the Hub, call it through NaalyaAiQuery and 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-API at fbb63d5178bcfe171292daebb19b6cbdac025a44: 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_MS in 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-Hub at 9e84f4c33d5f1a9b9ae84bd7f1e6663598504073: 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, and use-tone-rewrite.tsx on the report-card approval route.

On this page