Harden the seams a project sweep surfaced
A systematic review of the whole codebase (main process, renderer, IPC/migration/packaging seams) surfaced four real defects; each is fixed at its root: - Legacy catalogue drift: the operator's profile still carried 89 active skills from the removed ~/.agents import era next to the 228 built-ins. Catalogue sync now mirrors the bundle - actives whose slug the bundle does not ship retire (bindings keep resolving via their pinned revisions; retired skills leave list_skills and cannot be granted anew) - Broken-bundle guard: staging now refuses a bundle without the humanizer skill, so an empty or quarantined resources folder can never trigger the mirror pass into retiring a healthy catalogue - Duplicate agent names: @mentions, DM routing, and task assignment all resolve by name, so createAgent and updateAgent renames now reject a name already held by an active agent (case-insensitive); the mention resolver still refuses to guess between legacy duplicates - Stale DM titles: agent-to-agent conversation rows titled themselves from the frozen creation-time space name, so renames never reached the sidebar; direct titles now derive from members' current names Verified clean in the same sweep: IPC surface (82 channels, handler + preload + api aligned), per-migration transactions with rollback, quota-parking month rollover, retry-budget counting, meeting spot reuse across floor-plan rebuilds.
This commit is contained in:
1 parent
c50f17190c
commit
04093c4869
8 files changed
+156
-12
No files matched your search
@@ -86,15 +86,49 @@ describe("built-in skills", () => {
|
||||
expect(humanizer?.manifest.description).toContain("AI-generated writing");
|
||||
|
||||
const first = h.connection.transaction(() => importStagedSkills(h.skills, h.orgId, staged));
|
||||
expect(first).toMatchObject({ imported: 2, skipped: 0, failures: [] });
|
||||
expect(first).toMatchObject({ imported: 2, skipped: 0, retired: 0, failures: [] });
|
||||
const second = h.connection.transaction(() => importStagedSkills(h.skills, h.orgId, staged));
|
||||
expect(second).toMatchObject({ imported: 0, skipped: 2 });
|
||||
expect(second).toMatchObject({ imported: 0, skipped: 2, retired: 0 });
|
||||
const slugs = (h.connection.db.prepare("select slug from skill_definitions where org_id = ? order by slug").all(h.orgId) as Array<{ slug: string }>)
|
||||
.map((row) => row.slug);
|
||||
expect(slugs).toEqual(["engineering-backend-architect", "humanizer"]);
|
||||
h.connection.close();
|
||||
});
|
||||
|
||||
test("legacy catalogue entries retire so every install mirrors the bundle, while their bindings keep working", () => {
|
||||
const h = harness();
|
||||
const staged = stageBuiltinSkillsLibrary(h.sourceRoot, h.libraryRoot);
|
||||
h.connection.transaction(() => importStagedSkills(h.skills, h.orgId, staged));
|
||||
|
||||
// A relic of the old ~/.agents import: active, not in the bundle, bound.
|
||||
let agentId = "";
|
||||
h.connection.transaction(() => {
|
||||
const now = new Date().toISOString();
|
||||
h.connection.db.prepare(`
|
||||
insert into skill_definitions(id, org_id, slug, name, owner_type, status, created_at)
|
||||
values ('skl_legacy', ?, 'legacy-tool', 'Legacy Tool', 'organization', 'active', ?)
|
||||
`).run(h.orgId, now);
|
||||
h.connection.db.prepare(`
|
||||
insert into skill_revisions(id, skill_id, version_semver, manifest_json, source_type, source_ref, published_at, immutable_checksum)
|
||||
values ('skr_legacy', 'skl_legacy', '1.0.0', '{"name":"Legacy Tool","requiredTools":[]}', 'local_directory', '/old', ?, 'sum')
|
||||
`).run(now);
|
||||
agentId = h.organization.createAgent({
|
||||
orgId: h.orgId, name: "Ada", role: "Engineer", department: "Engineering",
|
||||
modelProviderId: null, modelId: null, budgetCents: 1000, managerAgentId: null,
|
||||
});
|
||||
h.skills.bind({ orgId: h.orgId, agentId, skillId: "skl_legacy", revisionId: "skr_legacy" });
|
||||
});
|
||||
|
||||
const report = h.connection.transaction(() => importStagedSkills(h.skills, h.orgId, staged));
|
||||
expect(report.retired).toBe(1);
|
||||
const legacy = h.connection.db.prepare("select status from skill_definitions where id = 'skl_legacy'").get() as { status: string };
|
||||
expect(legacy.status).toBe("retired");
|
||||
const builtinStatuses = (h.connection.db.prepare("select status from skill_definitions where org_id = ? and id <> 'skl_legacy'").all(h.orgId) as Array<{ status: string }>)
|
||||
.map((row) => row.status);
|
||||
expect(new Set(builtinStatuses)).toEqual(new Set(["active"]));
|
||||
h.connection.close();
|
||||
});
|
||||
|
||||
test("every agent's run carries humanizer; hire-time skills join it and oversized grants are named, not overflowed", () => {
|
||||
const h = harness();
|
||||
// A third, oversized flat skill to prove the compiled-prompt cap.
|
||||
|
||||
@@ -754,7 +754,13 @@ describe("chat governance", () => {
|
||||
});
|
||||
employeeId = (connection.db.prepare("select id from employees where org_id = ?").get(orgId) as { id: string }).id;
|
||||
organization.createAgent({ orgId, name: "Ada", role: "Reviewer", department: "Engineering", modelProviderId: null, modelId: null, budgetCents: 10000, managerAgentId: null });
|
||||
organization.createAgent({ orgId, name: "Ada", role: "Release lead", department: "Engineering", modelProviderId: null, modelId: null, budgetCents: 10000, managerAgentId: null });
|
||||
// The front door refuses duplicate names outright...
|
||||
expect(() => organization.createAgent({ orgId, name: "ada", role: "Release lead", department: "Engineering", modelProviderId: null, modelId: null, budgetCents: 10000, managerAgentId: null }))
|
||||
.toThrow("already exists");
|
||||
// ...but a legacy database may already carry duplicates; mentions must
|
||||
// still refuse to guess between them.
|
||||
const secondId = organization.createAgent({ orgId, name: "Ada Backup", role: "Release lead", department: "Engineering", modelProviderId: null, modelId: null, budgetCents: 10000, managerAgentId: null });
|
||||
connection.db.prepare("update agents set name = 'Ada' where id = ?").run(secondId);
|
||||
spaceId = chat.createSpace({ orgId, spaceType: "project", name: "release", topic: "Release coordination", visibility: "workspace" });
|
||||
});
|
||||
|
||||
|
||||
@@ -62,6 +62,32 @@ describe("identity editing", () => {
|
||||
h.connection.close();
|
||||
});
|
||||
|
||||
test("rejects renaming or hiring into an existing active agent name", () => {
|
||||
const h = harness();
|
||||
h.connection.transaction(() => {
|
||||
h.organization.createAgent({
|
||||
orgId: h.orgId, name: "Dana Lee", role: "Engineer", department: "Engineering",
|
||||
modelProviderId: null, modelId: null, budgetCents: 1000, managerAgentId: h.agentId,
|
||||
});
|
||||
});
|
||||
// Hiring a second "Dana Lee" (any case) is ambiguous for mentions and DMs.
|
||||
expect(() => h.organization.createAgent({
|
||||
orgId: h.orgId, name: "dana lee", role: "Designer", department: "Design",
|
||||
modelProviderId: null, modelId: null, budgetCents: 1000, managerAgentId: h.agentId,
|
||||
})).toThrow("already exists");
|
||||
// Renaming the CEO onto that name is equally ambiguous.
|
||||
expect(() => h.organization.updateAgent({
|
||||
orgId: h.orgId, agentId: h.agentId, name: "Dana Lee", role: "CEO", title: "CEO",
|
||||
roleLevel: "c_suite", department: "Executive", budgetCents: 25000, modelProviderId: null, modelId: null,
|
||||
})).toThrow("already exists");
|
||||
// Saving without changing the name stays legal.
|
||||
h.connection.transaction(() => h.organization.updateAgent({
|
||||
orgId: h.orgId, agentId: h.agentId, name: "CEO", role: "CEO", title: "CEO",
|
||||
roleLevel: "c_suite", department: "Executive", budgetCents: 25000, modelProviderId: null, modelId: null,
|
||||
}));
|
||||
h.connection.close();
|
||||
});
|
||||
|
||||
test("rejects blank names and malformed avatar colors", () => {
|
||||
const h = harness();
|
||||
const base = {
|
||||
|
||||
Reference in new issue
Block a user