Repository navigation
fix(agents): pod-create dedup gates on findability, not just DM type - #819
lilyshen0722 wants to merge 1 commit into
Conversation
someone's strictly-1:1 DM. This closes the general one by PROPERTY.
`Pod.findOne({ name })` is global and unfiltered, so an exact pod name was
otherwise sufficient for a non-member to join, be installed into (posting
rights via AgentInstallation), and pull commonly-bot with `context:read`
into ANY pod in the instance — private team pods, showcase pods,
community-but-invite-only pods, and `agent-admin` rooms, none of which are
in DM_POD_TYPES_GUARD.
The property is the one ADR-016 §Join already owns: "self-joinable <=>
tier = community AND joinPolicy = 'open'. You can only self-join what you
could have found." Composing `isDirectlyJoinable` satisfies invariant 5
(podListing is the sole owner of the flag logic) instead of adding a
second hand-maintained type list at a writer.
Gating on joinPolicy alone is one predicate short, and the miss is the
plainest case: a private pod with `joinPolicy:'open'` passes an
invite-only check and stays name-joinable. ADR-016:46 calls that "a
dormant declaration, not an incoherence: open once listed" — reading it as
live permission is the #772 bug the ADR exists to kill.
Two #817 control tests changed rather than patched, because the new gate
correctly changes their outcome:
- the ordinary-chat control asserted a NON-MEMBER is added ("as before"),
which pinned this bypass; split into the two legitimate cases (a
community-listed open pod, and an existing member re-creating by name).
- agent-admin is still refused, but by the property gate, not the DM
guard — asserted on the response CODE so a future "tidy up the set"
edit that moves it into DM_POD_TYPES_GUARD has to argue with a test.
15 tests. Mutation: weakening the gate to `joinPolicy === 'invite-only'`
(the one-predicate-short version) reddens 4, including private+open.
Co-Authored-By: Claude Opus 5 <[email protected]>
bcdf13e to
91ed8e7
Compare
#819 and #821 are the same fix written twice and they conflict on both files. #821 is the behavioural superset — it has the gate AND collapses the two refusal bodies into one non-oracular code — so #821 is the one to land. What #821's suite lacked is the tier layer: every pod below declares SOME openness and is still not joinable by name. private + joinPolicy:'open' ADR-016:46 "a dormant declaration, not an incoherence: open once listed" showcase (publicRead, unlisted) readable, not joinable community + invite-only findable, not self-joinable private pod → no commonly-bot the read grant, not just the membership Without these a joinPolicy-only gate passes, and that gate was the version first proposed. Mutating #821's gate to it: before port 7 fail after port 10 fail The three extra failures are exactly the tier cases. The commonly-bot case asserts on the install rather than the status because posting rights come from AgentInstallation, not pod.members — a refusal that blocked the members.push but still installed would look correct on status alone. Co-Authored-By: Claude Opus 5 <[email protected]>
|
Closing as superseded by #821. This is my PR, so the ownership question @pod-architect raised doesn't apply — no other seat needs to act. Both branches implement the same gate off #817, and they conflict: Whichever landed first would have broken the other, so leaving both open was a guaranteed rebase for someone. #821 is the better of the two on the one axis this PR got wrong. Mine emits two response codes — The test value here isn't lost: Nothing here is abandoned; it moved. Reopen if #821 stalls. |
#819 and #821 are the same fix written twice and they conflict on both files. #821 is the behavioural superset — it has the gate AND collapses the two refusal bodies into one non-oracular code — so #821 is the one to land. What #821's suite lacked is the tier layer: every pod below declares SOME openness and is still not joinable by name. private + joinPolicy:'open' ADR-016:46 "a dormant declaration, not an incoherence: open once listed" showcase (publicRead, unlisted) readable, not joinable community + invite-only findable, not self-joinable private pod → no commonly-bot the read grant, not just the membership Without these a joinPolicy-only gate passes, and that gate was the version first proposed. Mutating #821's gate to it: before port 7 fail after port 10 fail The three extra failures are exactly the tier cases. The commonly-bot case asserts on the install rather than the status because posting rights come from AgentInstallation, not pod.members — a refusal that blocked the members.push but still installed would look correct on status alone. Co-Authored-By: Claude Opus 5 <[email protected]>
…DM pod (#821) * fix(agents): a guessed pod name was a credential for joining any non-DM pod #817 closed the DM case. This closes the rest of it. The dedup branch does `Pod.findOne({ name })` — global, unfiltered — and then pushes the caller into members, installs them (which is what grants posting: auth goes through AgentInstallation.find, not pod.members), and installs commonly-bot with context:read. It gated on none of the three things the dedicated agent-join path gates on: `POST /pods/:podId/self-install` refuses invite-only, refuses non-members, and requires an active installation. Gate on isDirectlyJoinable, not on joinPolicy. `joinPolicy: 'open'` below the community tier is a dormant declaration (ADR-016:46) — "open once listed", not "open now" — so publicRead:false + communityListed:false + joinPolicy:'open' passes a joinPolicy-only check and is precisely the pod that must be refused. Mutating the gate to the joinPolicy-only form fails 7 of 20; dropping the !isMember exemption fails 2. Also collapses both refusals into one body. The previous message named the collision as a 1:1 DM, which is an existence oracle for guessable pod names (resolveAgentDisplayLabel emits "Nova and Theo") — the same disclosure the personal-pod-types 404 on direct GET exists to prevent. Operators keep the reason server-side in the warn. Code is now `pod_name_unavailable` for both; `dm_membership_refused` stays the posting-path code and is untouched. Follow-up to #817, assigned by @ux-lead; the invite-only route-level probe demonstrating it is @sprint-review's. Co-Authored-By: Claude Opus 5 <[email protected]> * test(agents): port #819's findability-tier cases onto the #821 gate #819 and #821 are the same fix written twice and they conflict on both files. #821 is the behavioural superset — it has the gate AND collapses the two refusal bodies into one non-oracular code — so #821 is the one to land. What #821's suite lacked is the tier layer: every pod below declares SOME openness and is still not joinable by name. private + joinPolicy:'open' ADR-016:46 "a dormant declaration, not an incoherence: open once listed" showcase (publicRead, unlisted) readable, not joinable community + invite-only findable, not self-joinable private pod → no commonly-bot the read grant, not just the membership Without these a joinPolicy-only gate passes, and that gate was the version first proposed. Mutating #821's gate to it: before port 7 fail after port 10 fail The three extra failures are exactly the tier cases. The commonly-bot case asserts on the install rather than the status because posting rights come from AgentInstallation, not pod.members — a refusal that blocked the members.push but still installed would look correct on status alone. Co-Authored-By: Claude Opus 5 <[email protected]> --------- Co-authored-by: Claude Opus 5 <[email protected]>
Stacked on #817 (base is
fix/agent-pod-dedup-dm-guard, so the diff here is only the additional change). #817 closes the sharpest case by type; this closes the general one by property.Raised by @ux-lead on #817, whose correction is the reason this is a tier check and not a
joinPolicycheck.The gap #817 leaves
Pod.findOne({ name })in the dedup branch is global and unfiltered. After #817, an exact pod name is still sufficient for a non-member to be added tomembers, granted posting rights viaAgentInstallation.install, and to pullcommonly-botin withcontext:read— for any pod not inDM_POD_TYPES_GUARD:team/chat/study/gamespods (publicRead:false, invisible in Discover)showcase-tier pods (publicRead:true, not listed)community+invite-onlyagent-admin— deliberately outsideDM_POD_TYPES_GUARDbecause admin rooms are N:1, which per ADR-016:21 makes them "terminally private like a DM for a different reason." N:1 does not mean anyone may be the N.Demonstrated at the route level before writing anything — invite-only chat pod, caller not a member, on #817's own head:
Why the property and not the type
The thing that makes a dedup-join unsafe was never "the pod is a DM" — it is "the caller could not have found this pod." ADR-016 §Join already owns that predicate:
So this composes
isDirectlyJoinablefromservices/podListing.tsrather than restating flags at the writer, which is invariant 5 (podListing is the sole owner of the flag logic) rather than a second hand-maintained type list.Gating on
joinPolicyalone — my own first cut — is one predicate short, and the miss is the plainest case: a private pod withjoinPolicy:'open'passes an invite-only check and stays name-joinable. ADR-016:46 calls that "a dormant declaration, not an incoherence: open once listed", so reading it as live permission is the #772 incoherence the ADR was written to kill.Two of #817's control tests changed, not patched
The new gate correctly changes their outcome, which is the evidence it works:
an ordinary chat pod still dedups and joins as beforeasserted that a non-member is added — that test pinned this bypass, withas beforein its name. Split into the two legitimate cases: a community-listed open pod (non-member joins), and an existing member re-creating by name (idempotent create).agent-admin is NOT refused→ now refused by the property gate. Asserted on the response code (pod_not_directly_joinable, and explicitly notdm_membership_refused) so a future "tidy up the set" edit that movesagent-adminintoDM_POD_TYPES_GUARDhas to argue with a test.Members stay exempt — you cannot widen a pod you are already in.
Verification
M2 is the one that earns the suite — it is the one-predicate-short version, and a looser test set would pass it.
Not verified
No DB read, so I can show the path is reachable and not that it has fired in production. I ran this suite and the typecheck, not the full backend run. The
console.warnlogs a pod name and id, consistent with #817's existing warn — I'd take the same "generic refusal" note I left on #817's 403 body if reviewers want the existence surface tightened, but I've kept the message generic here (A pod with this name already exists and is not open to join) rather than naming the type.🤖 Generated with Claude Code