36 lines
1.7 KiB
TypeScript
36 lines
1.7 KiB
TypeScript
// SPDX-License-Identifier: LicenseRef-ConusAI-Template-1.0
|
|
// The worker admits a job that leaves the process only for the person it acts for (apps/worker/src/
|
|
// native-admission.ts): the job's intent names the permissions that person must still hold. A module
|
|
// job that declares a platform operation and has no intent is refused every time it runs, so every
|
|
// such job has one.
|
|
|
|
import * as documents from "@app/modules/documents" // kit:documents
|
|
import * as knowledge from "@app/modules/knowledge" // kit:knowledge
|
|
import type { ModuleManifest } from "@conusai-kit/core"
|
|
import { describe, expect, it } from "vitest"
|
|
import { JOB_INTENT_PERMISSIONS } from "../apps/worker/src/native-admission.js"
|
|
|
|
const manifests: ModuleManifest[] = [
|
|
documents.documentsModule, // kit:documents
|
|
knowledge.knowledgeModule, // kit:knowledge
|
|
]
|
|
|
|
describe("the worker's native job admission", () => {
|
|
it("has an intent for every module job that declares a platform operation", () => {
|
|
for (const manifest of manifests) {
|
|
const jobs = Object.keys(manifest.jobs ?? {})
|
|
const declared = (manifest.serviceRequirements ?? [])
|
|
.filter((requirement) => requirement.transport === "platform")
|
|
.flatMap((requirement) => Object.keys(requirement.operations))
|
|
.filter((operation) => jobs.includes(operation))
|
|
for (const job of declared) expect(JOB_INTENT_PERMISSIONS[job]?.length, job).toBeGreaterThan(0)
|
|
}
|
|
})
|
|
|
|
// kit:knowledge:begin
|
|
it("admits the automatic PDF intake only while its administrator may still manage knowledge", () => {
|
|
expect(JOB_INTENT_PERMISSIONS[knowledge.AUTO_INDEX_JOB]).toEqual(["knowledge.knowledge.manage"])
|
|
})
|
|
// kit:knowledge:end
|
|
})
|