mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-21 08:22:20 +02:00
perf(skills): skip inventory work for empty runtime selections (#16343)
Return before company skill inventory work for a known empty native or stored-key selection. Preserve nonempty stored-key precedence, current access/version checks and legacy automatic skills.
Verified head f3f89eedff: 88 affected tests, full typecheck/build, full CI/E2E, Superagent, legacy status and Apex 5/5; no unresolved findings.
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
cda77edc60
commit
90a45ef254
3 files changed
+33
No files matched your search
@@ -1895,6 +1895,10 @@ automatically alongside it; see [Agent commentary](agent-commentary.md).
|
||||
Other runtime skills remain controlled by
|
||||
`paperclipSkillSync.desiredSkills`. The native `paperclip_runner` does not use
|
||||
this legacy default because its protocol supplies the control-plane contract.
|
||||
An empty native runtime selection returns before company skill inventory work.
|
||||
An explicit empty stored key set does the same. Nonempty selections still use
|
||||
the current inventory, version and access checks. Legacy automatic selections
|
||||
still resolve their operational and feedback skills.
|
||||
|
||||
Validate the catalog without writing the manifest:
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { expect, it } from "vitest";
|
||||
import type { Db } from "@paperclipai/db";
|
||||
import { companySkillService } from "../services/company-skills.js";
|
||||
|
||||
const databaseAccess = new Error("Runtime selection touched the inventory database");
|
||||
const db = new Proxy({} as Db, { get() { throw databaseAccess; } });
|
||||
|
||||
it.each([
|
||||
{ onlyKeys: new Set<string>() },
|
||||
{ onlyKeys: new Set<string>(), includeLegacy: true, selectionConfig: { paperclipSkillSync: { desiredSkills: ["selected"] } } },
|
||||
{ selectionConfig: {} },
|
||||
{ selectionConfig: { paperclipSkillSync: { desiredSkills: [] } } },
|
||||
{ selectionConfig: { paperclipSkillSync: { desiredSkills: [" ", null, {}] } } },
|
||||
])("does no inventory work for an empty runtime selection: %o", async options => {
|
||||
await expect(companySkillService(db).listRuntimeSkillEntries(randomUUID(), options)).resolves.toEqual([]);
|
||||
});
|
||||
|
||||
it.each([
|
||||
{},
|
||||
{ includeLegacy: true, selectionConfig: {} },
|
||||
{ includeLegacy: true, selectionConfig: { paperclipSkillSync: { desiredSkills: [] } } },
|
||||
{ selectionConfig: { paperclipSkillSync: { desiredSkills: ["selected"] } } },
|
||||
{ onlyKeys: new Set(["selected"]), selectionConfig: {} },
|
||||
])("retains inventory resolution for a requested or legacy skill set: %o", async options => {
|
||||
await expect(companySkillService(db).listRuntimeSkillEntries(randomUUID(), options)).rejects.toBe(databaseAccess);
|
||||
});
|
||||
@@ -6143,6 +6143,8 @@ export function companySkillService(db: Db, options: { actor?: AuthorizationActo
|
||||
companyId: string,
|
||||
options: RuntimeSkillEntryOptions = {},
|
||||
): Promise<PaperclipSkillEntry[]> {
|
||||
if (options.onlyKeys?.size === 0 || (!options.onlyKeys && options.selectionConfig && !options.includeLegacy
|
||||
&& readPaperclipSkillSyncPreference(options.selectionConfig).desiredSkills.length === 0)) return [];
|
||||
const skills = await listFull(companyId);
|
||||
const selectedKeys = options.onlyKeys ?? (options.selectionConfig ? new Set(
|
||||
(options.includeLegacy ? resolveLegacyPaperclipDesiredSkillNames : resolvePaperclipDesiredSkillNames)(
|
||||
|
||||
Reference in new issue
Block a user