mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-08-13 22:37:29 +00:00
Reject unknown task assignees (#80)
This commit is contained in:
parent
e38688f16e
commit
41ab662afa
2 changed files with 33 additions and 17 deletions
|
|
@ -136,6 +136,19 @@ describe("AgentStack coordinator", () => {
|
||||||
expect(() => stack.assignTask(task.id, agentDid("ghost"))).toThrow(/Unknown agent/);
|
expect(() => stack.assignTask(task.id, agentDid("ghost"))).toThrow(/Unknown agent/);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("rejects tasks preassigned to unknown agents", () => {
|
||||||
|
const stack = new AgentStack();
|
||||||
|
expect(() =>
|
||||||
|
stack.createTask({
|
||||||
|
ownerDid: owner,
|
||||||
|
sourceApp: "ugig.net",
|
||||||
|
title: "Ghost assignment",
|
||||||
|
assigneeDid: agentDid("ghost")
|
||||||
|
})
|
||||||
|
).toThrow(/Unknown agent/);
|
||||||
|
expect(stack.listTasks({ assigneeDid: agentDid("ghost") })).toHaveLength(0);
|
||||||
|
});
|
||||||
|
|
||||||
it("filters tasks in snapshots", () => {
|
it("filters tasks in snapshots", () => {
|
||||||
const stack = new AgentStack();
|
const stack = new AgentStack();
|
||||||
stack.createTask({ ownerDid: owner, sourceApp: "x", title: "a" });
|
stack.createTask({ ownerDid: owner, sourceApp: "x", title: "a" });
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,9 @@ export class AgentStack {
|
||||||
if (!parseDid(input.ownerDid)) {
|
if (!parseDid(input.ownerDid)) {
|
||||||
throw new Error(`Invalid owner DID: ${input.ownerDid}`);
|
throw new Error(`Invalid owner DID: ${input.ownerDid}`);
|
||||||
}
|
}
|
||||||
|
if (input.assigneeDid && !this.agents.has(input.assigneeDid)) {
|
||||||
|
throw new Error(`Unknown agent: ${input.assigneeDid}`);
|
||||||
|
}
|
||||||
const ts = this.now();
|
const ts = this.now();
|
||||||
const task: DidTask = {
|
const task: DidTask = {
|
||||||
id: this.nextId("task"),
|
id: this.nextId("task"),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue