Skip to content

Commit a2199a6

Browse files
johnmatthewtennantPoppyclaude
committed
fix(attention): keep an Interest whose skipped watch would be orphaned
interest_remove counted only readable watches, so an Interest whose remaining watch was skipped (for example over the limit) was removed and left that watch without an Interest, where the agent cannot delete it. Refuse instead and point to the owner's Attention tab, which deletes skipped watches with their Interest. Signed-off-by: John Tennant <[email protected]> Co-authored-by: Poppy <ace4dfe51b23bb4244ab9117dfd5e13b8239445e333225608c352e68cb3fe2b5@buzz.block.builderlab.xyz> Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent fa5e0a6 commit a2199a6

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

‎src/features/agents/attention-objects.test.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,24 @@ describe("checked writes", () => {
147147
expect(interestIds(gone)).toEqual(["other"]);
148148
});
149149

150+
it("keep an Interest whose only remaining watch this app skipped", async () => {
151+
const bare = await write(record(), "watch/asks", null);
152+
const value: AgentRecord = {
153+
...bare,
154+
skipped: {
155+
"watch/over": {
156+
slug: "watch/over",
157+
value: timer(),
158+
modifiedAt: 1,
159+
problem: "Over the limit",
160+
},
161+
},
162+
};
163+
await expect(write(value, "interest/triage", null)).rejects.toThrow(
164+
/^invalid-operation: .*over.*your owner can remove/,
165+
);
166+
});
167+
150168
it("report the format's own problems as invalid", async () => {
151169
await expect(
152170
write(record(), "watch/asks", watch({ since: 0 })),

‎src/features/agents/attention-objects.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,18 @@ export async function checkedWrite(
359359
"invalid-operation",
360360
`Remove its watches first: ${users.map((watch) => watch.id).join(", ")}`,
361361
);
362+
// A watch this app skipped, such as one over the limit, still belongs to
363+
// the Interest; removing the Interest would leave it without one.
364+
const skipped = Object.values(record.skipped ?? {}).filter(
365+
(object) =>
366+
(object.value as { interest_id?: unknown } | null)?.interest_id ===
367+
parsed.id,
368+
);
369+
if (skipped.length)
370+
throw new AttentionError(
371+
"invalid-operation",
372+
`${skipped.map(({ slug }) => slug).join(", ")} cannot be read by this app; your owner can remove the Interest with it on your Attention tab`,
373+
);
362374
}
363375
let after: AgentRecord;
364376
try {

0 commit comments

Comments
 (0)