Summary
Currently the keys system tracks a 1-to-1 mapping — each key entry maps one owner to one holder. In practice, lab keys are often held by multiple people at the same time (e.g., two people share responsibility, or one person temporarily hands a spare to a friend).
Current behavior
Each key entry is a single {holder, owner} pair. If Alice already holds Ravi's key and Bob also picks it up, the bot has no way to record Bob without losing Alice's entry.
Alice: "i have keys of ravi" → { holder: "Alice", owner: "ravi" }
Bob: "i have keys of ravi" → { holder: "Bob", owner: "ravi" } ← separate entry, both tracked
This technically works today (multiple entries per owner), but the "who has keys" and "who has ravi's keys" queries list each entry separately, and "i don't have keys" only removes the first matching entry. There's no concept of a key set for a single owner.
Proposed behavior
- Treat each owner's key as a set of holders, not individual entries.
bot who has keys should show something like:
ravi's keys are with Alice, Bob
bot ravi has keys should add the sender to the existing holder set (not create a duplicate entry).
bot i don't have keys should remove only the sender from the holder set.
bot i gave keys to Bob should transfer all of the sender's held keys to Bob (or add Bob if the intent is sharing).
bot who has ravi's keys should list all holders in one message.
Why
- Lab key management is a shared responsibility — multiple people hold keys at once.
- The current flat-list model makes it easy to create duplicates and hard to get a clean overview.
- A set-based model matches how keys actually work in the lab.
Acceptance criteria
Summary
Currently the keys system tracks a 1-to-1 mapping — each key entry maps one owner to one holder. In practice, lab keys are often held by multiple people at the same time (e.g., two people share responsibility, or one person temporarily hands a spare to a friend).
Current behavior
Each key entry is a single
{holder, owner}pair. If Alice already holds Ravi's key and Bob also picks it up, the bot has no way to record Bob without losing Alice's entry.This technically works today (multiple entries per owner), but the "who has keys" and "who has ravi's keys" queries list each entry separately, and "i don't have keys" only removes the first matching entry. There's no concept of a key set for a single owner.
Proposed behavior
bot who has keysshould show something like:bot ravi has keysshould add the sender to the existing holder set (not create a duplicate entry).bot i don't have keysshould remove only the sender from the holder set.bot i gave keys to Bobshould transfer all of the sender's held keys to Bob (or add Bob if the intent is sharing).bot who has ravi's keysshould list all holders in one message.Why
Acceptance criteria
test/migration-regressions.jscontinue to pass.