From 47210f602b2e4638f6e81096026a495faf99ac67 Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Fri, 4 Dec 2026 20:48:22 +0530 Subject: [PATCH 01/28] grants: invite a person to a namespace by handle or email, with a single-use link Co-Authored-By: Claude Opus 5.5 Signed-off-by: Lareb Zafar --- docs/architecture/storage-layout.md | 1 + docs/reference/configuration.md | 2 + loom.example.yaml | 4 + schemas/loom-settings.schema.json | 5 + schemas/migrations/123_namespace_invites.sql | 28 ++ schemas/schema.sql | 21 ++ server/auth/grant_claims.py | 11 +- server/erasure/store/census.py | 5 + server/identity/api/models_grants.py | 77 +++++ server/identity/api/ops_grants.py | 68 +++++ server/identity/app/grants.py | 31 ++- server/identity/app/invite_mail.py | 83 ++++++ server/identity/app/invites.py | 222 +++++++++++++++ server/identity/domain/invites.py | 85 ++++++ server/identity/store/invites.py | 61 ++++ server/identity/store/namespaces.py | 17 ++ server/settings/_env.py | 2 + server/settings/catalog.py | 13 + tests/integration/test_grants_invite.py | 111 ++++++++ tests/unit/test_grants_invite.py | 279 +++++++++++++++++++ 20 files changed, 1116 insertions(+), 10 deletions(-) create mode 100644 schemas/migrations/123_namespace_invites.sql create mode 100644 server/identity/app/invite_mail.py create mode 100644 server/identity/app/invites.py create mode 100644 server/identity/domain/invites.py create mode 100644 server/identity/store/invites.py create mode 100644 tests/integration/test_grants_invite.py create mode 100644 tests/unit/test_grants_invite.py diff --git a/docs/architecture/storage-layout.md b/docs/architecture/storage-layout.md index bbbccbed42c..b15edd027b6 100644 --- a/docs/architecture/storage-layout.md +++ b/docs/architecture/storage-layout.md @@ -934,6 +934,7 @@ copies of tables listed here, owned and removed by that run, and erasure reaches | `oauth_signin_state` | KeeperMap `claim_key` | Postgres `oauth_signin_state` | SoR | no content | 1 | strict compare-and-set per key with an expiry and optional verified sign-in email metadata: an `UPDATE … WHERE value = $old`; the KeeperMap expiry becomes `expires_at`, read by a sweep; named in `server/auth/claims.py`, `server/cli/secrets.py` | | `grant_claims` | KeeperMap `claim_key` | delete | Coord | no content | 1 | no code path writes it (its census entry says so); no module outside the census names the table (`server/auth/grant_claims.py` is the claim module, whose keys are in `_migration_lock`) | | `namespace_grants` | RMT(version) `(org, namespace, subject)`, by `org` | Postgres `namespace_grants` | SoR | step `grants.revoke` | 1 | every request's role check; a revoke takes effect within the grant cache's invalidation bound; named in `server/identity/store/grants.py`, `server/auth/self_signup.py` | +| `namespace_invites` | RMT(version) `(org, namespace, invite_id)`, TTL | Postgres `namespace_invites` | SoR | no content | 1 | an invitation read by `(org, namespace, invite_id)` when its link is accepted or cancelled, and the open ones when a namespace's members are shown; named in `server/identity/store/invites.py` | | `namespaces` | RMT(updated_at) `(org, namespace)`, by `org` | Postgres `namespaces` + ClickHouse mirror | SoR (head) | step `personal.retire`; step `collections.forget_owner` | 1 | the registry with its per-namespace settings, read by grants, sign-in and request paths through a cache; the mirror serves ClickHouse worker scans and the SQL surface views; named in `server/auth/self_signup.py`, `server/cli/hygiene.py` | | `collections` | RMT(version) `(org, namespace)` | Postgres `collections` | SoR | step `collections.forget_owner` | 1 | the collection tree grants inherit through; named in `server/identity/store/collections.py`, `server/identity/store/namespace_census.py` | | `acl_versions` | SMT(changes) `(org, kind)` | merge into Postgres `cache_generations` (kinds `grants`, `groups`, `collections`) | Coord | no content | 1 | a change counter caches poll; a generation row plus `NOTIFY` replaces it; named in `server/core/grant_cache.py` | diff --git a/docs/reference/configuration.md b/docs/reference/configuration.md index 3342f383c83..7b6b611e85f 100644 --- a/docs/reference/configuration.md +++ b/docs/reference/configuration.md @@ -136,6 +136,8 @@ Authentication, tokens and identity providers. | `LOOM_WORKLOAD_EXCHANGES_PER_AGENT` | `int` | `300` | | Workload-token exchanges one agent of a trust (a token with an agent claim) may make in 10 minutes, so one agent's loop cannot spend the trust's. A trust without agents has only `workload_exchanges_per_trust`. | | `LOOM_SELF_SIGNUP` | `'off' \| 'open'` | `'off'` | | Browser self-signup: "off" (endpoint 404s) or "open" (/v1/auth/self-signup mints JWTs scoped to the requested namespace). A non-loopback bind refuses "open" unless identity_provider is "trust-network", allow_insecure is set, or oauth_login_provider is "oidc" (which closes sign-up). | | `LOOM_SELF_SIGNUP_ORG` | `str` | `'dev'` | | Default org for self-signed tokens. | +| `LOOM_SMTP_URL` | `str` | *(unset)* | | The mail server an invitation is emailed through: `smtps://user:password@host:465` (TLS from the start) or `smtp://user:password@host:587` (STARTTLS, which a login requires). Empty: no email is sent, and whoever makes an invitation sends its link. | +| `LOOM_MAIL_FROM` | `str` | `''` | | The From address of an invitation email, e.g. `Loom `. Empty sends none, as does an empty smtp_url or public_base_url (the link needs it). | | `LOOM_IDENTITY_PROVIDER` | `'' \| 'single-user' \| 'trust-network' \| 'gateway'` | `''` | | How callers authenticate: "single-user" (no auth, one anonymous identity), "trust-network" (self-signup, first claim wins) or "gateway" (an upstream proxy mints short-lived Loom JWTs with the shared HS256 secret; Loom only validates). Empty = inferred from auth_required and self_signup at boot. | | `LOOM_DASHBOARD_REDIRECT_URL` | `str` | `''` | | When set, a dashboard page load redirects (302) here instead of serving the SPA (Loom behind an aggregator). Deployment-specific; never hardcode. | | `LOOM_TRUSTED_CALLERS` | `str` | `''` | | Comma-separated subjects allowed to send `X-Loom-On-Behalf-Of` (a trusted aggregator passing each end-user's identity under one service token). Empty disables the header. | diff --git a/loom.example.yaml b/loom.example.yaml index e70ed7853ef..3e4e7cc3338 100644 --- a/loom.example.yaml +++ b/loom.example.yaml @@ -883,6 +883,10 @@ settings: # Default org for self-signed tokens. [restart] # self_signup_org: "dev" + # The From address of an invitation email, e.g. `Loom `. Empty sends + # none, as does an empty smtp_url or public_base_url (the link needs it). [restart] + # mail_from: "" + # How callers authenticate: "single-user" (no auth, one anonymous identity), # "trust-network" (self-signup, first claim wins) or "gateway" (an upstream proxy # mints short-lived Loom JWTs with the shared HS256 secret; Loom only validates). diff --git a/schemas/loom-settings.schema.json b/schemas/loom-settings.schema.json index 985d0bd043f..d4b67baf3a7 100644 --- a/schemas/loom-settings.schema.json +++ b/schemas/loom-settings.schema.json @@ -4065,6 +4065,11 @@ "type": "string", "description": "Root log level. (Bind host/port are flags of `loom serve`, not settings.)" }, + "mail_from": { + "default": "", + "type": "string", + "description": "The From address of an invitation email, e.g. `Loom `. Empty sends none, as does an empty smtp_url or public_base_url (the link needs it)." + }, "max_request_bytes": { "default": 33554432, "type": "integer", diff --git a/schemas/migrations/123_namespace_invites.sql b/schemas/migrations/123_namespace_invites.sql new file mode 100644 index 00000000000..d613be78470 --- /dev/null +++ b/schemas/migrations/123_namespace_invites.sql @@ -0,0 +1,28 @@ +-- Invitations to a namespace, for a person no account signs in as yet. +-- +-- grants.invite writes one row per invitation: the role it gives, the email it was made +-- for and who made it. The link it hands out carries a random secret; the row is keyed +-- by the secret's SHA-256 (`invite_id`), so a row read out of storage admits nobody. +-- grants.accept_invite writes the row again with `state = 'accepted'` and who accepted +-- it, grants.cancel_invite with `state = 'cancelled'`. An invitation lives for +-- `expires_at` (Unix seconds); the TTL drops the rows a week after that. A build before +-- this one never reads the table. +CREATE TABLE IF NOT EXISTS loom.namespace_invites +( + org LowCardinality(String), + namespace LowCardinality(String), + invite_id String, + email String DEFAULT '', + role LowCardinality(String), + created_by String, + created_at DateTime64(3, 'UTC'), + expires_at UInt32, + state LowCardinality(String) DEFAULT 'open', + accepted_by String DEFAULT '', + changed_at DateTime64(3, 'UTC'), + version UInt64 DEFAULT toUInt64(toUnixTimestamp64Nano(now64(9))) +) +ENGINE = ReplacingMergeTree(version) +ORDER BY (org, namespace, invite_id) +TTL toDateTime(expires_at) + INTERVAL 7 DAY +SETTINGS non_replicated_deduplication_window = 1000; diff --git a/schemas/schema.sql b/schemas/schema.sql index 312e196b7fa..865cd96f7e7 100644 --- a/schemas/schema.sql +++ b/schemas/schema.sql @@ -3393,6 +3393,27 @@ ENGINE = MergeTree ORDER BY (org, namespace, revision) SETTINGS non_replicated_deduplication_window = 1000, index_granularity = 8192; +-- loom.namespace_invites +CREATE TABLE IF NOT EXISTS loom.namespace_invites +( + `org` LowCardinality(String), + `namespace` LowCardinality(String), + `invite_id` String, + `email` String DEFAULT '', + `role` LowCardinality(String), + `created_by` String, + `created_at` DateTime64(3, 'UTC'), + `expires_at` UInt32, + `state` LowCardinality(String) DEFAULT 'open', + `accepted_by` String DEFAULT '', + `changed_at` DateTime64(3, 'UTC'), + `version` UInt64 DEFAULT toUInt64(toUnixTimestamp64Nano(now64(9))) +) +ENGINE = ReplacingMergeTree(version) +ORDER BY (org, namespace, invite_id) +TTL toDateTime(expires_at) + toIntervalDay(7) +SETTINGS non_replicated_deduplication_window = 1000, index_granularity = 8192; + -- loom.namespace_ontology CREATE TABLE IF NOT EXISTS loom.namespace_ontology ( diff --git a/server/auth/grant_claims.py b/server/auth/grant_claims.py index 7092f532bdd..fb2a22aa5a9 100644 --- a/server/auth/grant_claims.py +++ b/server/auth/grant_claims.py @@ -17,7 +17,8 @@ `hand_down_lineage`); then an address's sign-up claim (`self_signup.email_claim`); then an org's collection tree or a SCIM group; then a subject's repository claim (`maintainers.repo_change`), the repository's admins and the namespaces' -admins, or the trusts; then a bot or a grant (several sorted by namespace). +admins, or the trusts; then an invitation (`invite_change`); then a bot or a grant +(several sorted by namespace). Taken the other way round, two changes wait each other out and both answer 503. """ @@ -56,6 +57,14 @@ def grant_change(org: str, namespace: str, subject: str) -> AbstractAsyncContext ) +def invite_change(org: str, namespace: str, invite_id: str) -> AbstractAsyncContextManager[None]: + """Hold one invitation from the read that finds it open to the write that accepts or + cancels it: two people opening one link at once must not both be let in.""" + return _claimed( + "invite:" + json.dumps([org, namespace, invite_id]), f"an invitation to {org}/{namespace}" + ) + + def admins_change(org: str, namespace: str) -> AbstractAsyncContextManager[None]: """Hold the set of admins of `namespace` (or of a repository's branches, as `repo:`). A change that may take admin from someone takes it before the diff --git a/server/erasure/store/census.py b/server/erasure/store/census.py index 1e0ce762ad3..85c458bea09 100644 --- a/server/erasure/store/census.py +++ b/server/erasure/store/census.py @@ -747,6 +747,11 @@ def owner(self, scope_type: str) -> str | None: "loom.oauth_claims": "auth plane: no code path writes it; never holds memory content.", "loom.grant_claims": "auth plane: no code path writes it; never holds memory content.", "loom.service_accounts": "auth plane: service-account definitions.", + "loom.namespace_invites": ( + "auth plane: invitations to a namespace (the address invited, a role, who made and " + "who accepted it; the link's secret only as a SHA-256), dropped a week after the " + "link expires; no memory content." + ), "loom.user_state": "per-subject UI state (default namespace).", # -- ledgers of the erasure itself, kept by design ---------- "loom.erasure_requests": "the erasure ledger; scope_value names the scope, 90-day TTL.", diff --git a/server/identity/api/models_grants.py b/server/identity/api/models_grants.py index c91c2d480d5..d64bd1d9e8a 100644 --- a/server/identity/api/models_grants.py +++ b/server/identity/api/models_grants.py @@ -210,3 +210,80 @@ class GrantsUnshareAgentOutput(BaseModel): revoked: bool # When the revoke was written (UTC); None when nothing was revoked. revoked_at: datetime | None = None + + +class GrantsInviteInput(BaseModel): + org: str + namespace: str + # The person to give `role`: a login handle or an email. An account that signs in + # under it (by its handle or a verified email) is granted the role at once; an email + # no account holds gets an invitation link; a handle no account holds is refused. + to: str = Field(min_length=1, max_length=320) + # `viewer`, `writer` or `admin`; a code namespace takes only `viewer` and `admin`. + role: GrantRoleStr + + +class GrantsInviteOutput(BaseModel): + # "granted": an account holds `to` and now has the role; "invited": no account + # holds the email, and `link_path` opens the invitation. + outcome: Literal["granted", "invited"] + role: GrantRoleStr + # On "granted", the login handle the grant is written under. + subject: str = "" + # On "invited": the invitation, for grants.cancel_invite. + invite_id: str = "" + # On "invited": the dashboard path that accepts it, its secret in the fragment. Returned + # this once; Loom keeps only the secret's hash. + link_path: str = "" + # `link_path` on the server's public_base_url; "" when that is unset. + url: str = "" + # On "invited": when the link stops working (UTC), seven days on. + expires_at: datetime | None = None + # On "invited": the link was emailed to `to` (the server has mail settings). + emailed: bool = False + + +class GrantsListInvitesInput(BaseModel): + org: str + namespace: str + + +class _InviteEntry(BaseModel): + invite_id: str + # The address the invitation was made for. + email: str + role: GrantRoleStr + created_by: str + created_at: datetime + expires_at: datetime + + +class GrantsListInvitesOutput(BaseModel): + # The namespace's invitations not yet accepted, cancelled or expired, newest first; + # at most 200. + rows: list[_InviteEntry] + + +class GrantsCancelInviteInput(BaseModel): + org: str + namespace: str + invite_id: str = Field(min_length=1, max_length=64) + + +class GrantsCancelInviteOutput(BaseModel): + # True when an open invitation was cancelled; false when none was open under the id. + cancelled: bool + + +class GrantsAcceptInviteInput(BaseModel): + org: str + # The namespace the link names. + namespace: str + # The secret from the link's fragment. + secret: str = Field(min_length=1, max_length=128) + + +class GrantsAcceptInviteOutput(BaseModel): + namespace: str + # The caller's role on the namespace now: the invitation's, or a higher one they held. + role: GrantRoleStr diff --git a/server/identity/api/ops_grants.py b/server/identity/api/ops_grants.py index 002ec3400f9..aac8bd60fb6 100644 --- a/server/identity/api/ops_grants.py +++ b/server/identity/api/ops_grants.py @@ -3,11 +3,19 @@ from __future__ import annotations from server.identity.api.models_grants import ( + GrantsAcceptInviteInput, + GrantsAcceptInviteOutput, GrantsApproveInput, GrantsApproveOutput, + GrantsCancelInviteInput, + GrantsCancelInviteOutput, GrantsCreateInput, GrantsCreateOutput, + GrantsInviteInput, + GrantsInviteOutput, GrantsListInput, + GrantsListInvitesInput, + GrantsListInvitesOutput, GrantsListOutput, GrantsPendingForMeInput, GrantsPendingForMeOutput, @@ -29,6 +37,12 @@ handle_grants_pending_for_me, handle_grants_revoke, ) +from server.identity.app.invites import ( + handle_grants_accept_invite, + handle_grants_cancel_invite, + handle_grants_invite, + handle_grants_list_invites, +) from server.operations.base import Operation, Role grants_create = Operation( @@ -116,6 +130,56 @@ audit=True, ) +grants_invite = Operation( + name="grants.invite", + maturity="experimental", + input_model=GrantsInviteInput, + output_model=GrantsInviteOutput, + handler=handle_grants_invite, + # A retry after a lost reply makes a second link; the first stays listed to cancel. + idempotent=False, + required_role=Role.ADMIN, + audit=True, +) + +grants_list_invites = Operation( + name="grants.list_invites", + maturity="experimental", + input_model=GrantsListInvitesInput, + output_model=GrantsListInvitesOutput, + handler=handle_grants_list_invites, + idempotent=True, + # The addresses invited are the admins' to see, as the people to approve are. + required_role=Role.ADMIN, + audit=False, +) + +grants_cancel_invite = Operation( + name="grants.cancel_invite", + maturity="experimental", + input_model=GrantsCancelInviteInput, + output_model=GrantsCancelInviteOutput, + handler=handle_grants_cancel_invite, + idempotent=True, + required_role=Role.ADMIN, + audit=True, +) + +# The person accepting holds no grant on the namespace yet: the link's secret is what +# admits them, and the handler checks it, the person and the org. +grants_accept_invite = Operation( + name="grants.accept_invite", + maturity="experimental", + input_model=GrantsAcceptInviteInput, + output_model=GrantsAcceptInviteOutput, + handler=handle_grants_accept_invite, + # A second call finds the link used and answers 404. + idempotent=False, + required_role=Role.VIEWER, + audit=True, + skip_namespace_authz=True, +) + OPERATIONS: list[Operation] = [ grants_create, @@ -125,4 +189,8 @@ grants_approve, grants_share_agent, grants_unshare_agent, + grants_invite, + grants_list_invites, + grants_cancel_invite, + grants_accept_invite, ] diff --git a/server/identity/app/grants.py b/server/identity/app/grants.py index 9c5101a54ba..09b038babd3 100644 --- a/server/identity/app/grants.py +++ b/server/identity/app/grants.py @@ -190,14 +190,19 @@ async def handle_grants_create(input: GrantsCreateInput) -> GrantsCreateOutput: async def create_grant( - input: GrantsCreateInput, may_replace: Callable[[GrantState], None] | None = None + input: GrantsCreateInput, + may_replace: Callable[[GrantState], None] | None = None, + *, + issuer: str | None = None, ) -> GrantsCreateOutput: """`grants.create`; `may_replace` raises for a live row this caller must - not write over, checked on the row read under the grant's claim.""" + not write over, checked on the row read under the grant's claim. `issuer` + is stamped as `granted_by` in place of the caller: the maker of an + invitation the caller accepts.""" await _enforce_code_ceiling(input.org, input.namespace, input.role) _enforce_principal_target(input.namespace, input.subject) async with _group_held(input.org, input.subject): - now = await _create_grant(input, may_replace) + now = await _create_grant(input, may_replace, issuer) return GrantsCreateOutput( org=input.org, namespace=input.namespace, @@ -208,7 +213,9 @@ async def create_grant( async def _create_grant( - input: GrantsCreateInput, may_replace: Callable[[GrantState], None] | None + input: GrantsCreateInput, + may_replace: Callable[[GrantState], None] | None, + issuer: str | None = None, ) -> datetime: """`grants.create`'s write and what follows it; returns when it was granted.""" # A grant to a verified email is written under its account's login handle, so the @@ -217,7 +224,7 @@ async def _create_grant( from server.auth.aliases import canonical_subject subject = await canonical_subject(input.org, input.subject) - now = await _write_or_lower(input, subject, may_replace) + now = await _write_or_lower(input, subject, may_replace, issuer) if input.role == "admin": # Admin flows to the repository's other branches: from an operator entry to # all of them, from a page-added branch to standard page-added ones. @@ -228,21 +235,24 @@ async def _create_grant( async def _write_or_lower( - input: GrantsCreateInput, subject: str, may_replace: Callable[[GrantState], None] | None + input: GrantsCreateInput, + subject: str, + may_replace: Callable[[GrantState], None] | None, + issuer: str | None = None, ) -> datetime: """Write the grant under its own claim, unless it lowers an active admin: only `replace=true` lowers a grant (else 409), and that goes through `_taking_admin`.""" async def _write(_row: GrantState | None) -> datetime: - return await _write_grant(input, subject, may_replace) + return await _write_grant(input, subject, may_replace, issuer) async with grant_change(input.org, input.namespace, subject): row = None if input.replace and input.role != "admin": row = await grants_repo.find_any_grant(input.org, input.namespace, subject) if row is None or not _active_admin(row): - return await _write_grant(input, subject, may_replace) + return await _write_grant(input, subject, may_replace, issuer) return await _taking_admin(input, subject, _write, lowered_to=input.role) @@ -250,6 +260,7 @@ async def _write_grant( input: GrantsCreateInput, subject: str, may_replace: Callable[[GrantState], None] | None = None, + issuer: str | None = None, ) -> datetime: """`grants.create`'s read of the current grant and its write, under the grant's claim.""" @@ -267,7 +278,9 @@ async def _write_grant( from server.auth.context import current_auth auth = current_auth() - granted_by = auth.subject if auth is not None and auth.subject else input.granted_by or "admin" + granted_by = issuer or ( + auth.subject if auth is not None and auth.subject else input.granted_by or "admin" + ) await grants_repo.insert_row( { "org": input.org, diff --git a/server/identity/app/invite_mail.py b/server/identity/app/invite_mail.py new file mode 100644 index 00000000000..1265843c9d4 --- /dev/null +++ b/server/identity/app/invite_mail.py @@ -0,0 +1,83 @@ +"""The invitation email, sent over SMTP when `smtp_url`, `mail_from` and +`public_base_url` are set. A failed send is logged and reported as not sent: the +invitation stands, and whoever made it copies the link instead.""" + +from __future__ import annotations + +import asyncio +import logging +import smtplib +import ssl +from datetime import UTC, datetime +from email.message import EmailMessage +from urllib.parse import unquote, urlsplit + +from server.core.logging_config import log_value +from server.settings import settings + +log = logging.getLogger(__name__) + +_TIMEOUT_S = 10 + + +def can_send() -> bool: + return bool(settings.smtp_url and settings.mail_from and settings.public_base_url) + + +def _message( + to: str, *, inviter: str, namespace: str, role: str, url: str, expires_at: int +) -> EmailMessage: + until = datetime.fromtimestamp(expires_at, UTC).strftime("%d %B %Y, %H:%M UTC") + msg = EmailMessage() + msg["From"] = settings.mail_from + msg["To"] = to + msg["Subject"] = f"{inviter} invited you to {namespace} on Loom" + msg.set_content( + f"{inviter} invited you to the Loom namespace {namespace} as a {role}.\n\n" + f"Open this link, sign in, and accept:\n{url}\n\n" + f"The link works once, until {until}. If you did not expect it, ignore this email.\n" + ) + return msg + + +def _send(msg: EmailMessage) -> None: + u = urlsplit(settings.smtp_url) + host = u.hostname or "" + tls = ssl.create_default_context() + client: smtplib.SMTP + if u.scheme == "smtps": + client = smtplib.SMTP_SSL(host, u.port or 465, context=tls, timeout=_TIMEOUT_S) + elif u.scheme == "smtp": + client = smtplib.SMTP(host, u.port or 587, timeout=_TIMEOUT_S) + else: + raise ValueError("smtp_url must start with smtp:// or smtps://") + with client: + if u.scheme == "smtp": + client.ehlo() + if client.has_extn("starttls"): + client.starttls(context=tls) + client.ehlo() + elif u.username: + # The password is never sent in the clear. + raise smtplib.SMTPNotSupportedError("the server offers no STARTTLS for the login") + if u.username: + client.login(unquote(u.username), unquote(u.password or "")) + client.send_message(msg) + + +async def send_invite( + to: str, *, inviter: str, namespace: str, role: str, url: str, expires_at: int +) -> bool: + """Email the link to `to`; True when the mail server took it.""" + if not (to and can_send()): + return False + try: + # Inside: the email library refuses a header with a line break in it. + msg = _message( + to, inviter=inviter, namespace=namespace, role=role, url=url, expires_at=expires_at + ) + await asyncio.to_thread(_send, msg) + except Exception as e: # noqa: BLE001 — a failed email leaves the link to copy + log.warning("invite mail: not sent to %s: %s", log_value(repr(to)), type(e).__name__) + return False + return True diff --git a/server/identity/app/invites.py b/server/identity/app/invites.py new file mode 100644 index 00000000000..0daa15317a5 --- /dev/null +++ b/server/identity/app/invites.py @@ -0,0 +1,222 @@ +"""grants.{invite,list_invites,cancel_invite,accept_invite} handlers. + +`grants.invite` gives a person a role by what an admin knows of them. An account +that signs in under the handle or verified email is granted at once. An email no +account holds gets an invitation: a link whose secret only its hash is kept of, +emailed when the server has mail settings, which gives whoever opens it, once, the +role, under the account they sign in with. A password account's email is never +verified, so this is how a person is reached by email on a server without single +sign-on. A handle no account holds is refused, so a typo is never kept as a grant +for whoever signs up under it later. +""" + +from __future__ import annotations + +import contextlib +import re +import time +from datetime import UTC, datetime + +from server.auth.grant_claims import invite_change +from server.core.errors import GrantWouldDowngradeError, NotFoundError, ValidationError +from server.core.principals import SERVICE_ACCOUNT, has_aliases, is_reserved_subject +from server.identity.api.models_grants import ( + GrantsAcceptInviteInput, + GrantsAcceptInviteOutput, + GrantsCancelInviteInput, + GrantsCancelInviteOutput, + GrantsCreateInput, + GrantsInviteInput, + GrantsInviteOutput, + GrantsListInvitesInput, + GrantsListInvitesOutput, + _InviteEntry, +) +from server.identity.app import invite_mail +from server.identity.app.grants import ( + _enforce_code_ceiling, + _enforce_principal_target, + create_grant, +) +from server.identity.domain import invites as domain +from server.identity.store import invites as invites_repo +from server.identity.store import namespaces as namespaces_repo +from server.operations.base import GRANT_ROLES, GrantRoleStr +from server.settings import settings + +# The open invitations a namespace lists. +_LISTED = 200 +_EMAIL = re.compile(r"[^@\s]+@[^@\s]+\.[^@\s]+") +_GONE = "this invitation link is used, cancelled or expired: ask for a new one" + + +def _role(value: str) -> GrantRoleStr: + """A role read back from a row written from a GrantRoleStr.""" + return next(r for r in GRANT_ROLES if r == value) + + +def _caller() -> str: + from server.auth.context import current_auth + + auth = current_auth() + return str(auth.subject) if auth is not None and auth.subject else "admin" + + +def _person(to: str) -> str: + """`to` as a person's spelling, or a refusal that names the op for the others.""" + person = to.strip() + if not has_aliases(person) or is_reserved_subject(person) or person.startswith(SERVICE_ACCOUNT): + raise ValidationError( + "invite a person by login handle or email; grants.create grants a service account, " + "a group or everyone" + ) + return person + + +async def _held(org: str, person: str) -> str | None: + """The subject an account signs in as for `person`: its handle, or the handle a + verified email ties to; None when no account does.""" + from server.auth.aliases import canonical_subject + + subject = await canonical_subject(org, person) + if subject != person or await namespaces_repo.has_account(org, person): + return subject + return None + + +async def handle_grants_invite(input: GrantsInviteInput) -> GrantsInviteOutput: + person = _person(input.to) + _enforce_principal_target(input.namespace, person) + subject = await _held(input.org, person) + if subject is not None: + await create_grant( + GrantsCreateInput( + org=input.org, namespace=input.namespace, subject=person, role=input.role + ) + ) + return GrantsInviteOutput(outcome="granted", role=input.role, subject=subject) + if "@" not in person: + raise NotFoundError( + f"no account in {input.org} signs in as {person!r}: check the login handle, " + "or invite them by email" + ) + if not _EMAIL.fullmatch(person): + raise ValidationError(f"{person!r} is not an email address") + await _enforce_code_ceiling(input.org, input.namespace, input.role) + return await _invite(input, person.lower()) + + +async def _invite(input: GrantsInviteInput, email: str) -> GrantsInviteOutput: + secret = domain.new_secret() + now = datetime.now(UTC) + invite = domain.Invite( + org=input.org, + namespace=input.namespace, + invite_id=domain.invite_id(secret), + email=email, + role=input.role, + created_by=_caller(), + created_at=now, + expires_at=int(now.timestamp()) + domain.TTL_S, + ) + await invites_repo.put(invite) + path = domain.link_path(input.org, input.namespace, secret) + base = settings.public_base_url.strip().rstrip("/") + url = f"{base}{path}" if base else "" + emailed = await invite_mail.send_invite( + email, + inviter=invite.created_by, + namespace=input.namespace, + role=input.role, + url=url, + expires_at=invite.expires_at, + ) + return GrantsInviteOutput( + outcome="invited", + role=input.role, + invite_id=invite.invite_id, + link_path=path, + url=url, + expires_at=datetime.fromtimestamp(invite.expires_at, UTC), + emailed=emailed, + ) + + +async def handle_grants_list_invites(input: GrantsListInvitesInput) -> GrantsListInvitesOutput: + rows = await invites_repo.open_on(input.org, input.namespace, int(time.time()), _LISTED) + return GrantsListInvitesOutput( + rows=[ + _InviteEntry( + invite_id=r.invite_id, + email=r.email, + role=_role(r.role), + created_by=r.created_by, + created_at=r.created_at, + expires_at=datetime.fromtimestamp(r.expires_at, UTC), + ) + for r in rows + ] + ) + + +async def handle_grants_cancel_invite(input: GrantsCancelInviteInput) -> GrantsCancelInviteOutput: + async with invite_change(input.org, input.namespace, input.invite_id): + invite = await invites_repo.get(input.org, input.namespace, input.invite_id) + if invite is None or not invite.is_open(int(time.time())): + return GrantsCancelInviteOutput(cancelled=False) + await invites_repo.put(invite.settled("cancelled", _caller(), datetime.now(UTC))) + return GrantsCancelInviteOutput(cancelled=True) + + +def _accepter(org: str) -> str: + """The signed-in person accepting: a service account, a principal or a token of + another org is refused.""" + from server.auth.context import current_auth + + auth = current_auth() + if auth is None or not auth.subject: + raise ValidationError("sign in to accept an invitation") + subject = str(auth.subject) + if auth.is_service_account or not has_aliases(subject) or is_reserved_subject(subject): + raise ValidationError("an invitation is accepted by a person, signed in as themselves") + if auth.org != org: + raise ValidationError(f"this invitation is to {org}: sign in to {org} to accept it") + return subject + + +async def handle_grants_accept_invite(input: GrantsAcceptInviteInput) -> GrantsAcceptInviteOutput: + subject = _accepter(input.org) + invite_id = domain.invite_id(input.secret) + async with invite_change(input.org, input.namespace, invite_id): + invite = await invites_repo.get(input.org, input.namespace, invite_id) + if invite is None or not invite.is_open(int(time.time())): + raise NotFoundError(_GONE) + if not await namespaces_repo.is_active(input.org, input.namespace): + raise NotFoundError(_GONE) + # Spent before the grant, under the claim: a link never lets two people in. + await invites_repo.put(invite.settled("accepted", subject, datetime.now(UTC))) + try: + role = await _grant(invite, subject) + except BaseException: + # Still under the claim, so no one took it since: a failed grant leaves the + # link open for another try. A failed put-back leaves it used, never open twice. + with contextlib.suppress(Exception): + await invites_repo.put(invite) + raise + return GrantsAcceptInviteOutput(namespace=input.namespace, role=role) + + +async def _grant(invite: domain.Invite, subject: str) -> GrantRoleStr: + """The invitation's role for `subject`, stamped as granted by its maker; a higher + role they hold already stands.""" + role = _role(invite.role) + try: + await create_grant( + GrantsCreateInput( + org=invite.org, namespace=invite.namespace, subject=subject, role=role + ), + issuer=invite.created_by, + ) + except GrantWouldDowngradeError as e: + return _role(str(e.extra["current_role"])) + return role diff --git a/server/identity/domain/invites.py b/server/identity/domain/invites.py new file mode 100644 index 00000000000..1247de0e653 --- /dev/null +++ b/server/identity/domain/invites.py @@ -0,0 +1,85 @@ +"""An invitation to a namespace: a link that gives whoever opens it, once, a role there. + +The link carries a random secret; Loom keeps only its SHA-256 (`invite_id`), so a row +read out of storage is not a working link. An invitation is open until it is +accepted, cancelled or `expires_at` passes. +""" + +from __future__ import annotations + +import hashlib +import secrets +from dataclasses import asdict, dataclass, replace +from datetime import datetime +from typing import Any, Literal +from urllib.parse import quote + +from server.core.datetimes import as_aware_utc + +InviteState = Literal["open", "accepted", "cancelled"] + +# How long a link stays open. +TTL_S = 7 * 86400 + + +def new_secret() -> str: + return secrets.token_urlsafe(32) + + +def invite_id(secret: str) -> str: + return hashlib.sha256(secret.encode()).hexdigest() + + +def link_path(org: str, namespace: str, secret: str) -> str: + """The dashboard path that accepts it. The secret is the fragment, which a browser + never sends to a server or puts in a Referer.""" + return f"/invite?org={quote(org, safe='')}&namespace={quote(namespace, safe='')}#{secret}" + + +@dataclass(frozen=True) +class Invite: + org: str + namespace: str + invite_id: str + email: str + role: str + created_by: str + created_at: datetime + expires_at: int + state: InviteState = "open" + accepted_by: str = "" + changed_at: datetime | None = None + + def is_open(self, now: int) -> bool: + return self.state == "open" and now < self.expires_at + + def settled(self, state: InviteState, by: str, at: datetime) -> Invite: + return replace( + self, state=state, accepted_by=by if state == "accepted" else "", changed_at=at + ) + + def row(self) -> dict[str, Any]: + out = asdict(self) + out["changed_at"] = self.changed_at or self.created_at + return out + + @classmethod + def from_row(cls, r: dict[str, Any]) -> Invite: + state = str(r.get("state") or "open") + return cls( + org=str(r["org"]), + namespace=str(r["namespace"]), + invite_id=str(r["invite_id"]), + email=str(r.get("email") or ""), + role=str(r["role"]), + created_by=str(r.get("created_by") or ""), + created_at=as_aware_utc(r["created_at"]), + expires_at=int(r["expires_at"]), + state="accepted" + if state == "accepted" + else "cancelled" + if state == "cancelled" + else "open", + accepted_by=str(r.get("accepted_by") or ""), + changed_at=as_aware_utc(r.get("changed_at")), + ) diff --git a/server/identity/store/invites.py b/server/identity/store/invites.py new file mode 100644 index 00000000000..8f46143a2cb --- /dev/null +++ b/server/identity/store/invites.py @@ -0,0 +1,61 @@ +"""Repository for loom.namespace_invites. + +One row per invitation, keyed by (org, namespace, invite_id); `invite_id` is the +SHA-256 of the link's secret. ReplacingMergeTree(version) keeps the newest +state, so an acceptance or a cancellation is a new row with a version past the +last (`next_version`). The caller holds the invitation's claim +(`grant_claims.invite_change`) from its read to that write. +""" + +from __future__ import annotations + +from typing import Any + +from server.core.ch import own_write_reads +from server.core.repo_base import _CHClient, _default_client +from server.core.versions import next_version +from server.identity.domain.invites import Invite + +TABLE = "loom.namespace_invites" +_COLUMNS = ( + "org, namespace, invite_id, email, role, created_by, created_at, expires_at, state, " + "accepted_by, changed_at" +) + + +async def put(invite: Invite, *, ch: _CHClient | None = None) -> None: + client = ch or _default_client() + row = invite.row() + row["version"] = await next_version( + client, + TABLE, + {"org": invite.org, "namespace": invite.namespace, "invite_id": invite.invite_id}, + ) + await client.insert(TABLE, [row], settings={"async_insert": 0, "wait_for_async_insert": 1}) + + +async def get( + org: str, namespace: str, invite_id: str, *, ch: _CHClient | None = None +) -> Invite | None: + """The invitation's newest state, read past a write another replica just took.""" + with own_write_reads(): + row = await (ch or _default_client()).query_one( + f"SELECT {_COLUMNS} FROM {TABLE} FINAL WHERE org = {{org:String}} " + "AND namespace = {ns:String} AND invite_id = {id:String} LIMIT 1", + params={"org": org, "ns": namespace, "id": invite_id}, + ) + return Invite.from_row(dict(row)) if row else None + + +async def open_on( + org: str, namespace: str, now: int, limit: int, *, ch: _CHClient | None = None +) -> list[Invite]: + """The namespace's invitations still open at `now` (Unix seconds), newest first.""" + with own_write_reads(): + rows: list[dict[str, Any]] = await (ch or _default_client()).query_all( + f"SELECT {_COLUMNS} FROM {TABLE} FINAL WHERE org = {{org:String}} " + "AND namespace = {ns:String} AND state = 'open' AND expires_at > {now:UInt32} " + "ORDER BY created_at DESC LIMIT {limit:UInt32}", + params={"org": org, "ns": namespace, "now": now, "limit": limit}, + ) + return [Invite.from_row(dict(r)) for r in rows] diff --git a/server/identity/store/namespaces.py b/server/identity/store/namespaces.py index aae3c35355d..f4533c775d6 100644 --- a/server/identity/store/namespaces.py +++ b/server/identity/store/namespaces.py @@ -9,6 +9,7 @@ from datetime import datetime from typing import Any +from server.core.ch import own_write_reads from server.core.repo_base import _CHClient, _default_client @@ -92,6 +93,22 @@ async def is_active(org: str, namespace: str, *, ch: _CHClient | None = None) -> return row is not None +async def has_account(org: str, subject: str, *, ch: _CHClient | None = None) -> bool: + """Does an active account of `org` sign in as `subject` (its login handle, in any + case)? Read past an account another replica just made.""" + with own_write_reads(): + row = await (ch or _default_client()).query_one( + """ + SELECT 1 AS one FROM loom.namespaces FINAL + WHERE org = {org:String} AND ifNull(active, true) = true + AND owner_email != '' AND lower(owner_email) = lower({sub:String}) + LIMIT 1 + """, + params={"org": org, "sub": subject}, + ) + return row is not None + + async def labels( org: str, namespaces: list[str], *, ch: _CHClient | None = None ) -> dict[str, dict[str, str]]: diff --git a/server/settings/_env.py b/server/settings/_env.py index c68d526cdef..a56237d0cb3 100644 --- a/server/settings/_env.py +++ b/server/settings/_env.py @@ -149,6 +149,8 @@ def unknown_env_keys(fields: Iterable[str], env_file: str | None) -> list[str]: r"(?:^|_)otlp_headers$", # A Postgres DSN carries the password: the memory authority's and the router's. r"(?:^|_)pg_dsn$", + # Its userinfo is the mail server's login. + r"^smtp_url$", ) ) ) diff --git a/server/settings/catalog.py b/server/settings/catalog.py index 898f926e553..b8d382a89d0 100644 --- a/server/settings/catalog.py +++ b/server/settings/catalog.py @@ -460,6 +460,14 @@ def trusted_issuers(self) -> set[str]: # Default org for self-signed tokens. self_signup_org: str = "dev" + # The mail server an invitation is emailed through: `smtps://user:password@host:465` + # (TLS from the start) or `smtp://user:password@host:587` (STARTTLS, which a login + # requires). Empty: no email is sent, and whoever makes an invitation sends its link. + smtp_url: str = "" + # The From address of an invitation email, e.g. `Loom `. Empty + # sends none, as does an empty smtp_url or public_base_url (the link needs it). + mail_from: str = "" + # How callers authenticate: "single-user" (no auth, one anonymous identity), # "trust-network" (self-signup, first claim wins) or "gateway" (an upstream proxy # mints short-lived Loom JWTs with the shared HS256 secret; Loom only validates). @@ -6570,9 +6578,14 @@ class TrackerSettings(BaseModel): "facts.related": 60, # One frontier query per hop, up to max_hops. "facts.traverse": 200, + "grants.accept_invite": 150, "grants.approve": 80, + "grants.cancel_invite": 80, "grants.create": 50, + # A mail server's round trip when the invitation is emailed. + "grants.invite": 3000, "grants.list": 80, + "grants.list_invites": 80, "grants.pending_for_me": 150, "grants.revoke": 80, "grants.share_agent": 80, diff --git a/tests/integration/test_grants_invite.py b/tests/integration/test_grants_invite.py new file mode 100644 index 00000000000..e31f0f68242 --- /dev/null +++ b/tests/integration/test_grants_invite.py @@ -0,0 +1,111 @@ +"""An admin invites a person by an email no account holds; the person, signed in under +another login handle, accepts the link once and holds the role under that handle, +granted by the admin. Runs against a real Control Plane + ClickHouse (LOOM_BASE_URL, +LOOM_CH_*).""" + +from __future__ import annotations + +import uuid +from urllib.parse import urlsplit + +import httpx + +from tests.integration._resources import unique_org + + +def _person_token(*, org: str, subject: str, namespaces: list[str], roles: list[str]) -> str: + from server.auth.jwt import mint_token + + return mint_token( + subject=subject, + org=org, + namespaces=namespaces, + roles=roles, + ttl_seconds=600, + is_service_account=False, + ) + + +def _post(base: str, token: str, op: str, payload: dict) -> httpx.Response: + with httpx.Client(base_url=base, timeout=30.0) as c: + return c.post(f"/v1/{op}", json=payload, headers={"Authorization": f"Bearer {token}"}) + + +def _register(base: str, token: str, org: str, namespace: str, owner: str) -> None: + body = {"org": org, "namespace": namespace, "owner_email": owner} + r = _post(base, token, "namespace.register", body) + assert r.status_code == 200, r.text + + +def test_an_invited_email_is_accepted_once_under_the_accepters_handle( + control_plane_url: str, +) -> None: + org = unique_org("invite") + ns = f"ns-{uuid.uuid4().hex[:8]}" + admin = _person_token(org=org, subject="ann-admin", namespaces=[ns], roles=["admin"]) + _register(control_plane_url, admin, org, ns, "ann-admin") + + r = _post( + control_plane_url, + admin, + "grants.invite", + {"org": org, "namespace": ns, "to": "michael@example.com", "role": "writer"}, + ) + assert r.status_code == 200, r.text + made = r.json() + assert made["outcome"] == "invited" + secret = urlsplit(made["link_path"]).fragment + listed = _post(control_plane_url, admin, "grants.list_invites", {"org": org, "namespace": ns}) + assert [row["email"] for row in listed.json()["rows"]] == ["michael@example.com"] + + # The person signs in under a handle that is not the email. + person = _person_token(org=org, subject="mlex", namespaces=[f"home-{ns}"], roles=["viewer"]) + body = {"org": org, "namespace": ns, "secret": secret} + r = _post(control_plane_url, person, "grants.accept_invite", body) + assert r.status_code == 200, r.text + assert r.json() == {"namespace": ns, "role": "writer"} + + grants = _post(control_plane_url, admin, "grants.list", {"org": org, "namespace": ns}) + mine = [g for g in grants.json()["rows"] if g["subject"] == "mlex"] + assert [(g["role"], g["granted_by"]) for g in mine] == [("writer", "ann-admin")] + + # Spent: a second open of the link admits nobody, and it is no longer listed. + other = _person_token(org=org, subject="someone", namespaces=[f"x-{ns}"], roles=["viewer"]) + again = _post(control_plane_url, other, "grants.accept_invite", body) + assert again.status_code == 404, again.text + listed = _post(control_plane_url, admin, "grants.list_invites", {"org": org, "namespace": ns}) + assert listed.json()["rows"] == [] + + +def test_a_handle_no_account_holds_is_refused(control_plane_url: str) -> None: + org = unique_org("invite") + ns = f"ns-{uuid.uuid4().hex[:8]}" + admin = _person_token(org=org, subject="ann-admin", namespaces=[ns], roles=["admin"]) + _register(control_plane_url, admin, org, ns, "ann-admin") + r = _post( + control_plane_url, + admin, + "grants.invite", + {"org": org, "namespace": ns, "to": "no-such-handle", "role": "viewer"}, + ) + assert r.status_code == 404, r.text + grants = _post(control_plane_url, admin, "grants.list", {"org": org, "namespace": ns}) + assert all(g["subject"] != "no-such-handle" for g in grants.json()["rows"]) + + +def test_a_handle_an_account_signs_in_as_is_granted_at_once(control_plane_url: str) -> None: + org = unique_org("invite") + ns = f"ns-{uuid.uuid4().hex[:8]}" + home = f"home-{ns}" + person = _person_token(org=org, subject="mlex", namespaces=[home], roles=["admin"]) + _register(control_plane_url, person, org, home, "mlex") + admin = _person_token(org=org, subject="ann-admin", namespaces=[ns], roles=["admin"]) + _register(control_plane_url, admin, org, ns, "ann-admin") + r = _post( + control_plane_url, + admin, + "grants.invite", + {"org": org, "namespace": ns, "to": "MLex", "role": "viewer"}, + ) + assert r.status_code == 200, r.text + assert (r.json()["outcome"], r.json()["link_path"]) == ("granted", "") diff --git a/tests/unit/test_grants_invite.py b/tests/unit/test_grants_invite.py new file mode 100644 index 00000000000..965947eff30 --- /dev/null +++ b/tests/unit/test_grants_invite.py @@ -0,0 +1,279 @@ +"""grants.invite gives a person a role by their handle or email: a grant when an account +signs in under it, an invitation link for an email no account holds, and a refusal for +a handle no account holds. grants.accept_invite spends a link once, for the signed-in +person, stamped as granted by the invitation's maker; a failed grant leaves it open.""" + +from __future__ import annotations + +import contextlib +import time +from collections.abc import AsyncIterator, Iterator +from dataclasses import replace +from typing import Any +from urllib.parse import parse_qs, urlsplit + +import pytest + +from server.auth.context import set_current_auth +from server.auth.jwt import AuthInfo +from server.core.errors import ( + BackendUnavailableError, + GrantWouldDowngradeError, + NotFoundError, + ValidationError, +) +from server.identity.api.models_grants import ( + GrantsAcceptInviteInput, + GrantsCancelInviteInput, + GrantsCreateInput, + GrantsInviteInput, + GrantsListInvitesInput, +) +from server.identity.app import invite_mail +from server.identity.app import invites as mod +from server.identity.domain import invites as domain +from server.operations.base import Role +from server.settings import settings + + +class World: + """The rows the handlers read and write, in memory.""" + + def __init__(self) -> None: + self.invites: dict[str, domain.Invite] = {} + self.writes: list[domain.Invite] = [] + self.accounts = {"mlex"} + self.verified = {"sso@example.com": "sso-handle"} + self.grants: list[tuple[GrantsCreateInput, str | None]] = [] + self.grant_error: BaseException | None = None + self.mail: list[dict[str, Any]] = [] + + +@pytest.fixture +def world(monkeypatch: pytest.MonkeyPatch) -> Iterator[World]: + w = World() + + async def put(invite: domain.Invite, **_: Any) -> None: + w.invites[invite.invite_id] = invite + w.writes.append(invite) + + async def get(org: str, namespace: str, invite_id: str, **_: Any) -> domain.Invite | None: + found = w.invites.get(invite_id) + return found if found and (found.org, found.namespace) == (org, namespace) else None + + async def open_on(org: str, namespace: str, now: int, limit: int, **_: Any) -> list[domain.Invite]: + return [i for i in w.invites.values() if i.is_open(now)][:limit] + + async def has_account(org: str, subject: str, **_: Any) -> bool: + return subject.lower() in w.accounts + + async def is_active(org: str, namespace: str, **_: Any) -> bool: + return True + + async def canonical(org: str, subject: str, **_: Any) -> str: + return w.verified.get(subject.lower(), subject) + + async def create_grant(input: GrantsCreateInput, *_a: Any, issuer: str | None = None) -> None: + if w.grant_error is not None: + raise w.grant_error + w.grants.append((input, issuer)) + + async def no_ceiling(*_a: Any, **_k: Any) -> None: + return None + + @contextlib.asynccontextmanager + async def claimed(*_a: Any) -> AsyncIterator[None]: + yield + + async def send(to: str, **kw: Any) -> bool: + w.mail.append({"to": to, **kw}) + return True + + monkeypatch.setattr(mod.invites_repo, "put", put) + monkeypatch.setattr(mod.invites_repo, "get", get) + monkeypatch.setattr(mod.invites_repo, "open_on", open_on) + monkeypatch.setattr(mod.namespaces_repo, "has_account", has_account) + monkeypatch.setattr(mod.namespaces_repo, "is_active", is_active) + monkeypatch.setattr("server.auth.aliases.canonical_subject", canonical) + monkeypatch.setattr(mod, "create_grant", create_grant) + monkeypatch.setattr(mod, "_enforce_code_ceiling", no_ceiling) + monkeypatch.setattr(mod, "invite_change", claimed) + monkeypatch.setattr(mod.invite_mail, "send_invite", send) + signed_in("admin-ann") + yield w + set_current_auth(None) + + +def signed_in(subject: str, *, org: str = "o", service: bool = False) -> None: + set_current_auth( + AuthInfo( + subject=subject, + org=org, + namespaces=("ns",), + roles=(Role.WRITER,), + is_service_account=service, + ) + ) + + +async def invite(to: str, role: str = "writer") -> Any: + return await mod.handle_grants_invite( + GrantsInviteInput(org="o", namespace="ns", to=to, role=role) # type: ignore[arg-type] + ) + + +def secret_of(link_path: str) -> str: + parts = urlsplit(link_path) + assert parts.path == "/invite" + assert parse_qs(parts.query) == {"org": ["o"], "namespace": ["ns"]} + return parts.fragment + + +async def accept(secret: str) -> Any: + return await mod.handle_grants_accept_invite( + GrantsAcceptInviteInput(org="o", namespace="ns", secret=secret) + ) + + +@pytest.mark.asyncio +async def test_a_handle_an_account_signs_in_as_is_granted_at_once(world: World) -> None: + out = await invite("MLex") + assert (out.outcome, out.subject, out.link_path) == ("granted", "MLex", "") + assert [(g.subject, g.role) for g, _ in world.grants] == [("MLex", "writer")] + assert world.invites == {} + + +@pytest.mark.asyncio +async def test_a_verified_email_is_granted_under_its_handle(world: World) -> None: + out = await invite("sso@example.com", "viewer") + assert (out.outcome, out.subject) == ("granted", "sso-handle") + assert world.invites == {} + + +@pytest.mark.asyncio +async def test_a_handle_no_account_holds_is_refused_and_writes_nothing(world: World) -> None: + with pytest.raises(NotFoundError, match="no account in o signs in as 'mlexx'"): + await invite("mlexx") + assert world.grants == [] and world.invites == {} + + +@pytest.mark.parametrize("to", ["sa:bot", "group:eng", "everyone", "user:42", "agent:x"]) +@pytest.mark.asyncio +async def test_a_principal_is_left_to_grants_create(world: World, to: str) -> None: + with pytest.raises(ValidationError, match="grants.create"): + await invite(to) + + +@pytest.mark.asyncio +async def test_an_email_no_account_holds_gets_a_link_kept_only_as_its_hash(world: World) -> None: + out = await invite("Michael@Example.com") + assert out.outcome == "invited" and out.emailed is True + secret = secret_of(out.link_path) + stored = world.invites[out.invite_id] + assert out.invite_id == domain.invite_id(secret) != secret + assert secret not in repr(stored) + assert (stored.email, stored.role, stored.created_by, stored.state) == ( + "michael@example.com", + "writer", + "admin-ann", + "open", + ) + assert stored.expires_at - time.time() == pytest.approx(domain.TTL_S, abs=5) + assert world.mail[0]["to"] == "michael@example.com" + listed = await mod.handle_grants_list_invites(GrantsListInvitesInput(org="o", namespace="ns")) + assert [r.email for r in listed.rows] == ["michael@example.com"] + + +@pytest.mark.asyncio +async def test_the_link_lets_one_person_in_once_as_granted_by_its_maker(world: World) -> None: + secret = secret_of((await invite("michael@example.com")).link_path) + signed_in("mlex") + out = await accept(secret) + assert (out.namespace, out.role) == ("ns", "writer") + assert [(g.subject, g.role, issuer) for g, issuer in world.grants] == [ + ("mlex", "writer", "admin-ann") + ] + assert world.invites[domain.invite_id(secret)].accepted_by == "mlex" + signed_in("someone-else") + with pytest.raises(NotFoundError, match="used, cancelled or expired"): + await accept(secret) + assert len(world.grants) == 1 + + +@pytest.mark.asyncio +async def test_a_higher_role_held_already_stands(world: World) -> None: + secret = secret_of((await invite("michael@example.com", "viewer")).link_path) + world.grant_error = GrantWouldDowngradeError(current_role="admin", requested_role="viewer") + signed_in("mlex") + assert (await accept(secret)).role == "admin" + assert world.invites[domain.invite_id(secret)].state == "accepted" + + +@pytest.mark.asyncio +async def test_a_failed_grant_leaves_the_link_open(world: World) -> None: + secret = secret_of((await invite("michael@example.com")).link_path) + world.grant_error = BackendUnavailableError("down") + signed_in("mlex") + with pytest.raises(BackendUnavailableError): + await accept(secret) + iid = domain.invite_id(secret) + assert [w.state for w in world.writes if w.invite_id == iid] == ["open", "accepted", "open"] + world.grant_error = None + assert (await accept(secret)).role == "writer" + + +@pytest.mark.asyncio +async def test_an_expired_or_cancelled_link_admits_nobody(world: World) -> None: + expired = secret_of((await invite("a@example.com")).link_path) + iid = domain.invite_id(expired) + world.invites[iid] = replace(world.invites[iid], expires_at=int(time.time()) - 1) + cancelled = (await invite("b@example.com")).invite_id + out = await mod.handle_grants_cancel_invite( + GrantsCancelInviteInput(org="o", namespace="ns", invite_id=cancelled) + ) + assert out.cancelled is True + again = await mod.handle_grants_cancel_invite( + GrantsCancelInviteInput(org="o", namespace="ns", invite_id=cancelled) + ) + assert again.cancelled is False + signed_in("mlex") + with pytest.raises(NotFoundError): + await accept(expired) + with pytest.raises(NotFoundError): + await accept("not-a-link") + assert world.grants == [] + + +@pytest.mark.parametrize( + ("subject", "org", "service", "words"), + [ + ("sa:bot", "o", True, "a person"), + ("group:eng", "o", False, "a person"), + ("mlex", "other", False, "sign in to o"), + ], +) +@pytest.mark.asyncio +async def test_only_a_person_of_the_org_accepts( + world: World, subject: str, org: str, service: bool, words: str +) -> None: + secret = secret_of((await invite("michael@example.com")).link_path) + signed_in(subject, org=org, service=service) + with pytest.raises(ValidationError, match=words): + await accept(secret) + assert world.invites[domain.invite_id(secret)].state == "open" + + +@pytest.mark.asyncio +async def test_no_mail_settings_send_nothing(monkeypatch: pytest.MonkeyPatch) -> None: + sent: list[Any] = [] + monkeypatch.setattr(invite_mail, "_send", sent.append) + monkeypatch.setattr(settings, "smtp_url", "") + args = {"inviter": "ann", "namespace": "ns", "role": "writer", "url": "u", "expires_at": 0} + assert await invite_mail.send_invite("m@example.com", **args) is False + monkeypatch.setattr(settings, "smtp_url", "smtp://mail.example.com") + monkeypatch.setattr(settings, "mail_from", "Loom ") + monkeypatch.setattr(settings, "public_base_url", "https://loom.example.com") + assert await invite_mail.send_invite("m@example.com", **{**args, "url": "https://x/l#s"}) + assert "https://x/l#s" in sent[0].get_content() + # A header with a line break is refused by the email library: reported as not sent. + assert await invite_mail.send_invite("m@example.com\nBcc: x@y.z", **args) is False From 15c46f01eda0f92902a5cffa0252be1277596fd5 Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Fri, 4 Dec 2026 21:04:11 +0530 Subject: [PATCH 02/28] grants: accept an invitation from Namespaces in your org; SDKs, reference and design docs Co-Authored-By: Claude Opus 5.5 Signed-off-by: Lareb Zafar --- docs/architecture/sharing.md | 33 + docs/features/namespaces-and-sharing.md | 35 +- docs/reference/operations.md | 6 +- docs/reference/operations/grants.md | 64 + docs/reference/schema.md | 3 +- docs/reference/status.md | 4 +- frontend/src/App.tsx | 2 + frontend/src/api/invites.ts | 51 + frontend/src/lib/boot.ts | 25 + frontend/src/views/Browse.tsx | 2 + frontend/src/views/InvitationCard.test.tsx | 81 + frontend/src/views/InvitationCard.tsx | 91 + sdk/go/client.gen.go | 79 + sdk/go/wire/models.gen.go | 84 +- sdk/python/loom/client.py | 35 + sdk/python/loom/ops.py | 137 + sdk/ruby/lib/clickhouse/loom/generated/ops.rb | 30 +- sdk/rust/src/blocking_operations.rs | 68 + sdk/rust/src/operations.rs | 72 + sdk/rust/src/wire_models.rs | 6608 +++++++++-------- sdk/rust/tests/registry_contracts.rs | 79 + sdk/typescript/src/generated/ops.ts | 71 +- server/identity/domain/invites.py | 8 +- server/operations/reach_manifest.py | 16 + tests/integration/test_grants_invite.py | 4 +- tests/unit/test_grants_invite.py | 11 +- 26 files changed, 4524 insertions(+), 3175 deletions(-) create mode 100644 frontend/src/api/invites.ts create mode 100644 frontend/src/views/InvitationCard.test.tsx create mode 100644 frontend/src/views/InvitationCard.tsx diff --git a/docs/architecture/sharing.md b/docs/architecture/sharing.md index 9dd427d934f..5231bc7fbac 100644 --- a/docs/architecture/sharing.md +++ b/docs/architecture/sharing.md @@ -194,6 +194,31 @@ admin. The group lands in that org; a member is a user id, held as `user:`. Membership is read by Loom on every request, never claimed by a token, so removing a member takes effect within the consistency window below. +## Invitations + +`grants.invite` gives a person a role by what an admin knows of them. A login handle an +account signs in under, or an email verified for one (an SSO account or an `sso_links` +row), is granted at once through `grants.create`. Any other email gets an invitation: a +`loom.namespace_invites` row and the link `/spaces#invite=&org=…&namespace=…`. The +link is the credential. Only the secret's SHA-256 is stored, as the row's `invite_id`, and +the link works once, for seven days. The server emails it when `smtp_url`, `mail_from` and +`public_base_url` are set; otherwise, or when the send fails, the answer carries the link +for the admin to pass on. A handle no account holds is refused with 404, so a typo is never +kept as a grant for whoever signs up under that handle later. + +`grants.accept_invite` gives the invitation's role to the signed-in caller, under the +handle they sign in with, stamped `granted_by` the invitation's maker. Only a person's +token accepts: a service account, a grant principal or a token of another org is refused. +It runs under a lease per invitation (`grant_claims.invite_change`) and marks the +invitation accepted before the grant, so one link never admits two people; a failed grant +puts it back open. A higher role the caller holds already stands. + +A password account's email is never verified, which is why an email reaches one only +through an invitation: the link went to that address, and opening it proves the reader +got it. The whole link is a fragment, which a browser never sends to a server or puts in a +Referer; the dashboard moves it into the tab's session storage at boot, so a single +sign-on round trip keeps it. + ## Consistency Every change to a grant, a group or the tree writes a row to `loom.acl_versions` for its @@ -370,6 +395,14 @@ One text serves agents and people, so there is no second copy to drift. principals and differs per user; no one sort order clusters every user's union. - **Group membership in a token claim.** A claim is fixed until the token expires, so a removed member keeps access for the token's life. +- **A confirmation email for every password account.** Verified emails would let a grant + by email bind at sign-in, but every server would need mail to sign anyone up; an + invitation works with or without mail. +- **A pending grant by email, bound at the first sign-in under that email.** A password + sign-up names any email it likes, so whoever registered the address first would take + the grant. +- **The invitation's secret in the query string.** It would reach access logs and Referer + headers. - **Inheritance resolved at write time.** Moving a collection would rewrite the grants of every descendant; resolving at check time from a cached tree costs a walk of at most eight parents. diff --git a/docs/features/namespaces-and-sharing.md b/docs/features/namespaces-and-sharing.md index 04d9efa95c0..523fec50eb0 100644 --- a/docs/features/namespaces-and-sharing.md +++ b/docs/features/namespaces-and-sharing.md @@ -71,18 +71,29 @@ account, or a service account `sa:`) a role on one namespace: `viewer` rea `writer` writes, `admin` manages grants and settings. The token carries the org and the namespaces it may reach; the grant table decides the role. -| Operation | Role | Does | -| -------------------------------------------------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `grants.create` | admin | Grant a role. A create below the subject's current role is refused with 409 `GRANT_WOULD_DOWNGRADE` unless `replace=true`. | -| `grants.list` | viewer | Who has access, at which role, and any `pending_role`. | -| `grants.revoke` | admin | Remove a grant. | -| `grants.approve` | admin | Approve or reject a pending request, optionally with a different role. | -| `grants.pending_for_me` | viewer | Every pending request in the namespaces the caller administers, org-wide. | -| `namespace.browse` | viewer | Public namespaces in the org, never a collection (`closed` ones only with `include_closed`). | -| `namespace.join` | viewer | Self-join a public namespace. `viewer` is granted at once; a `writer` or `admin` request always lands pending, with no access until an admin approves. | -| `namespace.leave`, `namespace.cancel_request`, `namespace.mark_seen` | viewer | Drop one's own grant, withdraw a pending request, acknowledge an invitation. | -| `namespace.list_mine` | viewer | The namespaces the caller belongs to, each with its `kind` (`collection` for a collection) and `title`. | -| `namespace.list` | org admin | Every namespace in the org. | +| Operation | Role | Does | +| -------------------------------------------------------------------- | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `grants.create` | admin | Grant a role. A create below the subject's current role is refused with 409 `GRANT_WOULD_DOWNGRADE` unless `replace=true`. | +| `grants.invite` | admin | Give a person a role by login handle or email. An account's handle, or an email verified for one, is granted at once; any other email gets a single-use invitation link, emailed when the server has mail settings. A handle no account holds is refused. | +| `grants.list_invites`, `grants.cancel_invite` | admin | The open invitations, and withdraw one. | +| `grants.accept_invite` | a signed-in person | Accept an invitation link: its role goes to the account the caller signs in as. | +| `grants.list` | viewer | Who has access, at which role, and any `pending_role`. | +| `grants.revoke` | admin | Remove a grant. | +| `grants.approve` | admin | Approve or reject a pending request, optionally with a different role. | +| `grants.pending_for_me` | viewer | Every pending request in the namespaces the caller administers, org-wide. | +| `namespace.browse` | viewer | Public namespaces in the org, never a collection (`closed` ones only with `include_closed`). | +| `namespace.join` | viewer | Self-join a public namespace. `viewer` is granted at once; a `writer` or `admin` request always lands pending, with no access until an admin approves. | +| `namespace.leave`, `namespace.cancel_request`, `namespace.mark_seen` | viewer | Drop one's own grant, withdraw a pending request, acknowledge an invitation. | +| `namespace.list_mine` | viewer | The namespaces the caller belongs to, each with its `kind` (`collection` for a collection) and `title`. | +| `namespace.list` | org admin | Every namespace in the org. | + +A password account's email is never verified, so a grant by email reaches such an +account only through an invitation. The link is `/spaces#invite=…` on the dashboard, works +once within seven days, and gives its role to whoever opens it signed in, under their own +login handle, as granted by the admin who made it. To have the server email it, set +`LOOM_SMTP_URL` (`smtps://user:password@host:465`, or `smtp://…:587` with STARTTLS), +`LOOM_MAIL_FROM` and `LOOM_PUBLIC_BASE_URL`; without them, or when a send fails, the +dashboard shows the link to copy. The design is in [sharing](../architecture/sharing.md#invitations). Minting tokens, service accounts, read scopes and restricted namespaces are covered in the [tokens and grants guide](../guides/tokens-and-grants.md). diff --git a/docs/reference/operations.md b/docs/reference/operations.md index afcfd662669..60e5267e87c 100644 --- a/docs/reference/operations.md +++ b/docs/reference/operations.md @@ -124,7 +124,7 @@ python scripts/codegen/docs_reference.py --check # exit 1 when a region is stal -387 operations in 43 groups. Every op is served at `POST /v1/` and as the MCP tool `loom_` (dots become underscores). +391 operations in 43 groups. Every op is served at `POST /v1/` and as the MCP tool `loom_` (dots become underscores). Columns: **Role** is the minimum role (`viewer` < `writer` < `admin` < `org_admin` < `platform_admin`); **Kind** is `read` (idempotent, viewer, unaudited, writes nothing — MCP `readOnlyHint`), `idempotent` (safe to retry) or `write`; **Listed under `all`** says whether an MCP connection on the `all` toolset lists the op in `tools/list` (`code.*` ops only with `LOOM_MCP_CODE_TOOLS=true`); an op marked `no` is still callable by name or through `loom_op`, unless it is hidden from MCP; **Audit** marks ops that leave an `audit_log` row. @@ -376,9 +376,13 @@ Fields for every `grants` op: [operations/grants.md](operations/grants.md). | Operation | Summary | Role | Kind | Listed under `all` | Audit | | --- | --- | --- | --- | --- | --- | +| [`grants.accept_invite`](operations/grants.md#grantsaccept_invite) | | viewer | write | no | yes | | [`grants.approve`](operations/grants.md#grantsapprove) | Approve (or reject) a pending grant request. | admin | idempotent | no | yes | +| [`grants.cancel_invite`](operations/grants.md#grantscancel_invite) | | admin | idempotent | no | yes | | [`grants.create`](operations/grants.md#grantscreate) | Grant another subject (user or service-account) viewer / writer / admin role on a namespace. | admin | idempotent | yes | yes | +| [`grants.invite`](operations/grants.md#grantsinvite) | | admin | write | no | yes | | [`grants.list`](operations/grants.md#grantslist) | List active grants on a namespace — who has access, at which role. | viewer | read | yes | | +| [`grants.list_invites`](operations/grants.md#grantslist_invites) | | admin | idempotent | no | | | [`grants.pending_for_me`](operations/grants.md#grantspending_for_me) | Every pending request in the namespaces the caller administers, in one statement. | viewer | read | no | | | [`grants.revoke`](operations/grants.md#grantsrevoke) | Remove a subject's grant on a namespace. | admin | idempotent | no | yes | | [`grants.share_agent`](operations/grants.md#grantsshare_agent) | Let another agent of the caller's trust read, or write, the caller's own namespace. | writer | idempotent | no | yes | diff --git a/docs/reference/operations/grants.md b/docs/reference/operations/grants.md index 52365d7121b..7b3c91c31dd 100644 --- a/docs/reference/operations/grants.md +++ b/docs/reference/operations/grants.md @@ -8,6 +8,21 @@ Every op is `POST /v1/` over HTTP and the MCP tool `loom_`. The identity +## `grants.accept_invite` + +`POST /v1/grants.accept_invite` · MCP `loom_grants_accept_invite` · role `viewer` · write · audited · not listed under the MCP `all` toolset + +| Input field | Type | Default | Meaning | +| --- | --- | --- | --- | +| `org` | `str` | required | The tenant (first element of the identity tuple). | +| `namespace` | `str` | required | The namespace the link names. | +| `secret` | `str` | required | The secret from the link's fragment. | + +| Output field | Type | Meaning | +| --- | --- | --- | +| `namespace` | `str` | The namespace the op reads or writes. | +| `role` | `Literal['viewer', 'writer', 'admin']` | The caller's role on the namespace now: the invitation's, or a higher one they held. | + ## `grants.approve` Approve (or reject) a pending grant request. @@ -30,6 +45,20 @@ Approve (or reject) a pending grant request. | `role` | `Literal['viewer', 'writer', 'admin'] \| None` | The role approved (for `reject`, the role the request would have had); None when no grant row existed for the subject. | | `decided_at` | `datetime` | When the decision was written (UTC). | +## `grants.cancel_invite` + +`POST /v1/grants.cancel_invite` · MCP `loom_grants_cancel_invite` · role `admin` · idempotent · audited · not listed under the MCP `all` toolset + +| Input field | Type | Default | Meaning | +| --- | --- | --- | --- | +| `org` | `str` | required | The tenant (first element of the identity tuple). | +| `namespace` | `str` | required | The namespace the op reads or writes. | +| `invite_id` | `str` | required | | + +| Output field | Type | Meaning | +| --- | --- | --- | +| `cancelled` | `bool` | True when an open invitation was cancelled; false when none was open under the id. | + ## `grants.create` Grant another subject (user or service-account) viewer / writer / admin role on a namespace. @@ -53,6 +82,28 @@ Grant another subject (user or service-account) viewer / writer / admin role on | `role` | `Literal['viewer', 'writer', 'admin']` | The role now active for the subject. | | `granted_at` | `datetime` | When the grant row was written (UTC). | +## `grants.invite` + +`POST /v1/grants.invite` · MCP `loom_grants_invite` · role `admin` · write · audited · not listed under the MCP `all` toolset + +| Input field | Type | Default | Meaning | +| --- | --- | --- | --- | +| `org` | `str` | required | The tenant (first element of the identity tuple). | +| `namespace` | `str` | required | The namespace the op reads or writes. | +| `to` | `str` | required | The person to give `role`: a login handle or an email. | +| `role` | `Literal['viewer', 'writer', 'admin']` | required | `viewer`, `writer` or `admin`; a code namespace takes only `viewer` and `admin`. | + +| Output field | Type | Meaning | +| --- | --- | --- | +| `outcome` | `Literal['granted', 'invited']` | "granted": an account holds `to` and now has the role; "invited": no account holds the email, and `link_path` opens the invitation. | +| `role` | `Literal['viewer', 'writer', 'admin']` | | +| `subject` | `str` | On "granted", the login handle the grant is written under. | +| `invite_id` | `str` | On "invited": the invitation, for grants.cancel_invite. | +| `link_path` | `str` | On "invited": the dashboard path that accepts it, its secret in the fragment. | +| `url` | `str` | `link_path` on the server's public_base_url; "" when that is unset. | +| `expires_at` | `datetime \| None` | On "invited": when the link stops working (UTC), seven days on. | +| `emailed` | `bool` | On "invited": the link was emailed to `to` (the server has mail settings). | + ## `grants.list` List active grants on a namespace — who has access, at which role. @@ -73,6 +124,19 @@ List active grants on a namespace — who has access, at which role. | `next_cursor` | `str \| None` | Pass as `cursor` for the next page; None when this page is the last. | | `truncated` | `bool` | True when more people follow this page (`next_cursor` is set). | +## `grants.list_invites` + +`POST /v1/grants.list_invites` · MCP `loom_grants_list_invites` · role `admin` · idempotent · not listed under the MCP `all` toolset + +| Input field | Type | Default | Meaning | +| --- | --- | --- | --- | +| `org` | `str` | required | The tenant (first element of the identity tuple). | +| `namespace` | `str` | required | The namespace the op reads or writes. | + +| Output field | Type | Meaning | +| --- | --- | --- | +| `rows` | `list[_InviteEntry]` | The namespace's invitations not yet accepted, cancelled or expired, newest first; at most 200. | + ## `grants.pending_for_me` Every pending request in the namespaces the caller administers, in one statement. diff --git a/docs/reference/schema.md b/docs/reference/schema.md index 60356c1f341..d8eddf35dcf 100644 --- a/docs/reference/schema.md +++ b/docs/reference/schema.md @@ -142,7 +142,7 @@ the `loom` tables each view reads, and, for each materialized view, its target, -198 tables, 5 views and 19 materialized views in the `loom` and `loom_telemetry` databases; a `loom_telemetry` object keeps its database prefix. +199 tables, 5 views and 19 materialized views in the `loom` and `loom_telemetry` databases; a `loom_telemetry` object keeps its database prefix. #### Tables @@ -291,6 +291,7 @@ the `loom` tables each view reads, and, for each materialized view, its target, | `namespace_calibration_result` | `ReplacingMergeTree(version)` | `(org, namespace)` | | | | | `namespace_grants` | `ReplacingMergeTree(version)` | `(org, namespace, subject)` | `org` | | | | `namespace_guides` | `MergeTree` | `(org, namespace, revision)` | | | | +| `namespace_invites` | `ReplacingMergeTree(version)` | `(org, namespace, invite_id)` | | `toDateTime(expires_at) + toIntervalDay(7)` | | | `namespace_ontology` | `ReplacingMergeTree(version)` | `(org, namespace, kind, name)` | `org` | | | | `namespace_policies` | `ReplacingMergeTree(version)` | `(org, namespace, policy_id)` | | | | | `namespace_snapshots` | `MergeTree` | `(org, source_namespace, created_at)` | `org` | | | diff --git a/docs/reference/status.md b/docs/reference/status.md index 760593c1673..74bac516a0d 100644 --- a/docs/reference/status.md +++ b/docs/reference/status.md @@ -25,7 +25,7 @@ serves is in the [MCP reference](./mcp.md#toolsets). -387 operations, 273 of them experimental. +391 operations, 277 of them experimental. | Group | Stable | Experimental | | --- | --- | --- | @@ -47,7 +47,7 @@ serves is in the [MCP reference](./mcp.md#toolsets). | `erasure` | 2 | [`erasure.list`](operations/erasure.md#erasurelist), [`erasure.status`](operations/erasure.md#erasurestatus) | | `extraction_policy` | 0 | [`extraction_policy.clear`](operations/extraction_policy.md#extraction_policyclear), [`extraction_policy.get`](operations/extraction_policy.md#extraction_policyget), [`extraction_policy.set`](operations/extraction_policy.md#extraction_policyset) | | `facts` | 2 | [`facts.expire_by_adapter`](operations/facts.md#factsexpire_by_adapter), [`facts.path`](operations/facts.md#factspath), [`facts.related`](operations/facts.md#factsrelated) | -| `grants` | 2 | [`grants.approve`](operations/grants.md#grantsapprove), [`grants.pending_for_me`](operations/grants.md#grantspending_for_me), [`grants.revoke`](operations/grants.md#grantsrevoke), [`grants.share_agent`](operations/grants.md#grantsshare_agent), [`grants.unshare_agent`](operations/grants.md#grantsunshare_agent) | +| `grants` | 2 | [`grants.accept_invite`](operations/grants.md#grantsaccept_invite), [`grants.approve`](operations/grants.md#grantsapprove), [`grants.cancel_invite`](operations/grants.md#grantscancel_invite), [`grants.invite`](operations/grants.md#grantsinvite), [`grants.list_invites`](operations/grants.md#grantslist_invites), [`grants.pending_for_me`](operations/grants.md#grantspending_for_me), [`grants.revoke`](operations/grants.md#grantsrevoke), [`grants.share_agent`](operations/grants.md#grantsshare_agent), [`grants.unshare_agent`](operations/grants.md#grantsunshare_agent) | | `help` | 0 | [`help.get`](operations/help.md#helpget), [`help.search`](operations/help.md#helpsearch) | | `inbox` | 0 | [`inbox.list`](operations/inbox.md#inboxlist), [`inbox.policy_list`](operations/inbox.md#inboxpolicy_list), [`inbox.policy_set`](operations/inbox.md#inboxpolicy_set), [`inbox.principals`](operations/inbox.md#inboxprincipals), [`inbox.register`](operations/inbox.md#inboxregister) | | `insights` | 0 | [`insights.catalog`](operations/insights.md#insightscatalog), [`insights.query`](operations/insights.md#insightsquery) | diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 52c2b393172..709ec2912c5 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -34,6 +34,7 @@ import { provisionalNamespace, rememberKinds, sameAccount, + takeInviteLink, takeLinkToken, takeSignInStarted, takeSsoAsk, @@ -310,6 +311,7 @@ export default function App() { // and scrubbed before anything can fail. The return to the page its sign-in started on // is a chunk of its own, and boot goes on without it. link = takeLinkToken(); + takeInviteLink(); const started = takeSignInStarted(link?.nonce ?? null); if (takeSsoAsk()) setSsoAsked(true); if (link) { diff --git a/frontend/src/api/invites.ts b/frontend/src/api/invites.ts new file mode 100644 index 00000000000..55a344a46bd --- /dev/null +++ b/frontend/src/api/invites.ts @@ -0,0 +1,51 @@ +// Inviting a person to a namespace: by a login handle or verified email they are granted at +// once; by any other email they get a single-use link, emailed when the server can send mail. +// Wire shapes mirror server/identity/api/models_grants.py. +import { post } from "../api"; +import type { GrantRole, Identity } from "../api"; + +type Scope = Pick; + +export interface InviteResult { + outcome: "granted" | "invited"; + role: GrantRole; + /** The subject granted, for `granted`. */ + subject: string; + invite_id: string; + /** `/invite?org=…&namespace=…#`, for `invited`: the link without the server's address. */ + link_path: string; + /** The whole link, when the server knows its public address. */ + url: string; + expires_at: string | null; + emailed: boolean; +} + +export interface OpenInvite { + invite_id: string; + email: string; + role: GrantRole; + created_by: string; + created_at: string; + expires_at: string; +} + +export function invite(id: Scope, to: string, role: GrantRole): Promise { + return post("/v1/grants.invite", { org: id.org, namespace: id.namespace, to, role }); +} + +export function listInvites(id: Scope): Promise<{ rows: OpenInvite[] }> { + return post("/v1/grants.list_invites", { org: id.org, namespace: id.namespace }); +} + +export function cancelInvite(id: Scope, inviteId: string): Promise<{ cancelled: boolean }> { + return post("/v1/grants.cancel_invite", { org: id.org, namespace: id.namespace, invite_id: inviteId }); +} + +export function acceptInvite(id: Scope, secret: string): Promise<{ namespace: string; role: GrantRole }> { + return post("/v1/grants.accept_invite", { org: id.org, namespace: id.namespace, secret }); +} + +/** The link to hand over: the server's own address when it knows it, else this page's. */ +export function inviteLink(r: Pick): string { + return r.url || `${window.location.origin}${r.link_path}`; +} diff --git a/frontend/src/lib/boot.ts b/frontend/src/lib/boot.ts index 86cfb1b192d..0a917cd2f49 100644 --- a/frontend/src/lib/boot.ts +++ b/frontend/src/lib/boot.ts @@ -145,6 +145,31 @@ export function takeLinkToken(): { token: string | null; atRoot: boolean; nonce: return { token, atRoot: fromHash && !qs && (pathname === "/" || pathname === "/me"), nonce }; } +/** The session key for an invitation link's `{ secret, org, namespace }`: boot moves it out + * of the address (`/spaces#invite=&org=…&namespace=…`) before the sign-in gate, so a + * single sign-on's round trip keeps it, and Namespaces in your org offers to accept it. */ +export const INVITE_LINK = "loom_invite_v1"; + +export interface InviteLink { + secret: string; + org: string; + namespace: string; +} + +/** Take an invitation link out of the address into this tab's session. */ +export function takeInviteLink(): void { + const { hash, pathname, search } = window.location; + if (!hash.startsWith("#invite=")) return; + history.replaceState(history.state, "", pathname + search); + const p = new URLSearchParams(hash.slice(1)); + const link = { secret: p.get("invite"), org: p.get("org"), namespace: p.get("namespace") }; + try { + if (link.secret && link.org && link.namespace) sessionStorage.setItem(INVITE_LINK, JSON.stringify(link)); + } catch { + /* no session storage: the link is opened again once signed in */ + } +} + /** Namespace kinds from the last membership answer this browser saw, so a * deep link can tell a memory namespace from a code or QA one before * list_mine answers again (a memory view never mounts on a code or tracker namespace; diff --git a/frontend/src/views/Browse.tsx b/frontend/src/views/Browse.tsx index 7db9aaa851e..60fa2c3d4c4 100644 --- a/frontend/src/views/Browse.tsx +++ b/frontend/src/views/Browse.tsx @@ -22,6 +22,7 @@ import { COLLECTION_PREFIX, NAMESPACE_NAME, isCollectionName, isPersonalCollecti import { canEditGuide, roleOnNamespace } from "../lib/namespaceRole"; import { callReason } from "../lib/callReason"; import { CreateNamespaceDialog } from "../flows/CreateNamespaceDialog"; +import { InvitationCard } from "./InvitationCard"; import { useStore, useIdentity } from "../lib/state"; import { RowSkeleton } from "../components/Skeleton"; import { Alert, ListRow, LoadingSkeleton, PageHeader, Panel, SectionHeading, Tip } from "../components/ui"; @@ -440,6 +441,7 @@ export function Browse() { A namespace is a project's or an agent's memory. Join public namespaces in your org, or invite people into the ones you manage.

+ {/* The Repositories hint: under the description, or inside the folded code section when there is one. */} {managedCode.length === 0 && repoHint &&
{repoHint}
} diff --git a/frontend/src/views/InvitationCard.test.tsx b/frontend/src/views/InvitationCard.test.tsx new file mode 100644 index 00000000000..40b02bf1aef --- /dev/null +++ b/frontend/src/views/InvitationCard.test.tsx @@ -0,0 +1,81 @@ +import { cleanup, render, screen } from "../test/rtl"; +import userEvent from "@testing-library/user-event"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import { acceptInvite } from "../api/invites"; +import { INVITE_LINK, takeInviteLink } from "../lib/boot"; +import { ApiError } from "../lib/errors"; +import { useStore } from "../lib/state"; +import { InvitationCard } from "./InvitationCard"; + +// An invitation link's secret rides in the fragment; boot moves it into the tab's session so +// a sign-in keeps it, and the card accepts it as the signed-in person. + +vi.mock("../api/invites", () => ({ acceptInvite: vi.fn() })); + +beforeEach(() => { + sessionStorage.clear(); + vi.mocked(acceptInvite).mockReset(); + useStore.setState({ identity: { org: "dev", namespace: "home", agent: "loom-ui" } }); +}); +afterEach(() => cleanup()); + +describe("takeInviteLink", () => { + it("moves the link out of the address into the session", () => { + history.replaceState(null, "", "/spaces#invite=s3cret&org=dev&namespace=team%2Falerts"); + takeInviteLink(); + expect(window.location.pathname + window.location.hash).toBe("/spaces"); + expect(JSON.parse(sessionStorage.getItem(INVITE_LINK) ?? "null")).toEqual({ + secret: "s3cret", + org: "dev", + namespace: "team/alerts", + }); + }); + + it("leaves any other fragment alone", () => { + history.replaceState(null, "", "/spaces#token=x"); + takeInviteLink(); + expect(window.location.hash).toBe("#token=x"); + expect(sessionStorage.getItem(INVITE_LINK)).toBeNull(); + }); +}); + +function opened(): void { + sessionStorage.setItem(INVITE_LINK, JSON.stringify({ secret: "s3cret", org: "dev", namespace: "alerts" })); + render(); +} + +describe("InvitationCard", () => { + it("accepts as the signed-in person and switches to the namespace", async () => { + vi.mocked(acceptInvite).mockResolvedValue({ namespace: "alerts", role: "writer" }); + const user = userEvent.setup(); + opened(); + expect(screen.getByRole("region", { name: "Invitation" })).toHaveTextContent("You're invited to alerts."); + await user.click(screen.getByRole("button", { name: "Accept invitation" })); + expect(acceptInvite).toHaveBeenCalledWith(expect.objectContaining({ org: "dev", namespace: "alerts" }), "s3cret"); + expect(useStore.getState().identity?.namespace).toBe("alerts"); + expect(sessionStorage.getItem(INVITE_LINK)).toBeNull(); + expect(screen.queryByRole("region", { name: "Invitation" })).toBeNull(); + }); + + it("says why a spent link is refused and offers only Close", async () => { + vi.mocked(acceptInvite).mockRejectedValue( + new ApiError({ + status: 404, + code: "NOT_FOUND", + message: "this invitation link is used, cancelled or expired: ask for a new one", + }), + ); + const user = userEvent.setup(); + opened(); + await user.click(screen.getByRole("button", { name: "Accept invitation" })); + expect(await screen.findByText(/used, cancelled or expired/)).toBeInTheDocument(); + expect(screen.queryByRole("button", { name: "Accept invitation" })).toBeNull(); + expect(sessionStorage.getItem(INVITE_LINK)).toBeNull(); + expect(useStore.getState().identity?.namespace).toBe("home"); + }); + + it("shows nothing without an invitation", () => { + render(); + expect(screen.queryByRole("region", { name: "Invitation" })).toBeNull(); + }); +}); diff --git a/frontend/src/views/InvitationCard.tsx b/frontend/src/views/InvitationCard.tsx new file mode 100644 index 00000000000..0a9a37dc663 --- /dev/null +++ b/frontend/src/views/InvitationCard.tsx @@ -0,0 +1,91 @@ +import { useState } from "react"; +import { Button } from "@clickhouse/click-ui/Button"; +import { setSavedNamespace } from "../api"; +import { acceptInvite } from "../api/invites"; +import { Alert } from "../components/ui"; +import { toast } from "../components/Toast"; +import { INVITE_LINK, type InviteLink } from "../lib/boot"; +import { humanizeError } from "../lib/errorWords"; +import { ApiError } from "../lib/errors"; +import { invalidateShared } from "../lib/sharedReads"; +import { useStore } from "../lib/state"; + +function stashed(): InviteLink | null { + try { + const v = JSON.parse(sessionStorage.getItem(INVITE_LINK) ?? "null") as Partial | null; + if (v && typeof v.secret === "string" && typeof v.org === "string" && typeof v.namespace === "string") { + return { secret: v.secret, org: v.org, namespace: v.namespace }; + } + } catch { + /* unreadable: no invitation */ + } + return null; +} + +function drop(): void { + try { + sessionStorage.removeItem(INVITE_LINK); + } catch { + /* no session storage: nothing was kept */ + } +} + +/** The invitation link this tab opened (`lib/boot.ts` keeps it through the sign-in), for the + * signed-in person to accept. */ +export function InvitationCard() { + const [link, setLink] = useState(stashed); + const [busy, setBusy] = useState(false); + const [error, setError] = useState(null); + // The server refused the link (used, cancelled, expired, or for another org): only Close is left. + const [refused, setRefused] = useState(false); + const identity = useStore((s) => s.identity); + const setIdentity = useStore((s) => s.setIdentity); + if (!link) return null; + + const close = () => { + drop(); + setLink(null); + }; + const accept = async () => { + setBusy(true); + setError(null); + try { + const out = await acceptInvite(link, link.secret); + close(); + toast(`You're a ${out.role} on ${out.namespace}`, "ok"); + invalidateShared("mine:"); + if (identity && identity.org === link.org) { + setIdentity({ ...identity, namespace: out.namespace }); + setSavedNamespace(out.namespace); + } + } catch (e) { + if (e instanceof ApiError && e.status >= 400 && e.status < 500) { + drop(); + setRefused(true); + } + setError(humanizeError(e)); + setBusy(false); + } + }; + + return ( +
+

+ You're invited to {link.namespace} + {identity && identity.org !== link.org ? ` in ${link.org}` : ""}. Accepting gives the account you're signed in + as the role the invitation names. +

+ {error && } +
+ + {!refused && ( + + )} +
+
+ ); +} diff --git a/sdk/go/client.gen.go b/sdk/go/client.gen.go index 58cf76835f8..9adc8eb8b3d 100644 --- a/sdk/go/client.gen.go +++ b/sdk/go/client.gen.go @@ -1040,21 +1040,45 @@ type FindingEvidence = wire.FindingEvidence // GrantEntry is a model used by Loom operations. type GrantEntry = wire.GrantEntry +// GrantsAcceptInviteInput is the request to grants.accept_invite. +type GrantsAcceptInviteInput = wire.GrantsAcceptInviteInput + +// GrantsAcceptInviteOutput is the response from grants.accept_invite. +type GrantsAcceptInviteOutput = wire.GrantsAcceptInviteOutput + // GrantsApproveInput is the request to grants.approve. type GrantsApproveInput = wire.GrantsApproveInput // GrantsApproveOutput is the response from grants.approve. type GrantsApproveOutput = wire.GrantsApproveOutput +// GrantsCancelInviteInput is the request to grants.cancel_invite. +type GrantsCancelInviteInput = wire.GrantsCancelInviteInput + +// GrantsCancelInviteOutput is the response from grants.cancel_invite. +type GrantsCancelInviteOutput = wire.GrantsCancelInviteOutput + // GrantsCreateInput is the request to grants.create. type GrantsCreateInput = wire.GrantsCreateInput // GrantsCreateOutput is the response from grants.create. type GrantsCreateOutput = wire.GrantsCreateOutput +// GrantsInviteInput is the request to grants.invite. +type GrantsInviteInput = wire.GrantsInviteInput + +// GrantsInviteOutput is the response from grants.invite. +type GrantsInviteOutput = wire.GrantsInviteOutput + // GrantsListInput is the request to grants.list. type GrantsListInput = wire.GrantsListInput +// GrantsListInvitesInput is the request to grants.list_invites. +type GrantsListInvitesInput = wire.GrantsListInvitesInput + +// GrantsListInvitesOutput is the response from grants.list_invites. +type GrantsListInvitesOutput = wire.GrantsListInvitesOutput + // GrantsListOutput is the response from grants.list. type GrantsListOutput = wire.GrantsListOutput @@ -1199,6 +1223,9 @@ type InventoryScope = wire.InventoryScope // InventorySection is a model used by Loom operations. type InventorySection = wire.InventorySection +// InviteEntry is a model used by Loom operations. +type InviteEntry = wire.InviteEntry + // KnowledgeAddInput is the request to knowledge.add. type KnowledgeAddInput = wire.KnowledgeAddInput @@ -5219,6 +5246,20 @@ func (s FactsService) Traverse(ctx context.Context, seedEntity string, opts ...O return callOperation[FactsTraverseOutput](s.client, ctx, "facts.traverse", in) } +// AcceptInvite calls grants.accept_invite. +// Use WithInput to supply additional request fields. +func (s GrantsService) AcceptInvite(ctx context.Context, secret string, opts ...Option[GrantsAcceptInviteInput]) (*GrantsAcceptInviteOutput, error) { + in := applyOptions(opts) + in.Secret = secret + if in.Namespace == "" { + in.Namespace = s.client.identity.Namespace + } + if in.Org == "" { + in.Org = s.client.identity.Org + } + return callOperation[GrantsAcceptInviteOutput](s.client, ctx, "grants.accept_invite", in) +} + // Approve calls grants.approve. // Use WithInput to supply additional request fields. func (s GrantsService) Approve(ctx context.Context, subject string, opts ...Option[GrantsApproveInput]) (*GrantsApproveOutput, error) { @@ -5233,6 +5274,20 @@ func (s GrantsService) Approve(ctx context.Context, subject string, opts ...Opti return callOperation[GrantsApproveOutput](s.client, ctx, "grants.approve", in) } +// CancelInvite calls grants.cancel_invite. +// Use WithInput to supply additional request fields. +func (s GrantsService) CancelInvite(ctx context.Context, inviteID string, opts ...Option[GrantsCancelInviteInput]) (*GrantsCancelInviteOutput, error) { + in := applyOptions(opts) + in.InviteID = inviteID + if in.Namespace == "" { + in.Namespace = s.client.identity.Namespace + } + if in.Org == "" { + in.Org = s.client.identity.Org + } + return callOperation[GrantsCancelInviteOutput](s.client, ctx, "grants.cancel_invite", in) +} + // Create calls grants.create. func (s GrantsService) Create(ctx context.Context, in GrantsCreateInput) (*GrantsCreateOutput, error) { if in.Namespace == "" { @@ -5244,6 +5299,17 @@ func (s GrantsService) Create(ctx context.Context, in GrantsCreateInput) (*Grant return callOperation[GrantsCreateOutput](s.client, ctx, "grants.create", in) } +// Invite calls grants.invite. +func (s GrantsService) Invite(ctx context.Context, in GrantsInviteInput) (*GrantsInviteOutput, error) { + if in.Namespace == "" { + in.Namespace = s.client.identity.Namespace + } + if in.Org == "" { + in.Org = s.client.identity.Org + } + return callOperation[GrantsInviteOutput](s.client, ctx, "grants.invite", in) +} + // List calls grants.list. // Use WithInput to supply additional request fields. func (s GrantsService) List(ctx context.Context, opts ...Option[GrantsListInput]) (*GrantsListOutput, error) { @@ -5257,6 +5323,19 @@ func (s GrantsService) List(ctx context.Context, opts ...Option[GrantsListInput] return callOperation[GrantsListOutput](s.client, ctx, "grants.list", in) } +// ListInvites calls grants.list_invites. +// Use WithInput to supply additional request fields. +func (s GrantsService) ListInvites(ctx context.Context, opts ...Option[GrantsListInvitesInput]) (*GrantsListInvitesOutput, error) { + in := applyOptions(opts) + if in.Namespace == "" { + in.Namespace = s.client.identity.Namespace + } + if in.Org == "" { + in.Org = s.client.identity.Org + } + return callOperation[GrantsListInvitesOutput](s.client, ctx, "grants.list_invites", in) +} + // PendingForMe calls grants.pending_for_me. // Use WithInput to supply additional request fields. func (s GrantsService) PendingForMe(ctx context.Context, opts ...Option[GrantsPendingForMeInput]) (*GrantsPendingForMeOutput, error) { diff --git a/sdk/go/wire/models.gen.go b/sdk/go/wire/models.gen.go index 6868f00309f..9e054402ac6 100644 --- a/sdk/go/wire/models.gen.go +++ b/sdk/go/wire/models.gen.go @@ -1,5 +1,5 @@ // Code generated by scripts/codegen/sdk_go_gen.py; DO NOT EDIT. -// Registry model schema SHA-256: 89731d59fda7a96ab4476c4e23f20a5d4cb501cc1de5a67c5960b8ad4bbadc43 +// Registry model schema SHA-256: b84d43a094a462f8b3b155e0b91a44e9001ce452ef110174b3bcf3e5dd5651b4 // Package wire contains the Go requests and responses for Loom operations. package wire @@ -4478,6 +4478,23 @@ type GrantEntry struct { Also *[]string `json:"also,omitempty"` } +// GrantsAcceptInviteInput is the request to grants.accept_invite. +type GrantsAcceptInviteInput struct { + Org string `json:"org"` + Namespace string `json:"namespace"` + Secret string `json:"secret"` +} + +// GrantsAcceptInviteOutput is the response from grants.accept_invite. +type GrantsAcceptInviteOutput struct { + IgnoredArgs *[]string `json:"ignored_args,omitempty"` + DidYouMean *map[string]string `json:"did_you_mean,omitempty"` + Mirrored *bool `json:"mirrored,omitempty"` + Degraded *[]string `json:"degraded,omitempty"` + Namespace string `json:"namespace"` + Role string `json:"role"` +} + // GrantsApproveInput is the request to grants.approve. type GrantsApproveInput struct { Org string `json:"org"` @@ -4500,6 +4517,22 @@ type GrantsApproveOutput struct { DecidedAt string `json:"decided_at"` } +// GrantsCancelInviteInput is the request to grants.cancel_invite. +type GrantsCancelInviteInput struct { + Org string `json:"org"` + Namespace string `json:"namespace"` + InviteID string `json:"invite_id"` +} + +// GrantsCancelInviteOutput is the response from grants.cancel_invite. +type GrantsCancelInviteOutput struct { + IgnoredArgs *[]string `json:"ignored_args,omitempty"` + DidYouMean *map[string]string `json:"did_you_mean,omitempty"` + Mirrored *bool `json:"mirrored,omitempty"` + Degraded *[]string `json:"degraded,omitempty"` + Cancelled bool `json:"cancelled"` +} + // GrantsCreateInput is the request to grants.create. type GrantsCreateInput struct { Org string `json:"org"` @@ -4523,6 +4556,30 @@ type GrantsCreateOutput struct { GrantedAt string `json:"granted_at"` } +// GrantsInviteInput is the request to grants.invite. +type GrantsInviteInput struct { + Org string `json:"org"` + Namespace string `json:"namespace"` + To string `json:"to"` + Role string `json:"role"` +} + +// GrantsInviteOutput is the response from grants.invite. +type GrantsInviteOutput struct { + IgnoredArgs *[]string `json:"ignored_args,omitempty"` + DidYouMean *map[string]string `json:"did_you_mean,omitempty"` + Mirrored *bool `json:"mirrored,omitempty"` + Degraded *[]string `json:"degraded,omitempty"` + Outcome string `json:"outcome"` + Role string `json:"role"` + Subject *string `json:"subject,omitempty"` + InviteID *string `json:"invite_id,omitempty"` + LinkPath *string `json:"link_path,omitempty"` + URL *string `json:"url,omitempty"` + ExpiresAt Optional[string] `json:"expires_at,omitempty"` + Emailed *bool `json:"emailed,omitempty"` +} + // GrantsListInput is the request to grants.list. type GrantsListInput struct { Org string `json:"org"` @@ -4532,6 +4589,21 @@ type GrantsListInput struct { Fields Optional[[]string] `json:"fields,omitempty"` } +// GrantsListInvitesInput is the request to grants.list_invites. +type GrantsListInvitesInput struct { + Org string `json:"org"` + Namespace string `json:"namespace"` +} + +// GrantsListInvitesOutput is the response from grants.list_invites. +type GrantsListInvitesOutput struct { + IgnoredArgs *[]string `json:"ignored_args,omitempty"` + DidYouMean *map[string]string `json:"did_you_mean,omitempty"` + Mirrored *bool `json:"mirrored,omitempty"` + Degraded *[]string `json:"degraded,omitempty"` + Rows []InviteEntry `json:"rows"` +} + // GrantsListOutput is the response from grants.list. type GrantsListOutput struct { IgnoredArgs *[]string `json:"ignored_args,omitempty"` @@ -5051,6 +5123,16 @@ type InventorySection struct { Reason *string `json:"reason,omitempty"` } +// InviteEntry is a model used by Loom operations. +type InviteEntry struct { + InviteID string `json:"invite_id"` + Email string `json:"email"` + Role string `json:"role"` + CreatedBy string `json:"created_by"` + CreatedAt string `json:"created_at"` + ExpiresAt string `json:"expires_at"` +} + // KnowledgeAddInput is the request to knowledge.add. type KnowledgeAddInput struct { Org string `json:"org"` diff --git a/sdk/python/loom/client.py b/sdk/python/loom/client.py index 2ef9d024b81..3bd20dae8d8 100644 --- a/sdk/python/loom/client.py +++ b/sdk/python/loom/client.py @@ -1149,6 +1149,15 @@ class GrantsOps: def __init__(self, agent: Agent) -> None: self._agent = agent + async def accept_invite( + self, body: _ops.GrantsAcceptInviteBody | None = None, /, **options: Any + ) -> _ops.GrantsAcceptInviteOutput: + """`grants.accept_invite`.""" + return cast( + "_ops.GrantsAcceptInviteOutput", + await self._agent.call("grants.accept_invite", body, **options), + ) + async def approve( self, body: _ops.GrantsApproveBody | None = None, /, **options: Any ) -> _ops.GrantsApproveOutput: @@ -1157,6 +1166,15 @@ async def approve( "_ops.GrantsApproveOutput", await self._agent.call("grants.approve", body, **options) ) + async def cancel_invite( + self, body: _ops.GrantsCancelInviteBody | None = None, /, **options: Any + ) -> _ops.GrantsCancelInviteOutput: + """`grants.cancel_invite`.""" + return cast( + "_ops.GrantsCancelInviteOutput", + await self._agent.call("grants.cancel_invite", body, **options), + ) + async def create( self, body: _ops.GrantsCreateBody | None = None, /, **options: Any ) -> _ops.GrantsCreateOutput: @@ -1165,12 +1183,29 @@ async def create( "_ops.GrantsCreateOutput", await self._agent.call("grants.create", body, **options) ) + async def invite( + self, body: _ops.GrantsInviteBody | None = None, /, **options: Any + ) -> _ops.GrantsInviteOutput: + """`grants.invite`.""" + return cast( + "_ops.GrantsInviteOutput", await self._agent.call("grants.invite", body, **options) + ) + async def list( self, body: _ops.GrantsListBody | None = None, /, **options: Any ) -> _ops.GrantsListOutput: """`grants.list`.""" return cast("_ops.GrantsListOutput", await self._agent.call("grants.list", body, **options)) + async def list_invites( + self, body: _ops.GrantsListInvitesBody | None = None, /, **options: Any + ) -> _ops.GrantsListInvitesOutput: + """`grants.list_invites`.""" + return cast( + "_ops.GrantsListInvitesOutput", + await self._agent.call("grants.list_invites", body, **options), + ) + async def pending_for_me( self, body: _ops.GrantsPendingForMeBody | None = None, /, **options: Any ) -> _ops.GrantsPendingForMeOutput: diff --git a/sdk/python/loom/ops.py b/sdk/python/loom/ops.py index 8b0c6c6e7ac..7fd801691eb 100644 --- a/sdk/python/loom/ops.py +++ b/sdk/python/loom/ops.py @@ -153,9 +153,13 @@ class OpSpec: "facts.path", "facts.related", "facts.traverse", + "grants.accept_invite", "grants.approve", + "grants.cancel_invite", "grants.create", + "grants.invite", "grants.list", + "grants.list_invites", "grants.pending_for_me", "grants.revoke", "grants.share_agent", @@ -543,9 +547,13 @@ class OpSpec: "facts.path", "facts.related", "facts.traverse", + "grants.accept_invite", "grants.approve", + "grants.cancel_invite", "grants.create", + "grants.invite", "grants.list", + "grants.list_invites", "grants.pending_for_me", "grants.revoke", "grants.share_agent", @@ -2187,6 +2195,18 @@ class OpSpec: False, True, ), + "grants.accept_invite": OpSpec( + "grants.accept_invite", + "GrantsAcceptInviteInput", + "GrantsAcceptInviteBody", + "GrantsAcceptInviteOutput", + False, + "viewer", + "experimental", + 150, + True, + False, + ), "grants.approve": OpSpec( "grants.approve", "GrantsApproveInput", @@ -2199,6 +2219,18 @@ class OpSpec: True, False, ), + "grants.cancel_invite": OpSpec( + "grants.cancel_invite", + "GrantsCancelInviteInput", + "GrantsCancelInviteBody", + "GrantsCancelInviteOutput", + True, + "admin", + "experimental", + 80, + True, + False, + ), "grants.create": OpSpec( "grants.create", "GrantsCreateInput", @@ -2211,6 +2243,18 @@ class OpSpec: True, False, ), + "grants.invite": OpSpec( + "grants.invite", + "GrantsInviteInput", + "GrantsInviteBody", + "GrantsInviteOutput", + False, + "admin", + "experimental", + 3000, + True, + False, + ), "grants.list": OpSpec( "grants.list", "GrantsListInput", @@ -2223,6 +2267,18 @@ class OpSpec: False, True, ), + "grants.list_invites": OpSpec( + "grants.list_invites", + "GrantsListInvitesInput", + "GrantsListInvitesBody", + "GrantsListInvitesOutput", + True, + "admin", + "experimental", + 80, + False, + False, + ), "grants.pending_for_me": OpSpec( "grants.pending_for_me", "GrantsPendingForMeInput", @@ -10374,6 +10430,23 @@ class TraversalNode(TypedDict, total=False): path: NotRequired[list[str]] +class GrantsAcceptInviteInput(TypedDict, total=False): + org: Required[str] + namespace: Required[str] + secret: Required[str] + + +class GrantsAcceptInviteBody(TypedDict, total=False): + org: NotRequired[str] + namespace: NotRequired[str] + secret: Required[str] + + +class GrantsAcceptInviteOutput(TypedDict, total=False): + namespace: Required[str] + role: Required[Literal["viewer", "writer", "admin"]] + + class GrantsApproveInput(TypedDict, total=False): "Approve (or reject) a pending grant request." @@ -10402,6 +10475,22 @@ class GrantsApproveOutput(TypedDict, total=False): decided_at: Required[str] # date-time as ISO-8601 text +class GrantsCancelInviteInput(TypedDict, total=False): + org: Required[str] + namespace: Required[str] + invite_id: Required[str] + + +class GrantsCancelInviteBody(TypedDict, total=False): + org: NotRequired[str] + namespace: NotRequired[str] + invite_id: Required[str] + + +class GrantsCancelInviteOutput(TypedDict, total=False): + cancelled: Required[bool] + + class GrantsCreateInput(TypedDict, total=False): org: Required[str] namespace: Required[str] @@ -10428,6 +10517,31 @@ class GrantsCreateOutput(TypedDict, total=False): granted_at: Required[str] # date-time as ISO-8601 text +class GrantsInviteInput(TypedDict, total=False): + org: Required[str] + namespace: Required[str] + to: Required[str] + role: Required[Literal["viewer", "writer", "admin"]] + + +class GrantsInviteBody(TypedDict, total=False): + org: NotRequired[str] + namespace: NotRequired[str] + to: Required[str] + role: Required[Literal["viewer", "writer", "admin"]] + + +class GrantsInviteOutput(TypedDict, total=False): + outcome: Required[Literal["granted", "invited"]] + role: Required[Literal["viewer", "writer", "admin"]] + subject: NotRequired[str] + invite_id: NotRequired[str] + link_path: NotRequired[str] + url: NotRequired[str] + expires_at: NotRequired[Optional[str]] + emailed: NotRequired[bool] + + class GrantsListInput(TypedDict, total=False): org: Required[str] namespace: Required[str] @@ -10461,6 +10575,29 @@ class GrantEntry(TypedDict, total=False): also: NotRequired[list[str]] +class GrantsListInvitesInput(TypedDict, total=False): + org: Required[str] + namespace: Required[str] + + +class GrantsListInvitesBody(TypedDict, total=False): + org: NotRequired[str] + namespace: NotRequired[str] + + +class GrantsListInvitesOutput(TypedDict, total=False): + rows: Required[list["InviteEntry"]] + + +class InviteEntry(TypedDict, total=False): + invite_id: Required[str] + email: Required[str] + role: Required[Literal["viewer", "writer", "admin"]] + created_by: Required[str] + created_at: Required[str] # date-time as ISO-8601 text + expires_at: Required[str] # date-time as ISO-8601 text + + class GrantsPendingForMeInput(TypedDict, total=False): org: Required[str] limit: NotRequired[int] diff --git a/sdk/ruby/lib/clickhouse/loom/generated/ops.rb b/sdk/ruby/lib/clickhouse/loom/generated/ops.rb index 08e7c12d35d..207725a916e 100644 --- a/sdk/ruby/lib/clickhouse/loom/generated/ops.rb +++ b/sdk/ruby/lib/clickhouse/loom/generated/ops.rb @@ -8,7 +8,7 @@ module Loom # Every served operation: its spec in OPS, and one method per op on the class # of its group (`client.memory.set(...)` is `memory.set`). module Generated - OP_COUNT = 387 + OP_COUNT = 391 # The declared spec of every served op, by name; the HTTP path is /v1/. OPS = { @@ -126,9 +126,13 @@ module Generated "facts.path" => OpSpec.new("facts.path", "facts", "path", true, true, "viewer", "experimental", %w[org namespace entity_a entity_b max_hops top_k_per_hop min_co_occur as_of relations labeled].freeze, %w[org namespace entity_a entity_b].freeze), "facts.related" => OpSpec.new("facts.related", "facts", "related", true, true, "viewer", "experimental", %w[org namespace entity top_k as_of].freeze, %w[org namespace entity].freeze), "facts.traverse" => OpSpec.new("facts.traverse", "facts", "traverse", true, true, "viewer", "stable", %w[org namespace seed_entity max_hops top_k_per_hop min_co_occur max_nodes as_of relations labeled hub_degree hub_share rank_by].freeze, %w[org namespace seed_entity].freeze), + "grants.accept_invite" => OpSpec.new("grants.accept_invite", "grants", "accept_invite", false, false, "viewer", "experimental", %w[org namespace secret].freeze, %w[org namespace secret].freeze), "grants.approve" => OpSpec.new("grants.approve", "grants", "approve", true, false, "admin", "experimental", %w[org namespace subject decision role].freeze, %w[org namespace subject].freeze), + "grants.cancel_invite" => OpSpec.new("grants.cancel_invite", "grants", "cancel_invite", true, false, "admin", "experimental", %w[org namespace invite_id].freeze, %w[org namespace invite_id].freeze), "grants.create" => OpSpec.new("grants.create", "grants", "create", true, false, "admin", "stable", %w[org namespace subject role granted_by replace].freeze, %w[org namespace subject role].freeze), + "grants.invite" => OpSpec.new("grants.invite", "grants", "invite", false, false, "admin", "experimental", %w[org namespace to role].freeze, %w[org namespace to role].freeze), "grants.list" => OpSpec.new("grants.list", "grants", "list", true, true, "viewer", "stable", %w[org namespace limit cursor fields].freeze, %w[org namespace].freeze), + "grants.list_invites" => OpSpec.new("grants.list_invites", "grants", "list_invites", true, false, "admin", "experimental", %w[org namespace].freeze, %w[org namespace].freeze), "grants.pending_for_me" => OpSpec.new("grants.pending_for_me", "grants", "pending_for_me", true, true, "viewer", "experimental", %w[org limit].freeze, %w[org].freeze), "grants.revoke" => OpSpec.new("grants.revoke", "grants", "revoke", true, false, "admin", "experimental", %w[org namespace subject].freeze, %w[org namespace subject].freeze), "grants.share_agent" => OpSpec.new("grants.share_agent", "grants", "share_agent", true, false, "writer", "experimental", %w[org namespace grantee role].freeze, %w[org namespace grantee].freeze), @@ -1170,6 +1174,12 @@ def traverse(body = nil, request_options: nil, **fields) # The `grants.*` operations. class GrantsOps < OpGroup + # `grants.accept_invite` (viewer, writes, experimental). + # Required: org, namespace, secret. + def accept_invite(body = nil, request_options: nil, **fields) + call_op("grants.accept_invite", body, fields, request_options) + end + # `grants.approve` (admin, writes, Idempotency-Key, experimental). # Approve (or reject) a pending grant request. # Required: org, namespace, subject. @@ -1177,18 +1187,36 @@ def approve(body = nil, request_options: nil, **fields) call_op("grants.approve", body, fields, request_options) end + # `grants.cancel_invite` (admin, writes, Idempotency-Key, experimental). + # Required: org, namespace, invite_id. + def cancel_invite(body = nil, request_options: nil, **fields) + call_op("grants.cancel_invite", body, fields, request_options) + end + # `grants.create` (admin, writes, Idempotency-Key). # Required: org, namespace, subject, role. def create(body = nil, request_options: nil, **fields) call_op("grants.create", body, fields, request_options) end + # `grants.invite` (admin, writes, experimental). + # Required: org, namespace, to, role. + def invite(body = nil, request_options: nil, **fields) + call_op("grants.invite", body, fields, request_options) + end + # `grants.list` (viewer, read-only). # Required: org, namespace. def list(body = nil, request_options: nil, **fields) call_op("grants.list", body, fields, request_options) end + # `grants.list_invites` (admin, writes, Idempotency-Key, experimental). + # Required: org, namespace. + def list_invites(body = nil, request_options: nil, **fields) + call_op("grants.list_invites", body, fields, request_options) + end + # `grants.pending_for_me` (viewer, read-only, experimental). # Required: org. def pending_for_me(body = nil, request_options: nil, **fields) diff --git a/sdk/rust/src/blocking_operations.rs b/sdk/rust/src/blocking_operations.rs index 79f66646b62..e1146209ab8 100644 --- a/sdk/rust/src/blocking_operations.rs +++ b/sdk/rust/src/blocking_operations.rs @@ -3931,6 +3931,74 @@ impl crate::blocking::Client { ) -> Result, crate::CallFailure> { self.call("grants.unshare_agent", &request, options) } + /// Call `grants.invite`. + pub fn grants_invite( + &self, + request: crate::GrantsInviteInput, + ) -> Result { + self.grants_invite_with_options(request, crate::CallOptions::default()) + .map(|result| result.data) + .map_err(|failure| failure.error) + } + /// Call `grants.invite` with per-request options and metadata. + pub fn grants_invite_with_options( + &self, + request: crate::GrantsInviteInput, + options: crate::CallOptions, + ) -> Result, crate::CallFailure> { + self.call("grants.invite", &request, options) + } + /// Call `grants.list_invites`. + pub fn grants_list_invites( + &self, + request: crate::GrantsListInvitesInput, + ) -> Result { + self.grants_list_invites_with_options(request, crate::CallOptions::default()) + .map(|result| result.data) + .map_err(|failure| failure.error) + } + /// Call `grants.list_invites` with per-request options and metadata. + pub fn grants_list_invites_with_options( + &self, + request: crate::GrantsListInvitesInput, + options: crate::CallOptions, + ) -> Result, crate::CallFailure> { + self.call("grants.list_invites", &request, options) + } + /// Call `grants.cancel_invite`. + pub fn grants_cancel_invite( + &self, + request: crate::GrantsCancelInviteInput, + ) -> Result { + self.grants_cancel_invite_with_options(request, crate::CallOptions::default()) + .map(|result| result.data) + .map_err(|failure| failure.error) + } + /// Call `grants.cancel_invite` with per-request options and metadata. + pub fn grants_cancel_invite_with_options( + &self, + request: crate::GrantsCancelInviteInput, + options: crate::CallOptions, + ) -> Result, crate::CallFailure> { + self.call("grants.cancel_invite", &request, options) + } + /// Call `grants.accept_invite`. + pub fn grants_accept_invite( + &self, + request: crate::GrantsAcceptInviteInput, + ) -> Result { + self.grants_accept_invite_with_options(request, crate::CallOptions::default()) + .map(|result| result.data) + .map_err(|failure| failure.error) + } + /// Call `grants.accept_invite` with per-request options and metadata. + pub fn grants_accept_invite_with_options( + &self, + request: crate::GrantsAcceptInviteInput, + options: crate::CallOptions, + ) -> Result, crate::CallFailure> { + self.call("grants.accept_invite", &request, options) + } /// Call `collection.budget_set`. pub fn collection_budget_set( &self, diff --git a/sdk/rust/src/operations.rs b/sdk/rust/src/operations.rs index dd3654c4e40..c20480b7782 100644 --- a/sdk/rust/src/operations.rs +++ b/sdk/rust/src/operations.rs @@ -4214,6 +4214,78 @@ impl crate::Client { ) -> Result, crate::CallFailure> { self.call("grants.unshare_agent", &request, options).await } + /// Call `grants.invite`. + pub async fn grants_invite( + &self, + request: crate::GrantsInviteInput, + ) -> Result { + self.grants_invite_with_options(request, crate::CallOptions::default()) + .await + .map(|result| result.data) + .map_err(|failure| failure.error) + } + /// Call `grants.invite` with per-request options and metadata. + pub async fn grants_invite_with_options( + &self, + request: crate::GrantsInviteInput, + options: crate::CallOptions, + ) -> Result, crate::CallFailure> { + self.call("grants.invite", &request, options).await + } + /// Call `grants.list_invites`. + pub async fn grants_list_invites( + &self, + request: crate::GrantsListInvitesInput, + ) -> Result { + self.grants_list_invites_with_options(request, crate::CallOptions::default()) + .await + .map(|result| result.data) + .map_err(|failure| failure.error) + } + /// Call `grants.list_invites` with per-request options and metadata. + pub async fn grants_list_invites_with_options( + &self, + request: crate::GrantsListInvitesInput, + options: crate::CallOptions, + ) -> Result, crate::CallFailure> { + self.call("grants.list_invites", &request, options).await + } + /// Call `grants.cancel_invite`. + pub async fn grants_cancel_invite( + &self, + request: crate::GrantsCancelInviteInput, + ) -> Result { + self.grants_cancel_invite_with_options(request, crate::CallOptions::default()) + .await + .map(|result| result.data) + .map_err(|failure| failure.error) + } + /// Call `grants.cancel_invite` with per-request options and metadata. + pub async fn grants_cancel_invite_with_options( + &self, + request: crate::GrantsCancelInviteInput, + options: crate::CallOptions, + ) -> Result, crate::CallFailure> { + self.call("grants.cancel_invite", &request, options).await + } + /// Call `grants.accept_invite`. + pub async fn grants_accept_invite( + &self, + request: crate::GrantsAcceptInviteInput, + ) -> Result { + self.grants_accept_invite_with_options(request, crate::CallOptions::default()) + .await + .map(|result| result.data) + .map_err(|failure| failure.error) + } + /// Call `grants.accept_invite` with per-request options and metadata. + pub async fn grants_accept_invite_with_options( + &self, + request: crate::GrantsAcceptInviteInput, + options: crate::CallOptions, + ) -> Result, crate::CallFailure> { + self.call("grants.accept_invite", &request, options).await + } /// Call `collection.budget_set`. pub async fn collection_budget_set( &self, diff --git a/sdk/rust/src/wire_models.rs b/sdk/rust/src/wire_models.rs index bbe9ff73ebe..507b10b0071 100644 --- a/sdk/rust/src/wire_models.rs +++ b/sdk/rust/src/wire_models.rs @@ -1197,6 +1197,28 @@ pub(crate) const OP_POLICIES: &[OperationPolicy] = &[ &["namespace", "org"], &[], ), + ("grants.invite", false, false, &["namespace", "org"], &[]), + ( + "grants.list_invites", + true, + false, + &["namespace", "org"], + &[], + ), + ( + "grants.cancel_invite", + true, + false, + &["namespace", "org"], + &[], + ), + ( + "grants.accept_invite", + false, + false, + &["namespace", "org"], + &[], + ), ("collection.budget_set", true, false, &["org"], &[]), ("collection.create", true, false, &["org"], &[]), ("collection.move", true, false, &["org"], &[]), @@ -2024,6 +2046,7 @@ pub(crate) const NAMESPACE_HINT_EXCLUSIONS: &[&str] = &[ "extraction_policy.clear", "extraction_policy.get", "extraction_policy.set", + "grants.accept_invite", "memory.verify", ]; #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] @@ -22404,6 +22427,66 @@ impl FactsTraverseInput { } } +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[non_exhaustive] +pub enum GrantsAcceptInviteOutputRole { + #[serde(rename = "viewer")] + Viewer, + #[serde(rename = "writer")] + Writer, + #[serde(rename = "admin")] + Admin, +} + +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[non_exhaustive] +pub struct GrantsAcceptInviteOutput { + pub namespace: String, + pub role: GrantsAcceptInviteOutputRole, +} + +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[non_exhaustive] +pub struct GrantsAcceptInviteInput { + #[serde( + default, + skip_serializing_if = "Option::is_none", + deserialize_with = "present_value" + )] + pub org: Option, + #[serde( + default, + skip_serializing_if = "Option::is_none", + deserialize_with = "present_value" + )] + pub namespace: Option, + pub secret: String, +} +impl GrantsAcceptInviteInput { + pub fn new(secret: impl Into) -> Self { + Self { + org: None, + namespace: None, + secret: secret.into(), + } + } + pub fn org(mut self, org: impl Into) -> Self { + self.org = Some(org.into()); + self + } + pub fn namespace(mut self, namespace: impl Into) -> Self { + self.namespace = Some(namespace.into()); + self + } + pub async fn send( + self, + client: &crate::Client, + options: crate::CallOptions, + ) -> Result, crate::CallFailure> { + client.call("grants.accept_invite", &self, options).await + } +} + #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[non_exhaustive] pub enum GrantsApproveOutputDecision { @@ -22523,6 +22606,54 @@ impl GrantsApproveInput { } } +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[non_exhaustive] +pub struct GrantsCancelInviteOutput { + pub cancelled: bool, +} + +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[non_exhaustive] +pub struct GrantsCancelInviteInput { + #[serde( + default, + skip_serializing_if = "Option::is_none", + deserialize_with = "present_value" + )] + pub org: Option, + #[serde( + default, + skip_serializing_if = "Option::is_none", + deserialize_with = "present_value" + )] + pub namespace: Option, + pub invite_id: String, +} +impl GrantsCancelInviteInput { + pub fn new(invite_id: impl Into) -> Self { + Self { + org: None, + namespace: None, + invite_id: invite_id.into(), + } + } + pub fn org(mut self, org: impl Into) -> Self { + self.org = Some(org.into()); + self + } + pub fn namespace(mut self, namespace: impl Into) -> Self { + self.namespace = Some(namespace.into()); + self + } + pub async fn send( + self, + client: &crate::Client, + options: crate::CallOptions, + ) -> Result, crate::CallFailure> { + client.call("grants.cancel_invite", &self, options).await + } +} + #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[non_exhaustive] pub enum GrantsCreateOutputRole { @@ -22621,6 +22752,100 @@ impl GrantsCreateInput { } } +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[non_exhaustive] +pub enum GrantsInviteOutputOutcome { + #[serde(rename = "granted")] + Granted, + #[serde(rename = "invited")] + Invited, +} + +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[non_exhaustive] +pub enum GrantsInviteOutputRole { + #[serde(rename = "viewer")] + Viewer, + #[serde(rename = "writer")] + Writer, + #[serde(rename = "admin")] + Admin, +} + +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[non_exhaustive] +pub struct GrantsInviteOutput { + pub outcome: GrantsInviteOutputOutcome, + pub role: GrantsInviteOutputRole, + #[serde(default = "default_1035")] + pub subject: String, + #[serde(default = "default_1036")] + pub invite_id: String, + #[serde(default = "default_1037")] + pub link_path: String, + #[serde(default = "default_1038")] + pub url: String, + #[serde(default = "default_1039")] + pub expires_at: Option, + #[serde(default = "default_1040")] + pub emailed: bool, +} + +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[non_exhaustive] +pub enum GrantsInviteInputRole { + #[serde(rename = "viewer")] + Viewer, + #[serde(rename = "writer")] + Writer, + #[serde(rename = "admin")] + Admin, +} + +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[non_exhaustive] +pub struct GrantsInviteInput { + #[serde( + default, + skip_serializing_if = "Option::is_none", + deserialize_with = "present_value" + )] + pub org: Option, + #[serde( + default, + skip_serializing_if = "Option::is_none", + deserialize_with = "present_value" + )] + pub namespace: Option, + pub to: String, + pub role: GrantsInviteInputRole, +} +impl GrantsInviteInput { + pub fn new(to: impl Into, role: GrantsInviteInputRole) -> Self { + Self { + org: None, + namespace: None, + to: to.into(), + role, + } + } + pub fn org(mut self, org: impl Into) -> Self { + self.org = Some(org.into()); + self + } + pub fn namespace(mut self, namespace: impl Into) -> Self { + self.namespace = Some(namespace.into()); + self + } + pub async fn send( + self, + client: &crate::Client, + options: crate::CallOptions, + ) -> Result, crate::CallFailure> { + client.call("grants.invite", &self, options).await + } +} + #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[non_exhaustive] pub enum GrantEntryRole { @@ -22709,9 +22934,9 @@ pub struct GrantEntry { #[non_exhaustive] pub struct GrantsListOutput { pub rows: Vec, - #[serde(default = "default_1035")] + #[serde(default = "default_1041")] pub next_cursor: Option, - #[serde(default = "default_1036")] + #[serde(default = "default_1042")] pub truncated: bool, } @@ -22801,6 +23026,79 @@ impl GrantsListInput { } } +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[non_exhaustive] +pub enum InviteEntryRole { + #[serde(rename = "viewer")] + Viewer, + #[serde(rename = "writer")] + Writer, + #[serde(rename = "admin")] + Admin, +} + +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[non_exhaustive] +pub struct InviteEntry { + pub invite_id: String, + pub email: String, + pub role: InviteEntryRole, + pub created_by: String, + pub created_at: String, + pub expires_at: String, +} + +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[non_exhaustive] +pub struct GrantsListInvitesOutput { + pub rows: Vec, +} + +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[non_exhaustive] +pub struct GrantsListInvitesInput { + #[serde( + default, + skip_serializing_if = "Option::is_none", + deserialize_with = "present_value" + )] + pub org: Option, + #[serde( + default, + skip_serializing_if = "Option::is_none", + deserialize_with = "present_value" + )] + pub namespace: Option, +} +impl Default for GrantsListInvitesInput { + fn default() -> Self { + Self::new() + } +} +impl GrantsListInvitesInput { + pub fn new() -> Self { + Self { + org: None, + namespace: None, + } + } + pub fn org(mut self, org: impl Into) -> Self { + self.org = Some(org.into()); + self + } + pub fn namespace(mut self, namespace: impl Into) -> Self { + self.namespace = Some(namespace.into()); + self + } + pub async fn send( + self, + client: &crate::Client, + options: crate::CallOptions, + ) -> Result, crate::CallFailure> { + client.call("grants.list_invites", &self, options).await + } +} + #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[non_exhaustive] pub enum PendingForMeEntryCurrentRole { @@ -22827,12 +23125,12 @@ pub enum PendingForMeEntryRequestedRole { #[non_exhaustive] pub struct PendingForMeEntry { pub namespace: String, - #[serde(default = "default_1037")] + #[serde(default = "default_1043")] pub kind: String, pub subject: String, pub current_role: PendingForMeEntryCurrentRole, pub requested_role: PendingForMeEntryRequestedRole, - #[serde(default = "default_1038")] + #[serde(default = "default_1044")] pub pending_since: Option, } @@ -22891,7 +23189,7 @@ impl GrantsPendingForMeInput { #[non_exhaustive] pub struct GrantsRevokeOutput { pub revoked: bool, - #[serde(default = "default_1039")] + #[serde(default = "default_1045")] pub revoked_at: Option, } @@ -23021,7 +23319,7 @@ impl GrantsShareAgentInput { #[non_exhaustive] pub struct GrantsUnshareAgentOutput { pub revoked: bool, - #[serde(default = "default_1040")] + #[serde(default = "default_1046")] pub revoked_at: Option, } @@ -23081,7 +23379,7 @@ pub enum HelpGetOutputAudience { pub struct HelpOutlineEntry { pub section: String, pub anchor: String, - #[serde(default = "default_1048")] + #[serde(default = "default_1054")] pub heading: String, } @@ -23091,21 +23389,21 @@ pub struct HelpGetOutput { pub available: bool, pub found: bool, pub path: String, - #[serde(default = "default_1041")] + #[serde(default = "default_1047")] pub title: String, - #[serde(default = "default_1042")] + #[serde(default = "default_1048")] pub section: String, - #[serde(default = "default_1043")] + #[serde(default = "default_1049")] pub anchor: String, - #[serde(default = "default_1044")] + #[serde(default = "default_1050")] pub audience: HelpGetOutputAudience, - #[serde(default = "default_1045")] + #[serde(default = "default_1051")] pub text: String, - #[serde(default = "default_1046")] + #[serde(default = "default_1052")] pub truncated: bool, - #[serde(default = "default_1047")] + #[serde(default = "default_1053")] pub next_offset: Integer, - #[serde(default = "default_1049")] + #[serde(default = "default_1055")] pub sections: Vec, } @@ -23250,21 +23548,21 @@ pub struct InboxPayload { pub inbox: String, pub owner_agent: String, pub owner_namespace: String, - #[serde(default = "default_1050")] + #[serde(default = "default_1056")] pub description: String, - #[serde(default = "default_1051")] + #[serde(default = "default_1057")] pub posters: Vec, - #[serde(default = "default_1052")] + #[serde(default = "default_1058")] pub accept_disclosure: Vec, pub default_lease_seconds: Integer, pub max_attempts: Integer, pub max_defers: Integer, pub triage_escalate_after_seconds: Integer, - #[serde(default = "default_1053")] + #[serde(default = "default_1059")] pub webhook_url: String, - #[serde(default = "default_1054")] + #[serde(default = "default_1060")] pub created_by: String, - #[serde(default = "default_1055")] + #[serde(default = "default_1061")] pub owner_subject: String, pub created_at: String, pub updated_at: String, @@ -23374,9 +23672,9 @@ pub struct PolicyPayload { pub poster: String, pub kind: String, pub mode: PolicyPayloadMode, - #[serde(default = "default_1056")] + #[serde(default = "default_1062")] pub require_evidence: Vec, - #[serde(default = "default_1057")] + #[serde(default = "default_1063")] pub set_by: String, pub set_at: String, pub version: Integer, @@ -23446,7 +23744,7 @@ impl InboxPolicyListInput { pub struct InboxPolicySetOutput { #[serde(deserialize_with = "required_nullable")] pub policy: Option, - #[serde(default = "default_1058")] + #[serde(default = "default_1064")] pub removed: bool, } @@ -23575,15 +23873,15 @@ pub struct Principal { pub subject: String, pub label: String, pub kind: PrincipalKind, - #[serde(default = "default_1059")] + #[serde(default = "default_1065")] pub namespaces: Vec, - #[serde(default = "default_1060")] + #[serde(default = "default_1066")] pub roles: Vec, - #[serde(default = "default_1061")] + #[serde(default = "default_1067")] pub last_seen: Option, - #[serde(default = "default_1062")] + #[serde(default = "default_1068")] pub can_already_post: bool, - #[serde(default = "default_1063")] + #[serde(default = "default_1069")] pub listed: bool, } @@ -23945,15 +24243,15 @@ pub struct AnalysisColumn { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct InsightsQueryOutput { - #[serde(default = "default_1064")] + #[serde(default = "default_1070")] pub columns: Vec, - #[serde(default = "default_1065")] + #[serde(default = "default_1071")] pub rows: Vec>, - #[serde(default = "default_1066")] + #[serde(default = "default_1072")] pub row_count: Integer, - #[serde(default = "default_1067")] + #[serde(default = "default_1073")] pub truncated: bool, - #[serde(default = "default_1068")] + #[serde(default = "default_1074")] pub sql_digest: String, } @@ -24252,32 +24550,32 @@ pub struct DatasetOut { pub dataset_id: String, pub source_uri: String, pub name: String, - #[serde(default = "default_1069")] + #[serde(default = "default_1075")] pub sheet: String, - #[serde(default = "default_1070")] + #[serde(default = "default_1076")] pub row_start: Integer, - #[serde(default = "default_1071")] + #[serde(default = "default_1077")] pub row_end: Integer, pub revision: Integer, pub snapshot_id: String, pub schema_state: String, pub columns: Vec, - #[serde(default = "default_1072")] + #[serde(default = "default_1078")] pub clarifications: Vec, pub row_count: Integer, - #[serde(default = "default_1073")] + #[serde(default = "default_1079")] pub rejected_rows: Integer, - #[serde(default = "default_1074")] + #[serde(default = "default_1080")] pub rejected: Vec, - #[serde(default = "default_1075")] + #[serde(default = "default_1081")] pub complete: bool, - #[serde(default = "default_1076")] + #[serde(default = "default_1082")] pub approved_by: String, - #[serde(default = "default_1077")] + #[serde(default = "default_1083")] pub approved_at: Option, - #[serde(default = "default_1078")] + #[serde(default = "default_1084")] pub created_at: Option, - #[serde(default = "default_1079")] + #[serde(default = "default_1085")] pub rows: Vec>, } @@ -24285,9 +24583,9 @@ pub struct DatasetOut { #[non_exhaustive] pub struct KnowledgeDatasetApproveOutput { pub found: bool, - #[serde(default = "default_1080")] + #[serde(default = "default_1086")] pub dataset: Option, - #[serde(default = "default_1081")] + #[serde(default = "default_1087")] pub retyped: bool, } @@ -24381,9 +24679,9 @@ impl KnowledgeDatasetApproveInput { #[non_exhaustive] pub struct KnowledgeDatasetGetOutput { pub found: bool, - #[serde(default = "default_1082")] + #[serde(default = "default_1088")] pub revision: Integer, - #[serde(default = "default_1083")] + #[serde(default = "default_1089")] pub datasets: Vec, } @@ -24456,7 +24754,7 @@ impl KnowledgeDatasetGetInput { pub struct KnowledgeDocCluster { pub content_sha256: String, pub doc_count: Integer, - #[serde(default = "default_1084")] + #[serde(default = "default_1090")] pub docs: Vec>, } @@ -24466,16 +24764,16 @@ pub struct KnowledgeChunkCluster { pub content_sha256: String, pub chunk_count: Integer, pub uri_count: Integer, - #[serde(default = "default_1086")] + #[serde(default = "default_1092")] pub samples: Vec>, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct KnowledgeDedupListOutput { - #[serde(default = "default_1085")] + #[serde(default = "default_1091")] pub doc_clusters: Vec, - #[serde(default = "default_1087")] + #[serde(default = "default_1093")] pub chunk_clusters: Vec, } @@ -24552,7 +24850,7 @@ pub struct KnowledgeDedupResolveOutput { pub canonical_uri: String, pub duplicate_uri: String, pub decision: String, - #[serde(default = "default_1088")] + #[serde(default = "default_1094")] pub superseded_uri: String, } @@ -24671,24 +24969,24 @@ impl KnowledgeDeleteInput { #[non_exhaustive] pub struct KnowledgeFormat { pub format: String, - #[serde(default = "default_1089")] + #[serde(default = "default_1095")] pub extensions: Vec, - #[serde(default = "default_1090")] + #[serde(default = "default_1096")] pub media_types: Vec, - #[serde(default = "default_1091")] + #[serde(default = "default_1097")] pub available: Option, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct KnowledgeFormatsOutput { - #[serde(default = "default_1092")] + #[serde(default = "default_1098")] pub formats: Vec, - #[serde(default = "default_1093")] + #[serde(default = "default_1099")] pub max_upload_bytes: Integer, - #[serde(default = "default_1094")] + #[serde(default = "default_1100")] pub refused_extensions: Vec, - #[serde(default = "default_1095")] + #[serde(default = "default_1101")] pub default_format: String, } @@ -24790,7 +25088,7 @@ impl KnowledgeGapsDraftInput { pub struct KnowledgeGap { pub gap_id: String, pub head: String, - #[serde(default = "default_1096")] + #[serde(default = "default_1102")] pub samples: Vec, pub askers: Integer, pub asks: Integer, @@ -24800,13 +25098,13 @@ pub struct KnowledgeGap { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct KnowledgeGapsListOutput { - #[serde(default = "default_1097")] + #[serde(default = "default_1103")] pub gaps: Vec, - #[serde(default = "default_1098")] + #[serde(default = "default_1104")] pub built_at: Option, - #[serde(default = "default_1099")] + #[serde(default = "default_1105")] pub capturing: Option, - #[serde(default = "default_1100")] + #[serde(default = "default_1106")] pub enabled: bool, } @@ -24872,7 +25170,7 @@ pub struct KnowledgeIngestOutput { pub ingestion_id: String, pub state: String, pub source_uri: String, - #[serde(default = "default_1101")] + #[serde(default = "default_1107")] pub namespace: String, } @@ -25091,9 +25389,9 @@ impl KnowledgeIngestInput { #[non_exhaustive] pub struct KnowledgeIngestCancelOutput { pub found: bool, - #[serde(default = "default_1102")] + #[serde(default = "default_1108")] pub state: String, - #[serde(default = "default_1103")] + #[serde(default = "default_1109")] pub cancelled: bool, } @@ -25144,39 +25442,39 @@ impl KnowledgeIngestCancelInput { pub struct KnowledgeIngestStatusOutput { pub found: bool, pub ingestion_id: String, - #[serde(default = "default_1104")] + #[serde(default = "default_1110")] pub source_uri: String, - #[serde(default = "default_1105")] + #[serde(default = "default_1111")] pub state: String, - #[serde(default = "default_1106")] + #[serde(default = "default_1112")] pub stage: String, - #[serde(default = "default_1107")] + #[serde(default = "default_1113")] pub attempts: Integer, - #[serde(default = "default_1108")] + #[serde(default = "default_1114")] pub error_code: String, - #[serde(default = "default_1109")] + #[serde(default = "default_1115")] pub error_message: String, - #[serde(default = "default_1110")] + #[serde(default = "default_1116")] pub format: String, - #[serde(default = "default_1111")] + #[serde(default = "default_1117")] pub coverage: Option>, - #[serde(default = "default_1112")] + #[serde(default = "default_1118")] pub warnings: Vec, - #[serde(default = "default_1113")] + #[serde(default = "default_1119")] pub chunks: Integer, - #[serde(default = "default_1114")] + #[serde(default = "default_1120")] pub revision: Integer, - #[serde(default = "default_1115")] + #[serde(default = "default_1121")] pub expected_revision: Option, - #[serde(default = "default_1116")] + #[serde(default = "default_1122")] pub filename: String, - #[serde(default = "default_1117")] + #[serde(default = "default_1123")] pub retrieval: String, - #[serde(default = "default_1118")] + #[serde(default = "default_1124")] pub cancel_requested: bool, - #[serde(default = "default_1119")] + #[serde(default = "default_1125")] pub created_at: Option, - #[serde(default = "default_1120")] + #[serde(default = "default_1126")] pub updated_at: Option, } @@ -25233,21 +25531,21 @@ pub struct DocumentCount { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct DocumentTotals { - #[serde(default = "default_1121")] + #[serde(default = "default_1127")] pub live: Option, - #[serde(default = "default_1122")] + #[serde(default = "default_1128")] pub deleted: Option, - #[serde(default = "default_1123")] + #[serde(default = "default_1129")] pub newest_ingested_at: Option, - #[serde(default = "default_1124")] + #[serde(default = "default_1130")] pub by_format: Vec, - #[serde(default = "default_1125")] + #[serde(default = "default_1131")] pub by_source_scheme: Vec, - #[serde(default = "default_1126")] + #[serde(default = "default_1132")] pub earlier_revisions: Option, - #[serde(default = "default_1127")] + #[serde(default = "default_1133")] pub unnumbered: Option, - #[serde(default = "default_1128")] + #[serde(default = "default_1134")] pub retired_versions: Option, } @@ -25262,15 +25560,15 @@ pub struct ChunkModelCount { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct ChunkTotals { - #[serde(default = "default_1129")] + #[serde(default = "default_1135")] pub embedder_model: String, - #[serde(default = "default_1130")] + #[serde(default = "default_1136")] pub live: Option, - #[serde(default = "default_1131")] + #[serde(default = "default_1137")] pub searchable: Option, - #[serde(default = "default_1132")] + #[serde(default = "default_1138")] pub unembedded: Option, - #[serde(default = "default_1133")] + #[serde(default = "default_1139")] pub by_model: Vec, } @@ -25295,9 +25593,9 @@ pub struct DocumentDecisions { #[non_exhaustive] pub struct DecisionTotals { pub definition: String, - #[serde(default = "default_1134")] + #[serde(default = "default_1140")] pub refs: Vec, - #[serde(default = "default_1135")] + #[serde(default = "default_1141")] pub all_documents: Option, } @@ -25312,7 +25610,7 @@ pub struct DocumentChunks { pub min_chars: Integer, pub median_chars: Integer, pub max_chars: Integer, - #[serde(default = "default_1138")] + #[serde(default = "default_1144")] pub models: Vec, } @@ -25362,11 +25660,11 @@ pub struct IngestJob { pub failure_class: IngestJobFailureClass, pub queued_at: String, pub updated_at: String, - #[serde(default = "default_1143")] + #[serde(default = "default_1149")] pub ended_at: Option, - #[serde(default = "default_1144")] + #[serde(default = "default_1150")] pub next_attempt_at: Option, - #[serde(default = "default_1145")] + #[serde(default = "default_1151")] pub stalled: bool, } @@ -25376,11 +25674,11 @@ pub struct SourceJobs { pub source_uri: String, pub jobs: Integer, pub open_jobs: Integer, - #[serde(default = "default_1142")] + #[serde(default = "default_1148")] pub open_ingestion_id: String, pub latest: IngestJob, pub current: IngestJob, - #[serde(default = "default_1146")] + #[serde(default = "default_1152")] pub replaced: bool, } @@ -25393,18 +25691,18 @@ pub struct InspectDocument { pub source_scheme: String, pub version: Integer, pub revision: Integer, - #[serde(default = "default_1136")] + #[serde(default = "default_1142")] pub ingestion_id: String, pub ingested_at: String, - #[serde(default = "default_1137")] + #[serde(default = "default_1143")] pub retired_versions: Option, - #[serde(default = "default_1139")] + #[serde(default = "default_1145")] pub chunks: Option, - #[serde(default = "default_1140")] + #[serde(default = "default_1146")] pub decisions: Option, - #[serde(default = "default_1141")] - pub extraction: Option, #[serde(default = "default_1147")] + pub extraction: Option, + #[serde(default = "default_1153")] pub jobs: Option, } @@ -25449,40 +25747,40 @@ pub struct DocumentFinding { pub kind: DocumentFindingKind, pub rule_version: Integer, pub source_op: String, - #[serde(default = "default_1150")] + #[serde(default = "default_1156")] pub window_seconds: Option, - #[serde(default = "default_1151")] + #[serde(default = "default_1157")] pub population: Option, pub sample_limit: Integer, pub samples_complete: bool, - #[serde(default = "default_1152")] + #[serde(default = "default_1158")] pub evidence: Vec, - #[serde(default = "default_1153")] + #[serde(default = "default_1159")] pub exceptions: String, - #[serde(default = "default_1154")] + #[serde(default = "default_1160")] pub uncertainty: String, pub code: String, pub severity: DocumentFindingSeverity, pub count: Integer, pub share: f64, - #[serde(default = "default_1155")] + #[serde(default = "default_1161")] pub samples: Vec, - #[serde(default = "default_1156")] + #[serde(default = "default_1162")] pub ingested: Integer, - #[serde(default = "default_1157")] + #[serde(default = "default_1163")] pub ingested_samples: Vec, pub detail: String, pub remedy: String, - #[serde(default = "default_1158")] + #[serde(default = "default_1164")] pub refs: Vec, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct ReportCoverage { - #[serde(default = "default_1160")] + #[serde(default = "default_1166")] pub rules_run: Vec, - #[serde(default = "default_1161")] + #[serde(default = "default_1167")] pub rules_skipped: Vec, pub complete: bool, } @@ -25490,43 +25788,43 @@ pub struct ReportCoverage { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct IngestionTotals { - #[serde(default = "default_1162")] + #[serde(default = "default_1168")] pub sources: Option, - #[serde(default = "default_1163")] + #[serde(default = "default_1169")] pub without_document: Option, - #[serde(default = "default_1164")] + #[serde(default = "default_1170")] pub replaced: Option, - #[serde(default = "default_1165")] + #[serde(default = "default_1171")] pub pending: Option, - #[serde(default = "default_1166")] + #[serde(default = "default_1172")] pub processing: Option, - #[serde(default = "default_1167")] + #[serde(default = "default_1173")] pub stalled: Option, - #[serde(default = "default_1168")] + #[serde(default = "default_1174")] pub ready: Option, - #[serde(default = "default_1169")] + #[serde(default = "default_1175")] pub partial: Option, - #[serde(default = "default_1170")] + #[serde(default = "default_1176")] pub failed: Option, - #[serde(default = "default_1171")] + #[serde(default = "default_1177")] pub cancelled: Option, - #[serde(default = "default_1172")] + #[serde(default = "default_1178")] pub oldest_open_queued_at: Option, pub worker_enabled: bool, - #[serde(default = "default_1173")] + #[serde(default = "default_1179")] pub extractor_configured: Option, - #[serde(default = "default_1174")] + #[serde(default = "default_1180")] pub without_document_listed: Vec, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct ExtractionTotals { - #[serde(default = "default_1175")] + #[serde(default = "default_1181")] pub documents: Option, - #[serde(default = "default_1176")] + #[serde(default = "default_1182")] pub incomplete: Option, - #[serde(default = "default_1177")] + #[serde(default = "default_1183")] pub lost: Vec, } @@ -25556,31 +25854,31 @@ pub struct IngestFinding { pub kind: IngestFindingKind, pub rule_version: Integer, pub source_op: String, - #[serde(default = "default_1178")] + #[serde(default = "default_1184")] pub window_seconds: Option, - #[serde(default = "default_1179")] + #[serde(default = "default_1185")] pub population: Option, pub sample_limit: Integer, pub samples_complete: bool, - #[serde(default = "default_1180")] + #[serde(default = "default_1186")] pub evidence: Vec, - #[serde(default = "default_1181")] + #[serde(default = "default_1187")] pub exceptions: String, - #[serde(default = "default_1182")] + #[serde(default = "default_1188")] pub uncertainty: String, pub code: String, pub severity: IngestFindingSeverity, pub count: Integer, pub share: f64, - #[serde(default = "default_1183")] + #[serde(default = "default_1189")] pub samples: Vec, - #[serde(default = "default_1184")] + #[serde(default = "default_1190")] pub ingestion_ids: Vec, - #[serde(default = "default_1185")] + #[serde(default = "default_1191")] pub without_document: Integer, pub detail: String, pub remedy: String, - #[serde(default = "default_1186")] + #[serde(default = "default_1192")] pub refs: Vec, } @@ -25607,20 +25905,20 @@ pub struct KnowledgeInspectOutput { pub documents: DocumentTotals, pub chunks: ChunkTotals, pub decisions: DecisionTotals, - #[serde(default = "default_1148")] + #[serde(default = "default_1154")] pub listed: Vec, - #[serde(default = "default_1149")] + #[serde(default = "default_1155")] pub listed_complete: bool, - #[serde(default = "default_1159")] + #[serde(default = "default_1165")] pub findings: Vec, pub coverage: ReportCoverage, pub ingestions: IngestionTotals, pub extraction: ExtractionTotals, - #[serde(default = "default_1187")] + #[serde(default = "default_1193")] pub ingest_findings: Vec, - #[serde(default = "default_1188")] + #[serde(default = "default_1194")] pub memory_findings: Vec, - #[serde(default = "default_1189")] + #[serde(default = "default_1195")] pub skipped: Vec, } @@ -25767,7 +26065,7 @@ pub struct KnowledgeListEntry { #[non_exhaustive] pub struct KnowledgeListOutput { pub rows: Vec, - #[serde(default = "default_1190")] + #[serde(default = "default_1196")] pub next_cursor: Option, } @@ -25933,9 +26231,9 @@ pub enum KnowledgeMoveResultReason { #[non_exhaustive] pub struct KnowledgeMoveResult { pub source_uri: String, - #[serde(default = "default_1192")] + #[serde(default = "default_1198")] pub moved: bool, - #[serde(default = "default_1193")] + #[serde(default = "default_1199")] pub reason: KnowledgeMoveResultReason, } @@ -25943,9 +26241,9 @@ pub struct KnowledgeMoveResult { #[non_exhaustive] pub struct KnowledgeMoveOutput { pub found: bool, - #[serde(default = "default_1191")] + #[serde(default = "default_1197")] pub to_namespace: String, - #[serde(default = "default_1194")] + #[serde(default = "default_1200")] pub results: Vec, } @@ -26011,17 +26309,17 @@ pub struct OutlineEntry { pub struct KnowledgeOutlineOutput { pub found: bool, pub source_uri: String, - #[serde(default = "default_1195")] + #[serde(default = "default_1201")] pub title: String, - #[serde(default = "default_1196")] + #[serde(default = "default_1202")] pub structured: bool, - #[serde(default = "default_1197")] + #[serde(default = "default_1203")] pub chunk_count: Integer, - #[serde(default = "default_1198")] + #[serde(default = "default_1204")] pub sections: Vec, - #[serde(default = "default_1199")] + #[serde(default = "default_1205")] pub section_content: Option, - #[serde(default = "default_1200")] + #[serde(default = "default_1206")] pub section_chunk_idxs: Vec, } @@ -26128,12 +26426,12 @@ pub struct QueryReceipt { pub struct KnowledgeQueryOutput { pub columns: Vec, pub rows: Vec>, - #[serde(default = "default_1201")] + #[serde(default = "default_1207")] pub row_ids: Vec>, - #[serde(default = "default_1202")] + #[serde(default = "default_1208")] pub truncated: bool, pub complete: bool, - #[serde(default = "default_1203")] + #[serde(default = "default_1209")] pub incomplete: Vec, pub receipt: QueryReceipt, } @@ -26806,9 +27104,9 @@ pub struct QueryHistoryListOutputQueryHistorySource { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct QueryHistoryListOutput { - #[serde(default = "default_1204")] + #[serde(default = "default_1210")] pub enabled: bool, - #[serde(default = "default_1205")] + #[serde(default = "default_1211")] pub sources: Vec, } @@ -26939,7 +27237,7 @@ impl QueryHistoryRemoveInput { #[non_exhaustive] pub struct KnowledgeReadsOutput { pub window_days: Integer, - #[serde(default = "default_1206")] + #[serde(default = "default_1212")] pub reads: Vec>, } @@ -27042,15 +27340,15 @@ pub enum KnowledgeRestoreOutputOriginal { #[non_exhaustive] pub struct KnowledgeRestoreOutput { pub restored: bool, - #[serde(default = "default_1207")] + #[serde(default = "default_1213")] pub reason: KnowledgeRestoreOutputReason, - #[serde(default = "default_1208")] + #[serde(default = "default_1214")] pub doc_id: String, - #[serde(default = "default_1209")] + #[serde(default = "default_1215")] pub revision: Option, - #[serde(default = "default_1210")] + #[serde(default = "default_1216")] pub chunks_restored: Integer, - #[serde(default = "default_1211")] + #[serde(default = "default_1217")] pub original: KnowledgeRestoreOutputOriginal, } @@ -27123,35 +27421,35 @@ pub struct KnowledgeSourceCrawlProof { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct KnowledgeSourceProbe { - #[serde(default = "default_1216")] + #[serde(default = "default_1222")] pub documents: Integer, - #[serde(default = "default_1217")] + #[serde(default = "default_1223")] pub more: bool, - #[serde(default = "default_1218")] + #[serde(default = "default_1224")] pub sample: Vec, - #[serde(default = "default_1219")] + #[serde(default = "default_1225")] pub checked: Integer, - #[serde(default = "default_1220")] + #[serde(default = "default_1226")] pub sampled: bool, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct KnowledgeSourceAddOutput { - #[serde(default = "default_1212")] + #[serde(default = "default_1218")] pub crawl_proof: Option, pub name: String, pub kind: String, pub namespace: String, - #[serde(default = "default_1213")] + #[serde(default = "default_1219")] pub items: Vec>, - #[serde(default = "default_1214")] + #[serde(default = "default_1220")] pub include: Vec, - #[serde(default = "default_1215")] - pub config: std::collections::HashMap, #[serde(default = "default_1221")] + pub config: std::collections::HashMap, + #[serde(default = "default_1227")] pub probe: KnowledgeSourceProbe, - #[serde(default = "default_1222")] + #[serde(default = "default_1228")] pub dry_run: bool, } @@ -27368,21 +27666,21 @@ impl KnowledgeSourceAddInput { #[non_exhaustive] pub struct KnowledgeSourceCheckOutput { pub name: String, - #[serde(default = "default_1223")] + #[serde(default = "default_1229")] pub reachable: bool, - #[serde(default = "default_1224")] + #[serde(default = "default_1230")] pub documents: Integer, - #[serde(default = "default_1225")] + #[serde(default = "default_1231")] pub more: bool, - #[serde(default = "default_1226")] + #[serde(default = "default_1232")] pub sample: Vec, - #[serde(default = "default_1227")] + #[serde(default = "default_1233")] pub checked: Integer, - #[serde(default = "default_1228")] + #[serde(default = "default_1234")] pub sampled: bool, - #[serde(default = "default_1229")] + #[serde(default = "default_1235")] pub summary: String, - #[serde(default = "default_1230")] + #[serde(default = "default_1236")] pub checked_at: String, } @@ -27431,37 +27729,37 @@ impl KnowledgeSourceCheckInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct KnowledgeSourceSync { - #[serde(default = "default_1241")] + #[serde(default = "default_1247")] pub requested_at: String, - #[serde(default = "default_1242")] + #[serde(default = "default_1248")] pub last_synced_at: String, - #[serde(default = "default_1243")] + #[serde(default = "default_1249")] pub status: String, - #[serde(default = "default_1244")] + #[serde(default = "default_1250")] pub documents_seen: Integer, - #[serde(default = "default_1245")] + #[serde(default = "default_1251")] pub changed: Integer, - #[serde(default = "default_1246")] + #[serde(default = "default_1252")] pub removed: Integer, - #[serde(default = "default_1247")] + #[serde(default = "default_1253")] pub unconverted: Integer, - #[serde(default = "default_1248")] + #[serde(default = "default_1254")] pub unconverted_reasons: std::collections::HashMap, - #[serde(default = "default_1249")] + #[serde(default = "default_1255")] pub skipped: Integer, - #[serde(default = "default_1250")] + #[serde(default = "default_1256")] pub error: String, - #[serde(default = "default_1251")] + #[serde(default = "default_1257")] pub pending_extract: Integer, - #[serde(default = "default_1252")] + #[serde(default = "default_1258")] pub last_extracted_at: String, - #[serde(default = "default_1253")] + #[serde(default = "default_1259")] pub extracted: Integer, - #[serde(default = "default_1254")] + #[serde(default = "default_1260")] pub flagged_pinned: Integer, - #[serde(default = "default_1255")] + #[serde(default = "default_1261")] pub unextracted: Integer, - #[serde(default = "default_1256")] + #[serde(default = "default_1262")] pub extract_error: String, } @@ -27469,11 +27767,11 @@ pub struct KnowledgeSourceSync { #[non_exhaustive] pub struct KnowledgeSourceDocument { pub source_uri: String, - #[serde(default = "default_1258")] + #[serde(default = "default_1264")] pub title: String, - #[serde(default = "default_1259")] + #[serde(default = "default_1265")] pub source_revision: String, - #[serde(default = "default_1260")] + #[serde(default = "default_1266")] pub ingested_at: String, } @@ -27482,29 +27780,29 @@ pub struct KnowledgeSourceDocument { pub struct KnowledgeSourceInspectOutput { pub name: String, pub kind: String, - #[serde(default = "default_1231")] + #[serde(default = "default_1237")] pub credential_mode: String, - #[serde(default = "default_1232")] + #[serde(default = "default_1238")] pub owned_by_caller: bool, - #[serde(default = "default_1233")] + #[serde(default = "default_1239")] pub access: String, - #[serde(default = "default_1234")] + #[serde(default = "default_1240")] pub crawl_options: std::collections::HashMap, - #[serde(default = "default_1235")] + #[serde(default = "default_1241")] pub owner_subject: String, - #[serde(default = "default_1236")] + #[serde(default = "default_1242")] pub items: Vec>, - #[serde(default = "default_1237")] + #[serde(default = "default_1243")] pub include: Vec, - #[serde(default = "default_1238")] + #[serde(default = "default_1244")] pub config: std::collections::HashMap, - #[serde(default = "default_1239")] + #[serde(default = "default_1245")] pub created_by: String, - #[serde(default = "default_1240")] + #[serde(default = "default_1246")] pub created_at: String, - #[serde(default = "default_1257")] + #[serde(default = "default_1263")] pub sync: KnowledgeSourceSync, - #[serde(default = "default_1261")] + #[serde(default = "default_1267")] pub documents: Vec, } @@ -27557,40 +27855,40 @@ impl KnowledgeSourceInspectInput { pub struct KnowledgeSourceEntry { pub name: String, pub kind: String, - #[serde(default = "default_1262")] + #[serde(default = "default_1268")] pub credential_mode: String, - #[serde(default = "default_1263")] + #[serde(default = "default_1269")] pub owned_by_caller: bool, - #[serde(default = "default_1264")] + #[serde(default = "default_1270")] pub access: String, - #[serde(default = "default_1265")] + #[serde(default = "default_1271")] pub crawl_options: std::collections::HashMap, - #[serde(default = "default_1266")] + #[serde(default = "default_1272")] pub owner_subject: String, - #[serde(default = "default_1267")] + #[serde(default = "default_1273")] pub items: Vec>, - #[serde(default = "default_1268")] + #[serde(default = "default_1274")] pub include: Vec, - #[serde(default = "default_1269")] + #[serde(default = "default_1275")] pub config: std::collections::HashMap, - #[serde(default = "default_1270")] + #[serde(default = "default_1276")] pub created_by: String, - #[serde(default = "default_1271")] + #[serde(default = "default_1277")] pub created_at: String, - #[serde(default = "default_1272")] + #[serde(default = "default_1278")] pub sync: KnowledgeSourceSync, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct KnowledgeSourceListOutput { - #[serde(default = "default_1273")] + #[serde(default = "default_1279")] pub sources: Vec, - #[serde(default = "default_1274")] + #[serde(default = "default_1280")] pub enabled: bool, - #[serde(default = "default_1275")] + #[serde(default = "default_1281")] pub accepts_sources: bool, - #[serde(default = "default_1276")] + #[serde(default = "default_1282")] pub self_service: bool, } @@ -27685,7 +27983,7 @@ impl std::fmt::Debug for KnowledgeSourceLiveDocument { #[non_exhaustive] pub struct KnowledgeSourceLiveOutput { pub status: KnowledgeSourceLiveOutputStatus, - #[serde(default = "default_1277")] + #[serde(default = "default_1283")] pub document: Option, } impl std::fmt::Debug for KnowledgeSourceLiveOutput { @@ -27753,18 +28051,18 @@ impl KnowledgeSourceLiveInput { #[non_exhaustive] pub struct KnowledgeSourceParsedLink { pub link: String, - #[serde(default = "default_1278")] + #[serde(default = "default_1284")] pub kind: String, - #[serde(default = "default_1279")] + #[serde(default = "default_1285")] pub item: std::collections::HashMap, - #[serde(default = "default_1280")] + #[serde(default = "default_1286")] pub unreadable: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct KnowledgeSourceParseLinksOutput { - #[serde(default = "default_1281")] + #[serde(default = "default_1287")] pub links: Vec, } @@ -27815,25 +28113,25 @@ impl KnowledgeSourceParseLinksInput { #[derive(Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct PushStatusOutput { - #[serde(default = "default_1282")] + #[serde(default = "default_1288")] pub enabled: bool, - #[serde(default = "default_1283")] + #[serde(default = "default_1289")] pub status: String, - #[serde(default = "default_1284")] + #[serde(default = "default_1290")] pub provider: String, - #[serde(default = "default_1285")] + #[serde(default = "default_1291")] pub generation: String, - #[serde(default = "default_1286")] + #[serde(default = "default_1292")] pub callback_url: String, - #[serde(default = "default_1287")] + #[serde(default = "default_1293")] pub provider_id: String, - #[serde(default = "default_1288")] + #[serde(default = "default_1294")] pub challenge_fingerprint: String, - #[serde(default = "default_1289")] + #[serde(default = "default_1295")] pub verification_token: String, - #[serde(default = "default_1290")] + #[serde(default = "default_1296")] pub channels: Integer, - #[serde(default = "default_1291")] + #[serde(default = "default_1297")] pub expires_at: f64, } impl std::fmt::Debug for PushStatusOutput { @@ -28078,7 +28376,7 @@ impl PushStatusInput { #[non_exhaustive] pub struct KnowledgeSourceRemoveOutput { pub name: String, - #[serde(default = "default_1292")] + #[serde(default = "default_1298")] pub documents_pending: Integer, } @@ -28140,12 +28438,12 @@ impl KnowledgeSourceRemoveInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct KnowledgeSourceRotateOutput { - #[serde(default = "default_1293")] + #[serde(default = "default_1299")] pub crawl_proof: Option, pub name: String, - #[serde(default = "default_1294")] + #[serde(default = "default_1300")] pub probe: KnowledgeSourceProbe, - #[serde(default = "default_1295")] + #[serde(default = "default_1301")] pub rotated_at: String, } @@ -28197,7 +28495,7 @@ impl KnowledgeSourceRotateInput { #[non_exhaustive] pub struct KnowledgeSourceSyncNowOutput { pub name: String, - #[serde(default = "default_1296")] + #[serde(default = "default_1302")] pub enabled: bool, } @@ -28259,20 +28557,20 @@ impl KnowledgeSourceSyncNowInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct KnowledgeSourceUpdateOutput { - #[serde(default = "default_1297")] + #[serde(default = "default_1303")] pub crawl_proof: Option, pub name: String, - #[serde(default = "default_1298")] + #[serde(default = "default_1304")] pub items: Vec>, - #[serde(default = "default_1299")] + #[serde(default = "default_1305")] pub include: Vec, - #[serde(default = "default_1300")] + #[serde(default = "default_1306")] pub config: std::collections::HashMap, - #[serde(default = "default_1301")] + #[serde(default = "default_1307")] pub added: Vec>, - #[serde(default = "default_1302")] + #[serde(default = "default_1308")] pub removed: Vec>, - #[serde(default = "default_1303")] + #[serde(default = "default_1309")] pub probe: KnowledgeSourceProbe, } @@ -28415,7 +28713,7 @@ pub enum WorkerApproveOutputStatus { #[non_exhaustive] pub struct WorkerApproveOutput { pub status: WorkerApproveOutputStatus, - #[serde(default = "default_1304")] + #[serde(default = "default_1310")] pub approval_generation: Option, } @@ -28515,9 +28813,9 @@ pub enum WorkerEnrollOutputStatus { #[non_exhaustive] pub struct WorkerEnrollOutput { pub status: WorkerEnrollOutputStatus, - #[serde(default = "default_1305")] + #[serde(default = "default_1311")] pub connection_id: Option, - #[serde(default = "default_1306")] + #[serde(default = "default_1312")] pub connection_generation: Option, } @@ -28606,19 +28904,19 @@ pub enum ReaderPolicy { #[non_exhaustive] pub struct WorkerPreviewOutput { pub status: WorkerPreviewOutputStatus, - #[serde(default = "default_1307")] + #[serde(default = "default_1313")] pub reader_policy: Option, - #[serde(default = "default_1308")] + #[serde(default = "default_1314")] pub stores_copy: Option, - #[serde(default = "default_1309")] + #[serde(default = "default_1315")] pub disclosure: Option, - #[serde(default = "default_1310")] + #[serde(default = "default_1316")] pub selected: Option, - #[serde(default = "default_1311")] + #[serde(default = "default_1317")] pub fingerprint: Option, - #[serde(default = "default_1312")] + #[serde(default = "default_1318")] pub evidence: Option, - #[serde(default = "default_1313")] + #[serde(default = "default_1319")] pub expires_at: Option, } @@ -28775,9 +29073,9 @@ pub struct WorkerProfileCursor { #[non_exhaustive] pub struct WorkerProfilesOutput { pub status: WorkerProfilesOutputStatus, - #[serde(default = "default_1314")] + #[serde(default = "default_1320")] pub profiles: Vec, - #[serde(default = "default_1315")] + #[serde(default = "default_1321")] pub next_page: Option, } @@ -28890,9 +29188,9 @@ pub enum WorkerRegisterOutputStatus { #[non_exhaustive] pub struct WorkerRegisterOutput { pub status: WorkerRegisterOutputStatus, - #[serde(default = "default_1316")] + #[serde(default = "default_1322")] pub source_id: Option, - #[serde(default = "default_1317")] + #[serde(default = "default_1323")] pub name: Option, } @@ -28994,9 +29292,9 @@ impl WorkerRegisterInput { pub struct CitedChunk { pub source_uri: String, pub chunk_idx: Integer, - #[serde(default = "default_1319")] + #[serde(default = "default_1325")] pub revision: Integer, - #[serde(default = "default_1320")] + #[serde(default = "default_1326")] pub locator: Option>, } @@ -29005,12 +29303,12 @@ pub struct CitedChunk { pub struct SynthesizeCalculation { pub columns: Vec, pub rows: Vec>, - #[serde(default = "default_1327")] + #[serde(default = "default_1333")] pub row_ids: Vec>, - #[serde(default = "default_1328")] + #[serde(default = "default_1334")] pub truncated: bool, pub complete: bool, - #[serde(default = "default_1329")] + #[serde(default = "default_1335")] pub incomplete: Vec, pub receipt: QueryReceipt, pub citation: String, @@ -29024,23 +29322,23 @@ pub struct KnowledgeSynthesizeOutput { pub chunks_read: Integer, pub documents: Integer, pub reduce_rounds: Integer, - #[serde(default = "default_1318")] + #[serde(default = "default_1324")] pub citations: Vec, - #[serde(default = "default_1321")] + #[serde(default = "default_1327")] pub cited_chunks: Vec, - #[serde(default = "default_1322")] + #[serde(default = "default_1328")] pub unsupported_citations: Vec, - #[serde(default = "default_1323")] + #[serde(default = "default_1329")] pub truncated: bool, - #[serde(default = "default_1324")] + #[serde(default = "default_1330")] pub abstain: bool, - #[serde(default = "default_1325")] + #[serde(default = "default_1331")] pub abstain_reason: String, - #[serde(default = "default_1326")] + #[serde(default = "default_1332")] pub clarification: String, - #[serde(default = "default_1330")] + #[serde(default = "default_1336")] pub calculations: Vec, - #[serde(default = "default_1331")] + #[serde(default = "default_1337")] pub model: String, } @@ -29156,13 +29454,13 @@ impl KnowledgeSynthesizeInput { #[non_exhaustive] pub struct KnowledgeUpdateMetadataOutput { pub updated: bool, - #[serde(default = "default_1332")] + #[serde(default = "default_1338")] pub title: String, - #[serde(default = "default_1333")] + #[serde(default = "default_1339")] pub description: String, - #[serde(default = "default_1334")] + #[serde(default = "default_1340")] pub tags: Vec, - #[serde(default = "default_1335")] + #[serde(default = "default_1341")] pub chunks_reindexed: Integer, } @@ -29274,13 +29572,13 @@ pub struct KnowledgeUpsertOutput { pub chunks_superseded: Integer, pub embedding_model: String, pub embedding_dim: Integer, - #[serde(default = "default_1336")] + #[serde(default = "default_1342")] pub duplicate_of_uri: String, - #[serde(default = "default_1337")] + #[serde(default = "default_1343")] pub duplicate_chunk_count: Integer, - #[serde(default = "default_1338")] + #[serde(default = "default_1344")] pub namespace: String, - #[serde(default = "default_1339")] + #[serde(default = "default_1345")] pub source_uri: String, } @@ -29465,26 +29763,26 @@ pub struct LearningEntry { pub memory_type: String, pub proposed_value: Value, pub supporter_count: Integer, - #[serde(default = "default_1340")] + #[serde(default = "default_1346")] pub supporter_sessions: Integer, - #[serde(default = "default_1341")] + #[serde(default = "default_1347")] pub supporter_writers: Integer, pub confidence_avg: f64, pub supporters: Vec, pub rationale: String, - #[serde(default = "default_1342")] + #[serde(default = "default_1348")] pub source_kind: String, - #[serde(default = "default_1343")] + #[serde(default = "default_1349")] pub source_resource_id: String, - #[serde(default = "default_1344")] + #[serde(default = "default_1350")] pub agent: String, pub status: LearningEntryStatus, pub proposed_at: String, - #[serde(default = "default_1345")] + #[serde(default = "default_1351")] pub decided_at: Option, - #[serde(default = "default_1346")] + #[serde(default = "default_1352")] pub decided_by: String, - #[serde(default = "default_1347")] + #[serde(default = "default_1353")] pub decision_reason: String, } @@ -29687,11 +29985,11 @@ pub enum LearningsReviewOutputNewStatus { pub struct LearningsReviewOutput { pub candidate_id: String, pub new_status: LearningsReviewOutputNewStatus, - #[serde(default = "default_1348")] + #[serde(default = "default_1354")] pub promoted_to_shared: bool, - #[serde(default = "default_1349")] + #[serde(default = "default_1355")] pub promoted_to_knowledge: bool, - #[serde(default = "default_1350")] + #[serde(default = "default_1356")] pub knowledge_source_uri: String, pub decided_at: String, } @@ -29895,7 +30193,7 @@ impl MemoryAgentsListInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct AggregateRow { - #[serde(default = "default_1351")] + #[serde(default = "default_1357")] pub group: std::collections::HashMap, pub metric: f64, } @@ -29903,9 +30201,9 @@ pub struct AggregateRow { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryAggregateOutput { - #[serde(default = "default_1352")] + #[serde(default = "default_1358")] pub rows: Vec, - #[serde(default = "default_1353")] + #[serde(default = "default_1359")] pub sql_executed: String, } @@ -30073,15 +30371,15 @@ impl MemoryAggregateInput { pub struct BulkSetResult { pub memory_key: String, pub version: Integer, - #[serde(default = "default_1354")] + #[serde(default = "default_1360")] pub memory_id: String, - #[serde(default = "default_1355")] + #[serde(default = "default_1361")] pub conflict_verdict: String, - #[serde(default = "default_1356")] + #[serde(default = "default_1362")] pub peers: Vec, - #[serde(default = "default_1357")] + #[serde(default = "default_1363")] pub next: String, - #[serde(default = "default_1358")] + #[serde(default = "default_1364")] pub pinned_blocker_id: String, } @@ -30089,29 +30387,29 @@ pub struct BulkSetResult { #[non_exhaustive] pub struct MemoryBulkSetOutput { pub written: Vec, - #[serde(default = "default_1359")] + #[serde(default = "default_1365")] pub skipped_pinned: Vec, - #[serde(default = "default_1360")] + #[serde(default = "default_1366")] pub skipped_locked: Vec, - #[serde(default = "default_1361")] + #[serde(default = "default_1367")] pub skipped_blacklisted: Vec, - #[serde(default = "default_1362")] + #[serde(default = "default_1368")] pub merged: Vec, - #[serde(default = "default_1363")] + #[serde(default = "default_1369")] pub value_updates_linked: Integer, - #[serde(default = "default_1364")] + #[serde(default = "default_1370")] pub rejected_pinned: Vec, - #[serde(default = "default_1365")] + #[serde(default = "default_1371")] pub duplicates: Vec, - #[serde(default = "default_1366")] + #[serde(default = "default_1372")] pub conflicted: Vec, - #[serde(default = "default_1367")] + #[serde(default = "default_1373")] pub unchecked: Integer, - #[serde(default = "default_1368")] + #[serde(default = "default_1374")] pub retyped: Vec, - #[serde(default = "default_1369")] + #[serde(default = "default_1375")] pub identity_duplicates: std::collections::HashMap, - #[serde(default = "default_1370")] + #[serde(default = "default_1376")] pub stage_ms: std::collections::HashMap, } @@ -30261,18 +30559,18 @@ pub enum ApplyRowStatus { #[non_exhaustive] pub struct ApplyRow { pub memory_key: String, - #[serde(default = "default_1378")] + #[serde(default = "default_1384")] pub memory_id: String, - #[serde(default = "default_1379")] + #[serde(default = "default_1385")] pub agent: String, - #[serde(default = "default_1380")] + #[serde(default = "default_1386")] pub user_id: String, - #[serde(default = "default_1381")] + #[serde(default = "default_1387")] pub session_id: String, pub status: ApplyRowStatus, - #[serde(default = "default_1382")] + #[serde(default = "default_1388")] pub version: Option, - #[serde(default = "default_1383")] + #[serde(default = "default_1389")] pub detail: String, } @@ -30282,21 +30580,21 @@ pub struct MemoryApplyOutput { pub action: String, pub dry_run: bool, pub target: String, - #[serde(default = "default_1371")] + #[serde(default = "default_1377")] pub matched: Integer, - #[serde(default = "default_1372")] + #[serde(default = "default_1378")] pub applied: Integer, - #[serde(default = "default_1373")] + #[serde(default = "default_1379")] pub would_apply: Integer, - #[serde(default = "default_1374")] + #[serde(default = "default_1380")] pub refused: Integer, - #[serde(default = "default_1375")] + #[serde(default = "default_1381")] pub noop: Integer, - #[serde(default = "default_1376")] + #[serde(default = "default_1382")] pub failed: Integer, - #[serde(default = "default_1377")] + #[serde(default = "default_1383")] pub truncated: bool, - #[serde(default = "default_1384")] + #[serde(default = "default_1390")] pub rows: Vec, } @@ -31030,137 +31328,137 @@ pub enum MemoryAskOutputDeepFirst { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryAskOutput { - #[serde(default = "default_1385")] + #[serde(default = "default_1391")] pub answer: String, - #[serde(default = "default_1386")] + #[serde(default = "default_1392")] pub source: MemoryAskOutputSource, - #[serde(default = "default_1387")] + #[serde(default = "default_1393")] pub abstain: bool, - #[serde(default = "default_1388")] + #[serde(default = "default_1394")] pub abstain_reason: String, - #[serde(default = "default_1389")] + #[serde(default = "default_1395")] pub memory_keys: Vec, - #[serde(default = "default_1390")] + #[serde(default = "default_1396")] pub results: Vec, - #[serde(default = "default_1391")] + #[serde(default = "default_1397")] pub cited_sessions: Vec, - #[serde(default = "default_1392")] + #[serde(default = "default_1398")] pub next: String, - #[serde(default = "default_1393")] + #[serde(default = "default_1399")] pub synth_model: String, - #[serde(default = "default_1394")] + #[serde(default = "default_1400")] pub route_tier: MemoryAskOutputRouteTier, - #[serde(default = "default_1395")] + #[serde(default = "default_1401")] pub route_reason: String, - #[serde(default = "default_1396")] + #[serde(default = "default_1402")] pub llm_cache_hits: Integer, - #[serde(default = "default_1397")] + #[serde(default = "default_1403")] pub llm_cache_misses: Integer, - #[serde(default = "default_1398")] + #[serde(default = "default_1404")] pub llm_cache: bool, - #[serde(default = "default_1399")] + #[serde(default = "default_1405")] pub llm_cache_saved_usd: f64, - #[serde(default = "default_1400")] + #[serde(default = "default_1406")] pub temporal_consistency: Option, - #[serde(default = "default_1401")] + #[serde(default = "default_1407")] pub citation_concentration: Option, - #[serde(default = "default_1402")] + #[serde(default = "default_1408")] pub escalated: bool, - #[serde(default = "default_1403")] + #[serde(default = "default_1409")] pub gate_mode: String, - #[serde(default = "default_1404")] + #[serde(default = "default_1410")] pub gate_kept: Integer, - #[serde(default = "default_1405")] + #[serde(default = "default_1411")] pub gate_dropped: Integer, - #[serde(default = "default_1406")] + #[serde(default = "default_1412")] pub pending_extraction: Integer, - #[serde(default = "default_1407")] + #[serde(default = "default_1413")] pub pending_evidence: Integer, - #[serde(default = "default_1408")] + #[serde(default = "default_1414")] pub retrieval_query: String, - #[serde(default = "default_1409")] + #[serde(default = "default_1415")] pub facets: Vec, - #[serde(default = "default_1410")] + #[serde(default = "default_1416")] pub facet_memories_added: Integer, - #[serde(default = "default_1411")] + #[serde(default = "default_1417")] pub consistency: MemoryAskOutputConsistency, - #[serde(default = "default_1412")] + #[serde(default = "default_1418")] pub consistency_score: f64, - #[serde(default = "default_1413")] + #[serde(default = "default_1419")] pub consistency_note: String, - #[serde(default = "default_1414")] + #[serde(default = "default_1420")] pub identifier_chase_hops: Integer, - #[serde(default = "default_1415")] + #[serde(default = "default_1421")] pub identifier_chase_added: Integer, - #[serde(default = "default_1416")] + #[serde(default = "default_1422")] pub premise_conflict: String, - #[serde(default = "default_1417")] + #[serde(default = "default_1423")] pub premise_note: String, - #[serde(default = "default_1418")] + #[serde(default = "default_1424")] pub premise_verdict: String, - #[serde(default = "default_1419")] + #[serde(default = "default_1425")] pub attribution_note: String, - #[serde(default = "default_1420")] + #[serde(default = "default_1426")] pub depth: MemoryAskOutputDepth, - #[serde(default = "default_1421")] + #[serde(default = "default_1427")] pub deep_fired: bool, - #[serde(default = "default_1422")] + #[serde(default = "default_1428")] pub decomposed: Vec, - #[serde(default = "default_1423")] + #[serde(default = "default_1429")] pub decomposed_parts: Integer, - #[serde(default = "default_1424")] + #[serde(default = "default_1430")] pub superseded_dropped: Integer, - #[serde(default = "default_1425")] + #[serde(default = "default_1431")] pub stale_sentences_masked: Integer, - #[serde(default = "default_1426")] + #[serde(default = "default_1432")] pub entity_followed: Vec, - #[serde(default = "default_1427")] + #[serde(default = "default_1433")] pub when_evidence_turns: Integer, - #[serde(default = "default_1428")] + #[serde(default = "default_1434")] pub decompose_failed: Integer, - #[serde(default = "default_1429")] + #[serde(default = "default_1435")] pub pool_k: Integer, - #[serde(default = "default_1430")] + #[serde(default = "default_1436")] pub grounding: MemoryAskOutputGrounding, - #[serde(default = "default_1431")] + #[serde(default = "default_1437")] pub deep_reason: String, - #[serde(default = "default_1432")] + #[serde(default = "default_1438")] pub deep_keys: Vec, - #[serde(default = "default_1433")] + #[serde(default = "default_1439")] pub deep_chars: Integer, - #[serde(default = "default_1434")] + #[serde(default = "default_1440")] pub code_hits: Integer, - #[serde(default = "default_1435")] + #[serde(default = "default_1441")] pub pool_facts: Integer, - #[serde(default = "default_1436")] + #[serde(default = "default_1442")] pub pool_chunks: Integer, - #[serde(default = "default_1437")] + #[serde(default = "default_1443")] pub prompt_blocks: std::collections::HashMap, - #[serde(default = "default_1438")] + #[serde(default = "default_1444")] pub deep_selector: MemoryAskOutputDeepSelector, - #[serde(default = "default_1439")] + #[serde(default = "default_1445")] pub deep_first: MemoryAskOutputDeepFirst, - #[serde(default = "default_1440")] + #[serde(default = "default_1446")] pub synth_calls: Integer, - #[serde(default = "default_1441")] + #[serde(default = "default_1447")] pub synth_input_tokens: Integer, - #[serde(default = "default_1442")] + #[serde(default = "default_1448")] pub synth_cached_input_tokens: Integer, - #[serde(default = "default_1443")] + #[serde(default = "default_1449")] pub synth_cache_write_tokens: Integer, - #[serde(default = "default_1444")] + #[serde(default = "default_1450")] pub synth_cost_usd: f64, - #[serde(default = "default_1445")] + #[serde(default = "default_1451")] pub context_tokens_est: Integer, - #[serde(default = "default_1446")] + #[serde(default = "default_1452")] pub context_trimmed: Integer, - #[serde(default = "default_1447")] + #[serde(default = "default_1453")] pub summary_hits: Integer, - #[serde(default = "default_1448")] + #[serde(default = "default_1454")] pub knowledge_hits: Integer, - #[serde(default = "default_1449")] + #[serde(default = "default_1455")] pub timeline_rows: Integer, - #[serde(default = "default_1450")] + #[serde(default = "default_1456")] pub count_recomputed: bool, } @@ -32115,36 +32413,36 @@ pub struct MemoryAutoRetirement { pub reason: String, pub memory_id: String, pub memory_key: String, - #[serde(default = "default_1451")] + #[serde(default = "default_1457")] pub agent: String, - #[serde(default = "default_1452")] + #[serde(default = "default_1458")] pub user_id: String, - #[serde(default = "default_1453")] + #[serde(default = "default_1459")] pub session_id: String, - #[serde(default = "default_1454")] + #[serde(default = "default_1460")] pub superseded_by: String, - #[serde(default = "default_1455")] + #[serde(default = "default_1461")] pub superseded_by_key: String, - #[serde(default = "default_1456")] + #[serde(default = "default_1462")] pub label: String, - #[serde(default = "default_1457")] + #[serde(default = "default_1463")] pub unconfirmed: bool, - #[serde(default = "default_1458")] + #[serde(default = "default_1464")] pub judge_verdict: String, - #[serde(default = "default_1459")] + #[serde(default = "default_1465")] pub judge_confidence: Option, - #[serde(default = "default_1460")] + #[serde(default = "default_1466")] pub judge_model: String, - #[serde(default = "default_1461")] + #[serde(default = "default_1467")] pub judge_prompt_version: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryAutoRetirementsOutput { - #[serde(default = "default_1462")] + #[serde(default = "default_1468")] pub rows: Vec, - #[serde(default = "default_1463")] + #[serde(default = "default_1469")] pub next_cursor: Option, } @@ -32238,9 +32536,9 @@ impl MemoryAutoRetirementsInput { #[non_exhaustive] pub struct BacklinkVersion { pub version: Integer, - #[serde(default = "default_1465")] + #[serde(default = "default_1471")] pub status: String, - #[serde(default = "default_1466")] + #[serde(default = "default_1472")] pub created_at: String, } @@ -32248,7 +32546,7 @@ pub struct BacklinkVersion { #[non_exhaustive] pub struct BacklinkDigest { pub session_id: String, - #[serde(default = "default_1468")] + #[serde(default = "default_1474")] pub date: String, } @@ -32256,9 +32554,9 @@ pub struct BacklinkDigest { #[non_exhaustive] pub struct BacklinkEdge { pub memory_key: String, - #[serde(default = "default_1470")] + #[serde(default = "default_1476")] pub relation: String, - #[serde(default = "default_1471")] + #[serde(default = "default_1477")] pub created_at: String, } @@ -32266,7 +32564,7 @@ pub struct BacklinkEdge { #[non_exhaustive] pub struct BacklinkRelated { pub memory_key: String, - #[serde(default = "default_1475")] + #[serde(default = "default_1481")] pub shared_entities: Vec, } @@ -32274,19 +32572,19 @@ pub struct BacklinkRelated { #[non_exhaustive] pub struct MemoryBacklinksOutput { pub memory_key: String, - #[serde(default = "default_1464")] + #[serde(default = "default_1470")] pub found: bool, - #[serde(default = "default_1467")] + #[serde(default = "default_1473")] pub versions: Vec, - #[serde(default = "default_1469")] + #[serde(default = "default_1475")] pub digests: Vec, - #[serde(default = "default_1472")] + #[serde(default = "default_1478")] pub links_in: Vec, - #[serde(default = "default_1473")] + #[serde(default = "default_1479")] pub links_out: Vec, - #[serde(default = "default_1474")] + #[serde(default = "default_1480")] pub evidence_count: Integer, - #[serde(default = "default_1476")] + #[serde(default = "default_1482")] pub related: Vec, } @@ -32391,36 +32689,36 @@ impl MemoryBacklinksInput { #[non_exhaustive] pub struct BriefEvidence { pub memory_key: String, - #[serde(default = "default_1481")] + #[serde(default = "default_1487")] pub source: String, - #[serde(default = "default_1482")] + #[serde(default = "default_1488")] pub source_class: String, - #[serde(default = "default_1483")] + #[serde(default = "default_1489")] pub verified: bool, - #[serde(default = "default_1484")] + #[serde(default = "default_1490")] pub when: String, - #[serde(default = "default_1485")] + #[serde(default = "default_1491")] pub session_id: String, - #[serde(default = "default_1486")] + #[serde(default = "default_1492")] pub excerpt: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryBriefOutput { - #[serde(default = "default_1477")] + #[serde(default = "default_1483")] pub query: String, - #[serde(default = "default_1478")] + #[serde(default = "default_1484")] pub answer: String, - #[serde(default = "default_1479")] + #[serde(default = "default_1485")] pub abstained: bool, - #[serde(default = "default_1480")] + #[serde(default = "default_1486")] pub grounding: String, - #[serde(default = "default_1487")] + #[serde(default = "default_1493")] pub evidence: Vec, - #[serde(default = "default_1488")] + #[serde(default = "default_1494")] pub unknowns: Vec, - #[serde(default = "default_1489")] + #[serde(default = "default_1495")] pub next_reads: Vec, } @@ -32834,9 +33132,9 @@ pub struct MemoryBulkGetOutputMemoryGetOutput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryBulkGetOutput { - #[serde(default = "default_1490")] + #[serde(default = "default_1496")] pub results: std::collections::HashMap, - #[serde(default = "default_1491")] + #[serde(default = "default_1497")] pub missing: Vec, } @@ -33349,7 +33647,7 @@ pub struct MemoryClearOutput { pub cleared_at: String, pub rows_affected: std::collections::HashMap, pub total: Integer, - #[serde(default = "default_1492")] + #[serde(default = "default_1498")] pub locked_skipped: Integer, } @@ -33437,21 +33735,21 @@ pub struct MemoryConsolidateResult { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryConsolidateOutput { - #[serde(default = "default_1493")] + #[serde(default = "default_1499")] pub consolidated: Vec, - #[serde(default = "default_1494")] + #[serde(default = "default_1500")] pub examined: Integer, - #[serde(default = "default_1495")] + #[serde(default = "default_1501")] pub clusters_found: Integer, - #[serde(default = "default_1496")] + #[serde(default = "default_1502")] pub clusters_failed: Integer, - #[serde(default = "default_1497")] + #[serde(default = "default_1503")] pub clusters_refused_lossy: Integer, - #[serde(default = "default_1498")] + #[serde(default = "default_1504")] pub skipped_in_flight: Integer, - #[serde(default = "default_1499")] + #[serde(default = "default_1505")] pub tokens_in: Integer, - #[serde(default = "default_1500")] + #[serde(default = "default_1506")] pub tokens_out: Integer, } @@ -33592,7 +33890,7 @@ impl MemoryConsolidateInput { #[non_exhaustive] pub struct MemoryCopyToOutput { pub copied: bool, - #[serde(default = "default_1501")] + #[serde(default = "default_1507")] pub target_memory_id: String, pub target_namespace: String, pub target_key: String, @@ -33703,11 +34001,11 @@ impl MemoryCopyToInput { #[non_exhaustive] pub struct MemoryCrossPromoteOutput { pub promoted: bool, - #[serde(default = "default_1502")] + #[serde(default = "default_1508")] pub target_memory_id: String, pub target_namespace: String, pub target_key: String, - #[serde(default = "default_1503")] + #[serde(default = "default_1509")] pub cross_promoted_from_memory_id: String, } @@ -33790,23 +34088,23 @@ pub struct DedupCollapsePair { #[non_exhaustive] pub struct MemoryDedupCollapseOutput { pub namespace: String, - #[serde(default = "default_1504")] + #[serde(default = "default_1510")] pub prefix: String, - #[serde(default = "default_1505")] + #[serde(default = "default_1511")] pub dry_run: bool, - #[serde(default = "default_1506")] + #[serde(default = "default_1512")] pub pairs: Integer, - #[serde(default = "default_1507")] + #[serde(default = "default_1513")] pub canonical_live: Integer, - #[serde(default = "default_1508")] + #[serde(default = "default_1514")] pub orphans: Integer, - #[serde(default = "default_1509")] + #[serde(default = "default_1515")] pub mirror_stale: Integer, - #[serde(default = "default_1510")] + #[serde(default = "default_1516")] pub restamped: Integer, - #[serde(default = "default_1511")] + #[serde(default = "default_1517")] pub truncated: bool, - #[serde(default = "default_1512")] + #[serde(default = "default_1518")] pub sample: Vec, } @@ -33905,7 +34203,7 @@ pub struct DedupDuplicate { pub memory_id: String, pub memory_key: String, pub agent: String, - #[serde(default = "default_1515")] + #[serde(default = "default_1521")] pub created_at: Option, } @@ -33913,12 +34211,12 @@ pub struct DedupDuplicate { #[non_exhaustive] pub struct DedupCluster { pub canonical_id: String, - #[serde(default = "default_1513")] + #[serde(default = "default_1519")] pub canonical_key: String, - #[serde(default = "default_1514")] + #[serde(default = "default_1520")] pub canonical_agent: String, pub dup_count: Integer, - #[serde(default = "default_1516")] + #[serde(default = "default_1522")] pub duplicates: Vec, } @@ -33990,11 +34288,11 @@ pub struct MemoryDedupResolveOutput { pub canonical_key: String, pub duplicate_key: String, pub decision: String, - #[serde(default = "default_1517")] + #[serde(default = "default_1523")] pub canonical_tombstoned: bool, - #[serde(default = "default_1518")] + #[serde(default = "default_1524")] pub duplicate_tombstoned: bool, - #[serde(default = "default_1519")] + #[serde(default = "default_1525")] pub ignored_args: Vec, } @@ -34132,17 +34430,17 @@ pub struct LostName { pub struct DefinitionEntry { pub memory_key: String, pub promoted_at: String, - #[serde(default = "default_1520")] + #[serde(default = "default_1526")] pub capped: bool, - #[serde(default = "default_1521")] + #[serde(default = "default_1527")] pub term: Option, - #[serde(default = "default_1522")] + #[serde(default = "default_1528")] pub aliases: Vec, - #[serde(default = "default_1523")] + #[serde(default = "default_1529")] pub verdict: Option, - #[serde(default = "default_1524")] + #[serde(default = "default_1530")] pub lapse_reason: Option, - #[serde(default = "default_1525")] + #[serde(default = "default_1531")] pub lost: Vec, } @@ -34203,15 +34501,15 @@ impl MemoryDefinitionsListInput { #[non_exhaustive] pub struct MemoryDeleteVersionOutput { pub tombstoned: bool, - #[serde(default = "default_1526")] + #[serde(default = "default_1532")] pub version: Integer, - #[serde(default = "default_1527")] + #[serde(default = "default_1533")] pub found: bool, - #[serde(default = "default_1528")] + #[serde(default = "default_1534")] pub reason: String, - #[serde(default = "default_1529")] + #[serde(default = "default_1535")] pub dependents_tombstoned: Integer, - #[serde(default = "default_1530")] + #[serde(default = "default_1536")] pub dependents_downgraded: Integer, } @@ -34338,21 +34636,21 @@ pub struct DemonstrationRow { pub struct MemoryDemonstrateOutput { pub query: String, pub demonstrations: Vec, - #[serde(default = "default_1531")] + #[serde(default = "default_1537")] pub votes: std::collections::HashMap, - #[serde(default = "default_1532")] + #[serde(default = "default_1538")] pub predicted_label: String, - #[serde(default = "default_1533")] + #[serde(default = "default_1539")] pub margin: f64, - #[serde(default = "default_1534")] + #[serde(default = "default_1540")] pub abstain: bool, - #[serde(default = "default_1535")] + #[serde(default = "default_1541")] pub abstain_reason: String, - #[serde(default = "default_1536")] + #[serde(default = "default_1542")] pub few_shot_block: String, - #[serde(default = "default_1537")] + #[serde(default = "default_1543")] pub examined: Integer, - #[serde(default = "default_1538")] + #[serde(default = "default_1544")] pub labelled: Integer, } @@ -34492,7 +34790,7 @@ impl MemoryDemonstrateInput { pub struct MemoryDemoteOutput { pub demoted: bool, pub was_reversible: bool, - #[serde(default = "default_1539")] + #[serde(default = "default_1545")] pub tombstoned_at: Option, } @@ -34554,15 +34852,15 @@ impl MemoryDemoteInput { pub struct DigestRow { pub session_id: String, pub summary_text: String, - #[serde(default = "default_1540")] + #[serde(default = "default_1546")] pub key_facts: Vec, - #[serde(default = "default_1541")] + #[serde(default = "default_1547")] pub derived_from: Vec, - #[serde(default = "default_1542")] + #[serde(default = "default_1548")] pub valid_at: Option, - #[serde(default = "default_1543")] + #[serde(default = "default_1549")] pub created_at: Option, - #[serde(default = "default_1544")] + #[serde(default = "default_1550")] pub version: Integer, } @@ -34570,7 +34868,7 @@ pub struct DigestRow { #[non_exhaustive] pub struct MemoryDigestsOutput { pub rows: Vec, - #[serde(default = "default_1545")] + #[serde(default = "default_1551")] pub truncated: bool, } @@ -34695,17 +34993,17 @@ pub struct MemoryEvidenceItem { pub evidence_id: String, pub support_type: String, pub scope: MemoryEvidenceItemScope, - #[serde(default = "default_1549")] + #[serde(default = "default_1555")] pub role: String, - #[serde(default = "default_1550")] + #[serde(default = "default_1556")] pub observed_at: Option, - #[serde(default = "default_1551")] + #[serde(default = "default_1557")] pub content: String, - #[serde(default = "default_1552")] + #[serde(default = "default_1558")] pub char_start: Integer, - #[serde(default = "default_1553")] + #[serde(default = "default_1559")] pub char_end: Integer, - #[serde(default = "default_1554")] + #[serde(default = "default_1560")] pub span: String, } @@ -34713,23 +35011,23 @@ pub struct MemoryEvidenceItem { #[non_exhaustive] pub struct MemoryEvidenceOutput { pub found: bool, - #[serde(default = "default_1546")] + #[serde(default = "default_1552")] pub memory_key: String, - #[serde(default = "default_1547")] + #[serde(default = "default_1553")] pub memory_id: String, - #[serde(default = "default_1548")] + #[serde(default = "default_1554")] pub value: String, - #[serde(default = "default_1555")] + #[serde(default = "default_1561")] pub items: Vec, - #[serde(default = "default_1556")] + #[serde(default = "default_1562")] pub truncated: bool, - #[serde(default = "default_1557")] + #[serde(default = "default_1563")] pub cited: Integer, - #[serde(default = "default_1558")] + #[serde(default = "default_1564")] pub lexical: Integer, - #[serde(default = "default_1559")] + #[serde(default = "default_1565")] pub window: Integer, - #[serde(default = "default_1560")] + #[serde(default = "default_1566")] pub derived: Integer, } @@ -34834,26 +35132,26 @@ impl MemoryEvidenceInput { #[non_exhaustive] pub struct EvidenceChunk { pub session_id: String, - #[serde(default = "default_1561")] + #[serde(default = "default_1567")] pub chunk_index: Integer, pub content: String, - #[serde(default = "default_1562")] + #[serde(default = "default_1568")] pub content_sha256: String, - #[serde(default = "default_1563")] + #[serde(default = "default_1569")] pub agent: String, - #[serde(default = "default_1564")] + #[serde(default = "default_1570")] pub user_id: String, - #[serde(default = "default_1565")] + #[serde(default = "default_1571")] pub parent_memory_key: String, - #[serde(default = "default_1566")] + #[serde(default = "default_1572")] pub memory_keys: Vec, - #[serde(default = "default_1567")] + #[serde(default = "default_1573")] pub line_start: Integer, - #[serde(default = "default_1568")] + #[serde(default = "default_1574")] pub line_end: Integer, - #[serde(default = "default_1569")] + #[serde(default = "default_1575")] pub created_at: String, - #[serde(default = "default_1570")] + #[serde(default = "default_1576")] pub source_url: String, } @@ -34862,17 +35160,17 @@ pub struct EvidenceChunk { pub struct EvidenceDigest { pub session_id: String, pub summary_text: String, - #[serde(default = "default_1572")] + #[serde(default = "default_1578")] pub agent: String, - #[serde(default = "default_1573")] + #[serde(default = "default_1579")] pub user_id: String, - #[serde(default = "default_1574")] + #[serde(default = "default_1580")] pub key_facts: Vec, - #[serde(default = "default_1575")] + #[serde(default = "default_1581")] pub derived_from: Vec, - #[serde(default = "default_1576")] + #[serde(default = "default_1582")] pub valid_at: String, - #[serde(default = "default_1577")] + #[serde(default = "default_1583")] pub created_at: String, } @@ -34882,28 +35180,28 @@ pub struct EvidenceEdge { pub from_key: String, pub to_key: String, pub relation: String, - #[serde(default = "default_1579")] + #[serde(default = "default_1585")] pub confidence: f64, - #[serde(default = "default_1580")] + #[serde(default = "default_1586")] pub explanation: String, - #[serde(default = "default_1581")] + #[serde(default = "default_1587")] pub created_at: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryExportEvidenceOutput { - #[serde(default = "default_1571")] + #[serde(default = "default_1577")] pub chunks: Vec, - #[serde(default = "default_1578")] + #[serde(default = "default_1584")] pub digests: Vec, - #[serde(default = "default_1582")] + #[serde(default = "default_1588")] pub edges: Vec, - #[serde(default = "default_1583")] + #[serde(default = "default_1589")] pub has_more: bool, - #[serde(default = "default_1584")] + #[serde(default = "default_1590")] pub next_cursor: String, - #[serde(default = "default_1585")] + #[serde(default = "default_1591")] pub held_high: Integer, } @@ -35096,15 +35394,15 @@ impl ExposureSummaryInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryExtractionRetryMineOutput { - #[serde(default = "default_1586")] + #[serde(default = "default_1592")] pub requeued: Vec, - #[serde(default = "default_1587")] + #[serde(default = "default_1593")] pub not_failed: Vec, - #[serde(default = "default_1588")] + #[serde(default = "default_1594")] pub model_calls_off: Vec, - #[serde(default = "default_1589")] + #[serde(default = "default_1595")] pub expired: Vec, - #[serde(default = "default_1590")] + #[serde(default = "default_1596")] pub unknown: Vec, } @@ -35165,20 +35463,20 @@ pub struct ExtractionQueueRow { pub content_chars: Integer, pub written: Integer, pub last_error: String, - #[serde(default = "default_1591")] + #[serde(default = "default_1597")] pub enqueued_at: Option, - #[serde(default = "default_1592")] + #[serde(default = "default_1598")] pub updated_at: Option, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryExtractionStatusOutput { - #[serde(default = "default_1593")] + #[serde(default = "default_1599")] pub batches: Vec, - #[serde(default = "default_1594")] + #[serde(default = "default_1600")] pub pending: Integer, - #[serde(default = "default_1595")] + #[serde(default = "default_1601")] pub failed: Integer, } @@ -35326,13 +35624,13 @@ impl MemoryExtractionStatusInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryExtractionStatusMineOutput { - #[serde(default = "default_1596")] + #[serde(default = "default_1602")] pub batches: Vec, - #[serde(default = "default_1597")] + #[serde(default = "default_1603")] pub unknown: Vec, - #[serde(default = "default_1598")] + #[serde(default = "default_1604")] pub pending: Integer, - #[serde(default = "default_1599")] + #[serde(default = "default_1605")] pub failed: Integer, } @@ -35453,39 +35751,39 @@ pub struct MemoryForFileHit { pub memory_key: String, pub memory_type: String, pub value: String, - #[serde(default = "default_1600")] + #[serde(default = "default_1606")] pub value_truncated: bool, - #[serde(default = "default_1601")] + #[serde(default = "default_1607")] pub tags: Vec, - #[serde(default = "default_1602")] + #[serde(default = "default_1608")] pub confidence: f64, - #[serde(default = "default_1603")] + #[serde(default = "default_1609")] pub pinned: bool, - #[serde(default = "default_1604")] + #[serde(default = "default_1610")] pub status: String, - #[serde(default = "default_1605")] + #[serde(default = "default_1611")] pub agent: String, - #[serde(default = "default_1606")] + #[serde(default = "default_1612")] pub updated_at: Option, - #[serde(default = "default_1607")] + #[serde(default = "default_1613")] pub namespace: String, - #[serde(default = "default_1608")] + #[serde(default = "default_1614")] pub actor: String, - #[serde(default = "default_1609")] + #[serde(default = "default_1615")] pub supersedes_key: String, - #[serde(default = "default_1610")] + #[serde(default = "default_1616")] pub supersedes: String, - #[serde(default = "default_1611")] + #[serde(default = "default_1617")] pub supersedes_kind: MemoryForFileHitSupersedesKind, - #[serde(default = "default_1612")] + #[serde(default = "default_1618")] pub matched_files: Vec, - #[serde(default = "default_1613")] + #[serde(default = "default_1619")] pub source_resource_id: String, - #[serde(default = "default_1614")] + #[serde(default = "default_1620")] pub verification: MemoryForFileHitVerification, - #[serde(default = "default_1615")] + #[serde(default = "default_1621")] pub code_state: MemoryForFileHitCodeState, - #[serde(default = "default_1616")] + #[serde(default = "default_1622")] pub code_moved: Vec, } @@ -35495,7 +35793,7 @@ pub struct MemoryForFilePrintedRow { pub namespace: String, pub memory_key: String, pub line: String, - #[serde(default = "default_1620")] + #[serde(default = "default_1626")] pub binding: bool, } @@ -35505,13 +35803,13 @@ pub struct MemoryForFileOutput { pub path: String, pub total: Integer, pub hits: Vec, - #[serde(default = "default_1617")] + #[serde(default = "default_1623")] pub rendered: String, - #[serde(default = "default_1618")] + #[serde(default = "default_1624")] pub tokens_estimate: Integer, - #[serde(default = "default_1619")] + #[serde(default = "default_1625")] pub truncated: bool, - #[serde(default = "default_1621")] + #[serde(default = "default_1627")] pub printed: Vec, } @@ -35619,61 +35917,61 @@ impl MemoryForFileInput { #[non_exhaustive] pub struct MemoryGetByIdOutput { pub found: bool, - #[serde(default = "default_1622")] + #[serde(default = "default_1628")] pub memory_id: String, - #[serde(default = "default_1623")] + #[serde(default = "default_1629")] pub namespace: String, - #[serde(default = "default_1624")] + #[serde(default = "default_1630")] pub agent: String, - #[serde(default = "default_1625")] + #[serde(default = "default_1631")] pub user_id: String, - #[serde(default = "default_1626")] + #[serde(default = "default_1632")] pub session_id: String, - #[serde(default = "default_1627")] + #[serde(default = "default_1633")] pub memory_key: String, - #[serde(default = "default_1628")] + #[serde(default = "default_1634")] pub memory_type: Option, - #[serde(default = "default_1629")] + #[serde(default = "default_1635")] pub value: Value, - #[serde(default = "default_1630")] + #[serde(default = "default_1636")] pub confidence: Option, - #[serde(default = "default_1631")] + #[serde(default = "default_1637")] pub version: Option, - #[serde(default = "default_1632")] + #[serde(default = "default_1638")] pub created_at: Option, - #[serde(default = "default_1633")] + #[serde(default = "default_1639")] pub expires_at: Option, - #[serde(default = "default_1634")] + #[serde(default = "default_1640")] pub valid_at: Option, - #[serde(default = "default_1635")] + #[serde(default = "default_1641")] pub valid_to: Option, - #[serde(default = "default_1636")] + #[serde(default = "default_1642")] pub pinned: bool, - #[serde(default = "default_1637")] + #[serde(default = "default_1643")] pub content_sha256: String, - #[serde(default = "default_1638")] + #[serde(default = "default_1644")] pub verified_by: String, - #[serde(default = "default_1639")] + #[serde(default = "default_1645")] pub verified_at: Option, - #[serde(default = "default_1640")] + #[serde(default = "default_1646")] pub verification: String, - #[serde(default = "default_1641")] + #[serde(default = "default_1647")] pub sensitivity: String, - #[serde(default = "default_1642")] + #[serde(default = "default_1648")] pub actor: String, - #[serde(default = "default_1643")] + #[serde(default = "default_1649")] pub source_class: String, - #[serde(default = "default_1644")] + #[serde(default = "default_1650")] pub lock_mode: String, - #[serde(default = "default_1645")] + #[serde(default = "default_1651")] pub lock_reason: String, - #[serde(default = "default_1646")] + #[serde(default = "default_1652")] pub lock_until: Option, - #[serde(default = "default_1647")] + #[serde(default = "default_1653")] pub locked_by: String, - #[serde(default = "default_1648")] + #[serde(default = "default_1654")] pub on_expire: String, - #[serde(default = "default_1649")] + #[serde(default = "default_1655")] pub expire_reason: String, } @@ -35749,41 +36047,41 @@ pub struct MemoryHealthTopRow { pub memory_type: String, pub recall_count: Integer, pub used_count: Integer, - #[serde(default = "default_1652")] + #[serde(default = "default_1658")] pub harm_count: Integer, - #[serde(default = "default_1653")] + #[serde(default = "default_1659")] pub last_recalled_at: Option, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryHealthStaleness { - #[serde(default = "default_1655")] + #[serde(default = "default_1661")] pub by_age: std::collections::HashMap, - #[serde(default = "default_1656")] + #[serde(default = "default_1662")] pub with_validity_end: Integer, - #[serde(default = "default_1657")] + #[serde(default = "default_1663")] pub with_validity_end_share: f64, - #[serde(default = "default_1658")] + #[serde(default = "default_1664")] pub with_expiry: Integer, - #[serde(default = "default_1659")] + #[serde(default = "default_1665")] pub expiring_7d: Integer, - #[serde(default = "default_1660")] + #[serde(default = "default_1666")] pub pinned: Integer, - #[serde(default = "default_1661")] + #[serde(default = "default_1667")] pub days_since_reinforced_p50: Integer, - #[serde(default = "default_1662")] + #[serde(default = "default_1668")] pub days_since_reinforced_p90: Integer, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryHealthFootprint { - #[serde(default = "default_1664")] + #[serde(default = "default_1670")] pub value_chars: Integer, - #[serde(default = "default_1665")] + #[serde(default = "default_1671")] pub value_tokens_est: Integer, - #[serde(default = "default_1666")] + #[serde(default = "default_1672")] pub tokens_per_row_est: f64, } @@ -35793,19 +36091,19 @@ pub struct MemoryHealthOutput { pub live: Integer, pub recalled_ever: Integer, pub used_ever: Integer, - #[serde(default = "default_1650")] + #[serde(default = "default_1656")] pub harmed_ever: Integer, pub silent: Integer, pub silent_older: Integer, pub silent_share: f64, pub silent_after_days: Integer, - #[serde(default = "default_1651")] + #[serde(default = "default_1657")] pub by_type: Vec, - #[serde(default = "default_1654")] + #[serde(default = "default_1660")] pub top_recalled: Vec, - #[serde(default = "default_1663")] + #[serde(default = "default_1669")] pub staleness: MemoryHealthStaleness, - #[serde(default = "default_1667")] + #[serde(default = "default_1673")] pub footprint: MemoryHealthFootprint, } @@ -35925,51 +36223,51 @@ impl MemoryHealthInput { pub struct MemoryHistoryRow { pub memory_id: String, pub version: Integer, - #[serde(default = "default_1668")] + #[serde(default = "default_1674")] pub version_text: String, - #[serde(default = "default_1669")] + #[serde(default = "default_1675")] pub value: Value, pub confidence: f64, - #[serde(default = "default_1670")] + #[serde(default = "default_1676")] pub source_trace: String, - #[serde(default = "default_1671")] + #[serde(default = "default_1677")] pub pinned: bool, pub created_at: String, - #[serde(default = "default_1672")] + #[serde(default = "default_1678")] pub expires_at: Option, - #[serde(default = "default_1673")] + #[serde(default = "default_1679")] pub tombstoned_at: Option, - #[serde(default = "default_1674")] + #[serde(default = "default_1680")] pub redacted_at: Option, - #[serde(default = "default_1675")] + #[serde(default = "default_1681")] pub redaction_reason: String, - #[serde(default = "default_1676")] + #[serde(default = "default_1682")] pub content_sha256: String, - #[serde(default = "default_1677")] + #[serde(default = "default_1683")] pub actor: String, - #[serde(default = "default_1678")] + #[serde(default = "default_1684")] pub source_class: String, - #[serde(default = "default_1679")] + #[serde(default = "default_1685")] pub agent: String, - #[serde(default = "default_1680")] + #[serde(default = "default_1686")] pub written_at: Option, - #[serde(default = "default_1681")] + #[serde(default = "default_1687")] pub status: String, - #[serde(default = "default_1682")] + #[serde(default = "default_1688")] pub conflict_with: Vec, - #[serde(default = "default_1683")] + #[serde(default = "default_1689")] pub tags: Vec, - #[serde(default = "default_1684")] + #[serde(default = "default_1690")] pub verified_at: Option, - #[serde(default = "default_1685")] + #[serde(default = "default_1691")] pub verified_by: String, - #[serde(default = "default_1686")] + #[serde(default = "default_1692")] pub verified_sha256: String, - #[serde(default = "default_1687")] + #[serde(default = "default_1693")] pub lock_mode: String, - #[serde(default = "default_1688")] + #[serde(default = "default_1694")] pub lock_reason: String, - #[serde(default = "default_1689")] + #[serde(default = "default_1695")] pub lock_until: Option, } @@ -36079,13 +36377,13 @@ impl MemoryHistoryInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryImportTotals { - #[serde(default = "default_1690")] + #[serde(default = "default_1696")] pub written: Integer, - #[serde(default = "default_1691")] + #[serde(default = "default_1697")] pub held: Integer, - #[serde(default = "default_1692")] + #[serde(default = "default_1698")] pub skipped: Integer, - #[serde(default = "default_1693")] + #[serde(default = "default_1699")] pub refused: Integer, } @@ -36168,11 +36466,11 @@ pub struct MemoryImportResult { pub index: Integer, pub key: String, pub outcome: MemoryImportResultOutcome, - #[serde(default = "default_1694")] + #[serde(default = "default_1700")] pub reason: MemoryImportResultReason, - #[serde(default = "default_1695")] + #[serde(default = "default_1701")] pub held_by: String, - #[serde(default = "default_1696")] + #[serde(default = "default_1702")] pub note: MemoryImportResultNote, } @@ -36181,7 +36479,7 @@ pub struct MemoryImportResult { pub struct MemoryImportOutput { pub totals: MemoryImportTotals, pub results: Vec, - #[serde(default = "default_1697")] + #[serde(default = "default_1703")] pub dry_run: bool, } @@ -36374,9 +36672,9 @@ pub struct MemoryImportCuratedRow { pub section_heading: String, pub bytes_written: Integer, pub verdict: String, - #[serde(default = "default_1698")] + #[serde(default = "default_1704")] pub rejection_reason: String, - #[serde(default = "default_1699")] + #[serde(default = "default_1705")] pub pinned_blocker_id: Option, } @@ -36468,21 +36766,21 @@ impl MemoryImportCuratedInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryImportEvidenceOutput { - #[serde(default = "default_1700")] + #[serde(default = "default_1706")] pub chunks_written: Integer, - #[serde(default = "default_1701")] + #[serde(default = "default_1707")] pub links_written: Integer, - #[serde(default = "default_1702")] + #[serde(default = "default_1708")] pub digests_written: Integer, - #[serde(default = "default_1703")] + #[serde(default = "default_1709")] pub embedding_model: String, - #[serde(default = "default_1704")] + #[serde(default = "default_1710")] pub embedding_dim: Integer, - #[serde(default = "default_1705")] + #[serde(default = "default_1711")] pub edited: Vec, - #[serde(default = "default_1706")] + #[serde(default = "default_1712")] pub skipped: Integer, - #[serde(default = "default_1707")] + #[serde(default = "default_1713")] pub unchecked: Integer, } @@ -36819,7 +37117,7 @@ pub struct InspectRow { pub memory_key: String, pub memory_id: String, pub version: Integer, - #[serde(default = "default_1717")] + #[serde(default = "default_1723")] pub content_sha256: String, pub memory_type: String, pub status: String, @@ -36830,9 +37128,9 @@ pub struct InspectRow { pub actor: String, pub updated_at: String, pub sensitivity: String, - #[serde(default = "default_1718")] + #[serde(default = "default_1724")] pub versions: Integer, - #[serde(default = "default_1719")] + #[serde(default = "default_1725")] pub excerpt: String, } @@ -36840,27 +37138,27 @@ pub struct InspectRow { #[non_exhaustive] pub struct InspectView { pub definition: String, - #[serde(default = "default_1708")] + #[serde(default = "default_1714")] pub refs: Vec, - #[serde(default = "default_1709")] + #[serde(default = "default_1715")] pub live_rows: Integer, - #[serde(default = "default_1710")] + #[serde(default = "default_1716")] pub by_type: Vec, - #[serde(default = "default_1711")] + #[serde(default = "default_1717")] pub by_status: Vec, - #[serde(default = "default_1712")] + #[serde(default = "default_1718")] pub by_source_class: Vec, - #[serde(default = "default_1713")] + #[serde(default = "default_1719")] pub top_tags: Vec, - #[serde(default = "default_1714")] + #[serde(default = "default_1720")] pub categories: Vec, - #[serde(default = "default_1715")] + #[serde(default = "default_1721")] pub first_updated_at: Option, - #[serde(default = "default_1716")] + #[serde(default = "default_1722")] pub last_updated_at: Option, - #[serde(default = "default_1720")] + #[serde(default = "default_1726")] pub newest: Vec, - #[serde(default = "default_1721")] + #[serde(default = "default_1727")] pub complete: bool, } @@ -36876,32 +37174,32 @@ pub struct InspectCall { #[non_exhaustive] pub struct InspectActivity { pub window_seconds: Integer, - #[serde(default = "default_1722")] + #[serde(default = "default_1728")] pub calls: Vec, - #[serde(default = "default_1723")] + #[serde(default = "default_1729")] pub first_at: Option, - #[serde(default = "default_1724")] + #[serde(default = "default_1730")] pub last_at: Option, - #[serde(default = "default_1725")] + #[serde(default = "default_1731")] pub gap: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct InspectSettings { - #[serde(default = "default_1726")] + #[serde(default = "default_1732")] pub guide_revision: Integer, - #[serde(default = "default_1727")] + #[serde(default = "default_1733")] pub guide_summary: String, - #[serde(default = "default_1728")] + #[serde(default = "default_1734")] pub categories_registered: Integer, - #[serde(default = "default_1729")] + #[serde(default = "default_1735")] pub extraction_policy: Option, - #[serde(default = "default_1730")] + #[serde(default = "default_1736")] pub extraction_policy_unavailable: String, - #[serde(default = "default_1731")] + #[serde(default = "default_1737")] pub extraction_instructions: String, - #[serde(default = "default_1732")] + #[serde(default = "default_1738")] pub extraction_instructions_refs: Vec, } @@ -36917,7 +37215,7 @@ pub struct MemoryInspectOutput { pub others: InspectView, pub activity: InspectActivity, pub settings: InspectSettings, - #[serde(default = "default_1733")] + #[serde(default = "default_1739")] pub skipped: Vec, } @@ -37011,7 +37309,7 @@ pub struct MemoryKeyRef { #[non_exhaustive] pub struct MemoryKeysOutput { pub keys: Vec, - #[serde(default = "default_1734")] + #[serde(default = "default_1740")] pub truncated: bool, } @@ -37114,9 +37412,9 @@ pub struct LineageCandidate { pub decided_at: String, pub decided_by: String, pub match_confidence: LineageCandidateMatchConfidence, - #[serde(default = "default_1743")] + #[serde(default = "default_1749")] pub seeded_from_thread_id: String, - #[serde(default = "default_1744")] + #[serde(default = "default_1750")] pub seeded_from_msg_id: String, } @@ -37134,25 +37432,25 @@ pub struct LineageAuditEvent { pub struct MemoryLineageOutput { pub found: bool, pub memory_key: String, - #[serde(default = "default_1735")] + #[serde(default = "default_1741")] pub promotion_event: String, - #[serde(default = "default_1736")] + #[serde(default = "default_1742")] pub promoted_by: String, - #[serde(default = "default_1737")] + #[serde(default = "default_1743")] pub promoted_at: Option, - #[serde(default = "default_1738")] + #[serde(default = "default_1744")] pub rationale: String, - #[serde(default = "default_1739")] + #[serde(default = "default_1745")] pub source_trace: String, - #[serde(default = "default_1740")] + #[serde(default = "default_1746")] pub source_resource_id: String, - #[serde(default = "default_1741")] + #[serde(default = "default_1747")] pub mechanism: MemoryLineageOutputMechanism, - #[serde(default = "default_1742")] + #[serde(default = "default_1748")] pub supporters: Vec, - #[serde(default = "default_1745")] + #[serde(default = "default_1751")] pub candidate: Option, - #[serde(default = "default_1746")] + #[serde(default = "default_1752")] pub audit_chain: Vec, } @@ -37281,11 +37579,11 @@ pub struct MemoryLinkOutput { pub from_key: String, pub to_key: String, pub relation: String, - #[serde(default = "default_1747")] + #[serde(default = "default_1753")] pub confidence: f64, - #[serde(default = "default_1748")] + #[serde(default = "default_1754")] pub conflict_opened: bool, - #[serde(default = "default_1749")] + #[serde(default = "default_1755")] pub relation_defaulted: bool, } @@ -37599,17 +37897,17 @@ pub struct MemoryListEntry { pub struct MemoryListOutput { pub entries: Vec, pub truncated: bool, - #[serde(default = "default_1750")] + #[serde(default = "default_1756")] pub total: Integer, - #[serde(default = "default_1751")] + #[serde(default = "default_1757")] pub today: Integer, - #[serde(default = "default_1752")] + #[serde(default = "default_1758")] pub namespace_version: String, - #[serde(default = "default_1753")] + #[serde(default = "default_1759")] pub unchanged: bool, - #[serde(default = "default_1754")] + #[serde(default = "default_1760")] pub hidden: Integer, - #[serde(default = "default_1755")] + #[serde(default = "default_1761")] pub hidden_hint: String, } @@ -37995,19 +38293,19 @@ impl MemoryListInput { #[non_exhaustive] pub struct MemoryLockOutput { pub locked: bool, - #[serde(default = "default_1756")] + #[serde(default = "default_1762")] pub reason: String, - #[serde(default = "default_1757")] + #[serde(default = "default_1763")] pub memory_id: String, - #[serde(default = "default_1758")] + #[serde(default = "default_1764")] pub version: Option, - #[serde(default = "default_1759")] + #[serde(default = "default_1765")] pub lock_mode: String, - #[serde(default = "default_1760")] + #[serde(default = "default_1766")] pub lock_until: Option, - #[serde(default = "default_1761")] + #[serde(default = "default_1767")] pub locked_by: String, - #[serde(default = "default_1762")] + #[serde(default = "default_1768")] pub previous_mode: String, } @@ -38166,21 +38464,21 @@ pub struct MemoryMoveOutput { pub from_key: String, pub to_key: String, pub redirected: bool, - #[serde(default = "default_1763")] + #[serde(default = "default_1769")] pub memory_id: String, - #[serde(default = "default_1764")] + #[serde(default = "default_1770")] pub version: Integer, - #[serde(default = "default_1765")] + #[serde(default = "default_1771")] pub content_sha256: String, - #[serde(default = "default_1766")] + #[serde(default = "default_1772")] pub advisories: Vec, - #[serde(default = "default_1767")] + #[serde(default = "default_1773")] pub dry_run: bool, - #[serde(default = "default_1768")] + #[serde(default = "default_1774")] pub memory_type: String, - #[serde(default = "default_1769")] + #[serde(default = "default_1775")] pub value_preview: String, - #[serde(default = "default_1770")] + #[serde(default = "default_1776")] pub sensitivity: String, } @@ -38392,7 +38690,7 @@ impl MemoryMoveInput { pub struct MemoryOutcomeOutput { pub recorded: bool, pub evidence_count_after: Integer, - #[serde(default = "default_1771")] + #[serde(default = "default_1777")] pub quarantined: bool, } @@ -38635,13 +38933,13 @@ impl MemoryOutcomeRunInput { #[non_exhaustive] pub struct OutlineSession { pub session_id: String, - #[serde(default = "default_1773")] + #[serde(default = "default_1779")] pub date: String, - #[serde(default = "default_1774")] + #[serde(default = "default_1780")] pub headline: String, - #[serde(default = "default_1775")] + #[serde(default = "default_1781")] pub key_facts: Integer, - #[serde(default = "default_1776")] + #[serde(default = "default_1782")] pub rows: Integer, } @@ -38649,7 +38947,7 @@ pub struct OutlineSession { #[non_exhaustive] pub struct OutlineHub { pub entity: String, - #[serde(default = "default_1779")] + #[serde(default = "default_1785")] pub degree: Integer, } @@ -38657,28 +38955,28 @@ pub struct OutlineHub { #[non_exhaustive] pub struct OutlineCommunity { pub community_id: Integer, - #[serde(default = "default_1781")] + #[serde(default = "default_1787")] pub label: String, - #[serde(default = "default_1782")] + #[serde(default = "default_1788")] pub size: Integer, - #[serde(default = "default_1783")] + #[serde(default = "default_1789")] pub computed_at: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryOutlineOutput { - #[serde(default = "default_1772")] + #[serde(default = "default_1778")] pub rows_by_type: std::collections::HashMap, - #[serde(default = "default_1777")] + #[serde(default = "default_1783")] pub sessions: Vec, - #[serde(default = "default_1778")] + #[serde(default = "default_1784")] pub sessions_total: Integer, - #[serde(default = "default_1780")] + #[serde(default = "default_1786")] pub hubs: Vec, - #[serde(default = "default_1784")] + #[serde(default = "default_1790")] pub communities: Vec, - #[serde(default = "default_1785")] + #[serde(default = "default_1791")] pub profile_chars: Integer, } @@ -38830,7 +39128,7 @@ pub struct OwnerUsageRow { pub recalls: Integer, pub used: Integer, pub harm: Integer, - #[serde(default = "default_1786")] + #[serde(default = "default_1792")] pub last_recalled: Option, } @@ -39317,7 +39615,7 @@ pub struct MemoryPromoteOutput { pub shared_memory_key: String, pub promotion_event: String, pub reversible_until: String, - #[serde(default = "default_1787")] + #[serde(default = "default_1793")] pub ignored_args: Vec, } @@ -39486,18 +39784,18 @@ impl MemoryPromoteInput { pub struct MemoryProposalDecision { pub memory_key: String, pub decided: bool, - #[serde(default = "default_1789")] + #[serde(default = "default_1795")] pub status: String, - #[serde(default = "default_1790")] + #[serde(default = "default_1796")] pub reason: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryProposalDecideOutput { - #[serde(default = "default_1788")] + #[serde(default = "default_1794")] pub decided: Integer, - #[serde(default = "default_1791")] + #[serde(default = "default_1797")] pub results: Vec, } @@ -39598,33 +39896,33 @@ pub enum MemoryProposalReady { pub struct MemoryProposal { pub memory_key: String, pub memory_id: String, - #[serde(default = "default_1792")] + #[serde(default = "default_1798")] pub content_sha256: String, - #[serde(default = "default_1793")] + #[serde(default = "default_1799")] pub agent: String, - #[serde(default = "default_1794")] + #[serde(default = "default_1800")] pub memory_type: String, - #[serde(default = "default_1795")] + #[serde(default = "default_1801")] pub value_preview: String, - #[serde(default = "default_1796")] + #[serde(default = "default_1802")] pub sensitivity: String, - #[serde(default = "default_1797")] + #[serde(default = "default_1803")] pub tags: Vec, - #[serde(default = "default_1798")] + #[serde(default = "default_1804")] pub created_at: String, - #[serde(default = "default_1799")] + #[serde(default = "default_1805")] pub graded_passes: Integer, - #[serde(default = "default_1800")] + #[serde(default = "default_1806")] pub graded_fails: Integer, - #[serde(default = "default_1801")] + #[serde(default = "default_1807")] pub last_graded_at: String, - #[serde(default = "default_1802")] + #[serde(default = "default_1808")] pub used_count: Integer, - #[serde(default = "default_1803")] + #[serde(default = "default_1809")] pub harm_count: Integer, - #[serde(default = "default_1804")] + #[serde(default = "default_1810")] pub ready: MemoryProposalReady, - #[serde(default = "default_1805")] + #[serde(default = "default_1811")] pub conflict_with: Vec, } @@ -39640,24 +39938,24 @@ pub enum ProposalPolicyMode { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct ProposalPolicy { - #[serde(default = "default_1808")] + #[serde(default = "default_1814")] pub mode: ProposalPolicyMode, - #[serde(default = "default_1809")] + #[serde(default = "default_1815")] pub min_passes: Integer, - #[serde(default = "default_1810")] + #[serde(default = "default_1816")] pub max_fails: Integer, - #[serde(default = "default_1811")] + #[serde(default = "default_1817")] pub reject_after_fails: Integer, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryProposalsOutput { - #[serde(default = "default_1806")] + #[serde(default = "default_1812")] pub proposals: Vec, - #[serde(default = "default_1807")] + #[serde(default = "default_1813")] pub total: Integer, - #[serde(default = "default_1812")] + #[serde(default = "default_1818")] pub policy: ProposalPolicy, } @@ -39775,19 +40073,19 @@ impl MemoryProposalsInput { pub struct MemoryProvenanceLink { pub direction: String, pub memory_key: String, - #[serde(default = "default_1826")] + #[serde(default = "default_1832")] pub relation: String, - #[serde(default = "default_1827")] + #[serde(default = "default_1833")] pub label: String, - #[serde(default = "default_1828")] + #[serde(default = "default_1834")] pub explanation: String, - #[serde(default = "default_1829")] + #[serde(default = "default_1835")] pub evidence: Vec, - #[serde(default = "default_1830")] + #[serde(default = "default_1836")] pub confidence: f64, - #[serde(default = "default_1831")] + #[serde(default = "default_1837")] pub author: String, - #[serde(default = "default_1832")] + #[serde(default = "default_1838")] pub run_id: String, } @@ -39795,33 +40093,33 @@ pub struct MemoryProvenanceLink { #[non_exhaustive] pub struct MemoryProvenanceOutput { pub found: bool, - #[serde(default = "default_1813")] + #[serde(default = "default_1819")] pub source_trace: String, - #[serde(default = "default_1814")] + #[serde(default = "default_1820")] pub source_kind: String, - #[serde(default = "default_1815")] + #[serde(default = "default_1821")] pub actor: String, - #[serde(default = "default_1816")] + #[serde(default = "default_1822")] pub source_class: String, - #[serde(default = "default_1817")] + #[serde(default = "default_1823")] pub source_label: String, - #[serde(default = "default_1818")] + #[serde(default = "default_1824")] pub thread_id: String, - #[serde(default = "default_1819")] + #[serde(default = "default_1825")] pub thread_exists: bool, - #[serde(default = "default_1820")] + #[serde(default = "default_1826")] pub thread_title: String, - #[serde(default = "default_1821")] + #[serde(default = "default_1827")] pub agent: String, - #[serde(default = "default_1822")] + #[serde(default = "default_1828")] pub session_id: String, - #[serde(default = "default_1823")] + #[serde(default = "default_1829")] pub run_id: String, - #[serde(default = "default_1824")] + #[serde(default = "default_1830")] pub written_at: String, - #[serde(default = "default_1825")] + #[serde(default = "default_1831")] pub source_resource_id: String, - #[serde(default = "default_1833")] + #[serde(default = "default_1839")] pub links: Vec, } @@ -39916,17 +40214,17 @@ impl MemoryProvenanceInput { pub struct RecallTurn { pub evidence_id: String, pub session_id: String, - #[serde(default = "default_1834")] + #[serde(default = "default_1840")] pub role: String, - #[serde(default = "default_1835")] + #[serde(default = "default_1841")] pub actor: String, - #[serde(default = "default_1836")] + #[serde(default = "default_1842")] pub observed_at: String, - #[serde(default = "default_1837")] + #[serde(default = "default_1843")] pub content: String, - #[serde(default = "default_1838")] + #[serde(default = "default_1844")] pub truncated: bool, - #[serde(default = "default_1839")] + #[serde(default = "default_1845")] pub matched_tokens: Integer, } @@ -39943,21 +40241,21 @@ pub enum MemoryRecallOutputOrder { #[non_exhaustive] pub struct MemoryRecallOutput { pub turns: Vec, - #[serde(default = "default_1840")] + #[serde(default = "default_1846")] pub total_matched: Integer, - #[serde(default = "default_1841")] + #[serde(default = "default_1847")] pub returned: Integer, - #[serde(default = "default_1842")] + #[serde(default = "default_1848")] pub has_more: bool, - #[serde(default = "default_1843")] + #[serde(default = "default_1849")] pub next_cursor: String, - #[serde(default = "default_1844")] + #[serde(default = "default_1850")] pub next_offset: Integer, - #[serde(default = "default_1845")] + #[serde(default = "default_1851")] pub order: MemoryRecallOutputOrder, - #[serde(default = "default_1846")] + #[serde(default = "default_1852")] pub query_tokens: Vec, - #[serde(default = "default_1847")] + #[serde(default = "default_1853")] pub tokens_returned: Integer, } @@ -40239,19 +40537,19 @@ pub struct MemoryRecordConflictRow { pub schema_name: String, pub memory_key: String, pub field_name: String, - #[serde(default = "default_1848")] + #[serde(default = "default_1854")] pub prior_value: Value, - #[serde(default = "default_1849")] + #[serde(default = "default_1855")] pub incoming_value: Value, pub prior_record_id: String, pub incoming_record_id: String, - #[serde(default = "default_1850")] + #[serde(default = "default_1856")] pub prior_memory_id: String, - #[serde(default = "default_1851")] + #[serde(default = "default_1857")] pub incoming_memory_id: String, - #[serde(default = "default_1852")] + #[serde(default = "default_1858")] pub detected_at: Option, - #[serde(default = "default_1853")] + #[serde(default = "default_1859")] pub resolved_at: Option, } @@ -40259,7 +40557,7 @@ pub struct MemoryRecordConflictRow { #[non_exhaustive] pub struct MemoryRecordConflictsOutput { pub rows: Vec, - #[serde(default = "default_1854")] + #[serde(default = "default_1860")] pub truncated: bool, } @@ -40369,19 +40667,19 @@ pub enum MemoryRecordRowStatus { #[non_exhaustive] pub struct MemoryRecordRow { pub record_id: String, - #[serde(default = "default_1855")] + #[serde(default = "default_1861")] pub memory_key: String, - #[serde(default = "default_1856")] + #[serde(default = "default_1862")] pub memory_id: String, - #[serde(default = "default_1857")] + #[serde(default = "default_1863")] pub record: std::collections::HashMap, - #[serde(default = "default_1858")] + #[serde(default = "default_1864")] pub field_states: std::collections::HashMap, - #[serde(default = "default_1859")] + #[serde(default = "default_1865")] pub status: MemoryRecordRowStatus, - #[serde(default = "default_1860")] + #[serde(default = "default_1866")] pub valid_at: Option, - #[serde(default = "default_1861")] + #[serde(default = "default_1867")] pub valid_to: Option, } @@ -40448,7 +40746,7 @@ impl MemoryRecordHistoryInput { #[non_exhaustive] pub struct MemoryRecordQueryOutput { pub rows: Vec, - #[serde(default = "default_1862")] + #[serde(default = "default_1868")] pub truncated: bool, } @@ -40672,15 +40970,15 @@ pub enum MemoryRecordWriteOutputKeySource { pub struct MemoryRecordWriteOutput { pub record_id: String, pub field_count: Integer, - #[serde(default = "default_1863")] + #[serde(default = "default_1869")] pub memory_key: String, - #[serde(default = "default_1864")] + #[serde(default = "default_1870")] pub key_source: MemoryRecordWriteOutputKeySource, - #[serde(default = "default_1865")] + #[serde(default = "default_1871")] pub fold: std::collections::HashMap, - #[serde(default = "default_1866")] + #[serde(default = "default_1872")] pub superseded_record_id: String, - #[serde(default = "default_1867")] + #[serde(default = "default_1873")] pub conflicts: Integer, } @@ -40923,13 +41221,13 @@ impl MemoryRecordWriteInput { #[non_exhaustive] pub struct MemoryRedactOutput { pub redacted: bool, - #[serde(default = "default_1868")] + #[serde(default = "default_1874")] pub refused_head: bool, - #[serde(default = "default_1869")] + #[serde(default = "default_1875")] pub redacted_at: Option, - #[serde(default = "default_1870")] + #[serde(default = "default_1876")] pub cache_rows_deleted: Integer, - #[serde(default = "default_1871")] + #[serde(default = "default_1877")] pub precedent_rows_deleted: Integer, } @@ -41089,7 +41387,7 @@ impl MemoryReindexInput { #[non_exhaustive] pub struct MemoryRejectOutput { pub rejected: bool, - #[serde(default = "default_1872")] + #[serde(default = "default_1878")] pub rejected_at: Option, } @@ -41205,7 +41503,7 @@ pub struct MemoryRelatedHit { pub struct MemoryRelatedOutput { pub results: Vec, pub source_entities: Vec, - #[serde(default = "default_1873")] + #[serde(default = "default_1879")] pub reason: String, } @@ -41320,13 +41618,13 @@ impl MemoryRelatedInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryResolveOrphanDuplicatesOutput { - #[serde(default = "default_1874")] + #[serde(default = "default_1880")] pub candidates: Integer, - #[serde(default = "default_1875")] + #[serde(default = "default_1881")] pub reactivated: Integer, - #[serde(default = "default_1876")] + #[serde(default = "default_1882")] pub dry_run: bool, - #[serde(default = "default_1877")] + #[serde(default = "default_1883")] pub memory_ids: Vec, } @@ -41403,15 +41701,15 @@ impl MemoryResolveOrphanDuplicatesInput { #[non_exhaustive] pub struct MemoryRestoreOutput { pub restored: bool, - #[serde(default = "default_1878")] + #[serde(default = "default_1884")] pub memory_id: Option, - #[serde(default = "default_1879")] + #[serde(default = "default_1885")] pub version: Option, - #[serde(default = "default_1880")] + #[serde(default = "default_1886")] pub expired: bool, - #[serde(default = "default_1881")] + #[serde(default = "default_1887")] pub redacted: bool, - #[serde(default = "default_1882")] + #[serde(default = "default_1888")] pub from_status: String, } @@ -41531,13 +41829,13 @@ pub struct SearchTraceHit { pub content_excerpt: String, pub distance: f64, pub similarity: f64, - #[serde(default = "default_1883")] + #[serde(default = "default_1889")] pub entity_boost: f64, pub rank_score: f64, pub rank: Integer, - #[serde(default = "default_1884")] + #[serde(default = "default_1890")] pub source: String, - #[serde(default = "default_1885")] + #[serde(default = "default_1891")] pub parent_memory_key: String, } @@ -41547,11 +41845,11 @@ pub struct MemorySearchTraceOutput { pub results: Vec, pub embedding_model: String, pub entity_filter: Vec, - #[serde(default = "default_1886")] + #[serde(default = "default_1892")] pub query_spellings: std::collections::HashMap, - #[serde(default = "default_1887")] + #[serde(default = "default_1893")] pub query_spellings_skipped: bool, - #[serde(default = "default_1888")] + #[serde(default = "default_1894")] pub stale_dropped: Integer, } @@ -42754,7 +43052,7 @@ pub struct SearchTraceLogRow { pub embedding_model: String, pub latency_ms: Integer, pub run_id: String, - #[serde(default = "default_1889")] + #[serde(default = "default_1895")] pub operation: String, } @@ -42863,71 +43161,71 @@ pub struct RefusedFact { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemorySetFromMessagesOutput { - #[serde(default = "default_1890")] + #[serde(default = "default_1896")] pub written: Vec, - #[serde(default = "default_1891")] + #[serde(default = "default_1897")] pub refused: Vec, - #[serde(default = "default_1892")] + #[serde(default = "default_1898")] pub tokens_in: Integer, - #[serde(default = "default_1893")] + #[serde(default = "default_1899")] pub tokens_out: Integer, - #[serde(default = "default_1894")] + #[serde(default = "default_1900")] pub llm_provider: String, - #[serde(default = "default_1895")] + #[serde(default = "default_1901")] pub llm_model: String, - #[serde(default = "default_1896")] + #[serde(default = "default_1902")] pub segments: Integer, - #[serde(default = "default_1897")] + #[serde(default = "default_1903")] pub foresight: Integer, - #[serde(default = "default_1898")] + #[serde(default = "default_1904")] pub forgotten: Integer, - #[serde(default = "default_1899")] + #[serde(default = "default_1905")] pub forgotten_keys: Vec, - #[serde(default = "default_1900")] + #[serde(default = "default_1906")] pub forget_requests: Integer, - #[serde(default = "default_1901")] + #[serde(default = "default_1907")] pub about_other: Integer, - #[serde(default = "default_1902")] + #[serde(default = "default_1908")] pub premise_facts: Integer, - #[serde(default = "default_1903")] + #[serde(default = "default_1909")] pub learning_candidates: Integer, - #[serde(default = "default_1904")] + #[serde(default = "default_1910")] pub ignored_args: Vec, - #[serde(default = "default_1905")] + #[serde(default = "default_1911")] pub segmenter: String, - #[serde(default = "default_1906")] + #[serde(default = "default_1912")] pub cached_tokens_in: Integer, - #[serde(default = "default_1907")] + #[serde(default = "default_1913")] pub ontology_warnings: Vec, - #[serde(default = "default_1908")] + #[serde(default = "default_1914")] pub evidence_ids: Vec, - #[serde(default = "default_1909")] + #[serde(default = "default_1915")] pub belief_source_links: Integer, - #[serde(default = "default_1910")] + #[serde(default = "default_1916")] pub pipeline_errors: Vec, - #[serde(default = "default_1911")] + #[serde(default = "default_1917")] pub value_updates_linked: Integer, - #[serde(default = "default_1912")] + #[serde(default = "default_1918")] pub stubbed_fields: Vec, - #[serde(default = "default_1913")] + #[serde(default = "default_1919")] pub degraded: Vec, - #[serde(default = "default_1914")] + #[serde(default = "default_1920")] pub deferred: bool, - #[serde(default = "default_1915")] + #[serde(default = "default_1921")] pub queue_id: String, - #[serde(default = "default_1916")] + #[serde(default = "default_1922")] pub deferred_by: String, - #[serde(default = "default_1917")] + #[serde(default = "default_1923")] pub stage_ms: std::collections::HashMap, - #[serde(default = "default_1918")] + #[serde(default = "default_1924")] pub observation_date_source: String, - #[serde(default = "default_1919")] + #[serde(default = "default_1925")] pub under_operator_policy: bool, - #[serde(default = "default_1920")] + #[serde(default = "default_1926")] pub extract_prompt_keys: Vec, - #[serde(default = "default_1921")] + #[serde(default = "default_1927")] pub llm_cache_hits: Integer, - #[serde(default = "default_1922")] + #[serde(default = "default_1928")] pub llm_cache_misses: Integer, } @@ -43382,22 +43680,22 @@ pub enum StackEntrySection { #[non_exhaustive] pub struct StackEntry { pub section: StackEntrySection, - #[serde(default = "default_1923")] + #[serde(default = "default_1929")] pub memory_key: String, - #[serde(default = "default_1924")] + #[serde(default = "default_1930")] pub memory_type: String, - #[serde(default = "default_1925")] + #[serde(default = "default_1931")] pub value: String, pub tokens: Integer, - #[serde(default = "default_1926")] + #[serde(default = "default_1932")] pub pinned: bool, - #[serde(default = "default_1927")] + #[serde(default = "default_1933")] pub recall_count: Integer, - #[serde(default = "default_1928")] + #[serde(default = "default_1934")] pub last_recalled_at: Option, - #[serde(default = "default_1929")] + #[serde(default = "default_1935")] pub actor: String, - #[serde(default = "default_1930")] + #[serde(default = "default_1936")] pub namespace: String, } @@ -43582,14 +43880,14 @@ impl MemoryStackInput { pub struct MemoryStatus { pub memory_id: String, pub status: String, - #[serde(default = "default_1931")] + #[serde(default = "default_1937")] pub superseded_by: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryStatusesOutput { - #[serde(default = "default_1932")] + #[serde(default = "default_1938")] pub rows: Vec, } @@ -43638,23 +43936,23 @@ impl MemoryStatusesInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemorySweepExpiredOutput { - #[serde(default = "default_1933")] + #[serde(default = "default_1939")] pub scanned: Integer, - #[serde(default = "default_1934")] + #[serde(default = "default_1940")] pub tombstoned: Integer, - #[serde(default = "default_1935")] + #[serde(default = "default_1941")] pub demoted: Integer, - #[serde(default = "default_1936")] + #[serde(default = "default_1942")] pub anonymized: Integer, - #[serde(default = "default_1937")] + #[serde(default = "default_1943")] pub locked_skipped: Integer, - #[serde(default = "default_1938")] + #[serde(default = "default_1944")] pub moved_skipped: Integer, - #[serde(default = "default_1939")] + #[serde(default = "default_1945")] pub dry_run: bool, - #[serde(default = "default_1940")] + #[serde(default = "default_1946")] pub sample: Vec>, - #[serde(default = "default_1941")] + #[serde(default = "default_1947")] pub failures: Vec, } @@ -43731,10 +44029,10 @@ pub struct MemoryTimelineEntry { pub memory_key: String, pub memory_type: String, pub content_excerpt: String, - #[serde(default = "default_1942")] + #[serde(default = "default_1948")] pub valid_at: Option, pub created_at: String, - #[serde(default = "default_1943")] + #[serde(default = "default_1949")] pub namespace: String, } @@ -43742,7 +44040,7 @@ pub struct MemoryTimelineEntry { #[non_exhaustive] pub struct MemoryTimelineOutput { pub events: Vec, - #[serde(default = "default_1944")] + #[serde(default = "default_1950")] pub total_matching: Integer, } @@ -43934,9 +44232,9 @@ impl MemoryTimelineInput { pub struct MemoryTouchResult { pub memory_key: String, pub touched: bool, - #[serde(default = "default_1947")] + #[serde(default = "default_1953")] pub version: Option, - #[serde(default = "default_1948")] + #[serde(default = "default_1954")] pub expires_at: Option, } @@ -43944,13 +44242,13 @@ pub struct MemoryTouchResult { #[non_exhaustive] pub struct MemoryTouchOutput { pub touched: bool, - #[serde(default = "default_1945")] + #[serde(default = "default_1951")] pub version: Option, - #[serde(default = "default_1946")] + #[serde(default = "default_1952")] pub expires_at: Option, - #[serde(default = "default_1949")] + #[serde(default = "default_1955")] pub results: Vec, - #[serde(default = "default_1950")] + #[serde(default = "default_1956")] pub touched_count: Integer, } @@ -44130,15 +44428,15 @@ impl MemoryTouchInput { #[non_exhaustive] pub struct MemoryUnlockOutput { pub unlocked: bool, - #[serde(default = "default_1951")] + #[serde(default = "default_1957")] pub reason: String, - #[serde(default = "default_1952")] + #[serde(default = "default_1958")] pub memory_id: String, - #[serde(default = "default_1953")] + #[serde(default = "default_1959")] pub version: Option, - #[serde(default = "default_1954")] + #[serde(default = "default_1960")] pub previous_mode: String, - #[serde(default = "default_1955")] + #[serde(default = "default_1961")] pub unlocked_by: String, } @@ -44243,11 +44541,11 @@ impl MemoryUnlockInput { #[non_exhaustive] pub struct MemoryUnpinOutput { pub unpinned: bool, - #[serde(default = "default_1956")] + #[serde(default = "default_1962")] pub reason: String, - #[serde(default = "default_1957")] + #[serde(default = "default_1963")] pub memory_id: String, - #[serde(default = "default_1958")] + #[serde(default = "default_1964")] pub version: Option, } @@ -44341,15 +44639,15 @@ impl MemoryUnpinInput { #[non_exhaustive] pub struct MemoryUpdateCandidate { pub memory_id: String, - #[serde(default = "default_1964")] + #[serde(default = "default_1970")] pub agent: String, - #[serde(default = "default_1965")] + #[serde(default = "default_1971")] pub user_id: String, - #[serde(default = "default_1966")] + #[serde(default = "default_1972")] pub session_id: String, - #[serde(default = "default_1967")] + #[serde(default = "default_1973")] pub version: Integer, - #[serde(default = "default_1968")] + #[serde(default = "default_1974")] pub status: String, } @@ -44357,23 +44655,23 @@ pub struct MemoryUpdateCandidate { #[non_exhaustive] pub struct MemoryUpdateOutput { pub updated: bool, - #[serde(default = "default_1959")] + #[serde(default = "default_1965")] pub memory_id: String, - #[serde(default = "default_1960")] + #[serde(default = "default_1966")] pub memory_key: String, - #[serde(default = "default_1961")] + #[serde(default = "default_1967")] pub new_version: Integer, - #[serde(default = "default_1962")] + #[serde(default = "default_1968")] pub content_sha256: String, - #[serde(default = "default_1963")] - pub reason: String, #[serde(default = "default_1969")] + pub reason: String, + #[serde(default = "default_1975")] pub candidates: Vec, - #[serde(default = "default_1970")] + #[serde(default = "default_1976")] pub conflict_verdict: String, - #[serde(default = "default_1971")] + #[serde(default = "default_1977")] pub conflict_peers: Integer, - #[serde(default = "default_1972")] + #[serde(default = "default_1978")] pub duplicate_of: String, } @@ -44582,15 +44880,15 @@ impl MemoryUpdateInput { #[non_exhaustive] pub struct MemoryUpdateByIdOutput { pub updated: bool, - #[serde(default = "default_1973")] + #[serde(default = "default_1979")] pub new_version: Integer, - #[serde(default = "default_1974")] + #[serde(default = "default_1980")] pub content_sha256: String, - #[serde(default = "default_1975")] + #[serde(default = "default_1981")] pub conflict_verdict: String, - #[serde(default = "default_1976")] + #[serde(default = "default_1982")] pub conflict_peers: Integer, - #[serde(default = "default_1977")] + #[serde(default = "default_1983")] pub duplicate_of: String, } @@ -44718,23 +45016,23 @@ impl MemoryUpdateByIdInput { #[non_exhaustive] pub struct MemoryVerifyOutput { pub found: bool, - #[serde(default = "default_1978")] + #[serde(default = "default_1984")] pub changed: bool, - #[serde(default = "default_1979")] + #[serde(default = "default_1985")] pub memory_id: String, - #[serde(default = "default_1980")] + #[serde(default = "default_1986")] pub memory_key: String, - #[serde(default = "default_1981")] + #[serde(default = "default_1987")] pub namespace: String, - #[serde(default = "default_1982")] + #[serde(default = "default_1988")] pub verified_by: String, - #[serde(default = "default_1983")] + #[serde(default = "default_1989")] pub verified_at: Option, - #[serde(default = "default_1984")] + #[serde(default = "default_1990")] pub verification: String, - #[serde(default = "default_1985")] + #[serde(default = "default_1991")] pub version: Integer, - #[serde(default = "default_1986")] + #[serde(default = "default_1992")] pub content_sha256: String, } @@ -44939,13 +45237,13 @@ pub struct SchemaFieldOutput { #[serde(rename = "type")] pub r#type: String, pub required: bool, - #[serde(default = "default_1989")] + #[serde(default = "default_1995")] pub identity: bool, - #[serde(default = "default_1990")] + #[serde(default = "default_1996")] pub enum_values: Vec, - #[serde(default = "default_1991")] + #[serde(default = "default_1997")] pub constraints: std::collections::HashMap, - #[serde(default = "default_1992")] + #[serde(default = "default_1998")] pub description: String, } @@ -44954,11 +45252,11 @@ pub struct SchemaFieldOutput { pub struct MemorySchemaSummary { pub schema_id: String, pub name: String, - #[serde(default = "default_1987")] + #[serde(default = "default_1993")] pub description: String, - #[serde(default = "default_1988")] + #[serde(default = "default_1994")] pub status: String, - #[serde(default = "default_1993")] + #[serde(default = "default_1999")] pub fields: Vec, } @@ -45373,13 +45671,13 @@ impl MemorySchemaRegisterInput { #[non_exhaustive] pub struct MentorPlane { pub plane: String, - #[serde(default = "default_1995")] + #[serde(default = "default_2001")] pub calls: Integer, - #[serde(default = "default_1996")] + #[serde(default = "default_2002")] pub available: Option, - #[serde(default = "default_1997")] + #[serde(default = "default_2003")] pub when: String, - #[serde(default = "default_1998")] + #[serde(default = "default_2004")] pub mentored: bool, } @@ -45389,11 +45687,11 @@ pub struct MentorHint { pub code: String, pub severity: String, pub text: String, - #[serde(default = "default_2000")] + #[serde(default = "default_2006")] pub ops: Vec, - #[serde(default = "default_2001")] + #[serde(default = "default_2007")] pub evidence: std::collections::HashMap, - #[serde(default = "default_2002")] + #[serde(default = "default_2008")] pub plane: Option, } @@ -45401,9 +45699,9 @@ pub struct MentorHint { #[non_exhaustive] pub struct MentorAdoption { pub code: String, - #[serde(default = "default_2004")] + #[serde(default = "default_2010")] pub shown_sessions: Integer, - #[serde(default = "default_2005")] + #[serde(default = "default_2011")] pub followed_sessions: Integer, } @@ -45439,7 +45737,7 @@ pub enum UsageRungSource { #[non_exhaustive] pub struct UsageRung { pub rung: UsageRungRung, - #[serde(default = "default_2007")] + #[serde(default = "default_2013")] pub count: Option, pub source: UsageRungSource, pub meaning: String, @@ -45454,27 +45752,27 @@ pub struct MentorBriefOutput { pub window_seconds: Integer, pub computed_at: String, pub sessions: Integer, - #[serde(default = "default_1994")] + #[serde(default = "default_2000")] pub usage: std::collections::HashMap, - #[serde(default = "default_1999")] + #[serde(default = "default_2005")] pub planes: Vec, - #[serde(default = "default_2003")] + #[serde(default = "default_2009")] pub hints: Vec, - #[serde(default = "default_2006")] + #[serde(default = "default_2012")] pub adoption: Vec, - #[serde(default = "default_2008")] + #[serde(default = "default_2014")] pub usage_evidence: Vec, - #[serde(default = "default_2009")] + #[serde(default = "default_2015")] pub ledger_from: Option, - #[serde(default = "default_2010")] + #[serde(default = "default_2016")] pub ledger_retention_days: Option, - #[serde(default = "default_2011")] + #[serde(default = "default_2017")] pub agents: Vec, - #[serde(default = "default_2012")] + #[serde(default = "default_2018")] pub agent_defaulted: bool, - #[serde(default = "default_2013")] + #[serde(default = "default_2019")] pub skipped: Vec, - #[serde(default = "default_2014")] + #[serde(default = "default_2020")] pub healthy: bool, } @@ -45623,33 +45921,33 @@ impl MentorGuideInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct NamespaceAuditSummary { - #[serde(default = "default_2015")] + #[serde(default = "default_2021")] pub live_rows: Integer, - #[serde(default = "default_2016")] + #[serde(default = "default_2022")] pub live_bytes: Integer, - #[serde(default = "default_2017")] + #[serde(default = "default_2023")] pub excerpt_bytes: Integer, - #[serde(default = "default_2018")] + #[serde(default = "default_2024")] pub version_rows: Integer, - #[serde(default = "default_2019")] + #[serde(default = "default_2025")] pub version_bytes: Integer, - #[serde(default = "default_2020")] + #[serde(default = "default_2026")] pub unembedded_rows: Integer, - #[serde(default = "default_2021")] + #[serde(default = "default_2027")] pub gets: Integer, - #[serde(default = "default_2022")] + #[serde(default = "default_2028")] pub searches: Integer, - #[serde(default = "default_2023")] + #[serde(default = "default_2029")] pub sets: Integer, - #[serde(default = "default_2024")] + #[serde(default = "default_2030")] pub get_search_ratio: f64, - #[serde(default = "default_2025")] + #[serde(default = "default_2031")] pub inspector_calls: Integer, - #[serde(default = "default_2026")] + #[serde(default = "default_2032")] pub typed_gets: Integer, - #[serde(default = "default_2027")] + #[serde(default = "default_2033")] pub written_in_window: Integer, - #[serde(default = "default_2028")] + #[serde(default = "default_2034")] pub ledger_calls: Integer, } @@ -45681,25 +45979,25 @@ pub struct NamespaceAuditFinding { pub kind: NamespaceAuditFindingKind, pub rule_version: Integer, pub source_op: String, - #[serde(default = "default_2029")] + #[serde(default = "default_2035")] pub window_seconds: Option, - #[serde(default = "default_2030")] + #[serde(default = "default_2036")] pub population: Option, pub sample_limit: Integer, pub samples_complete: bool, - #[serde(default = "default_2031")] + #[serde(default = "default_2037")] pub evidence: Vec, - #[serde(default = "default_2032")] + #[serde(default = "default_2038")] pub exceptions: String, - #[serde(default = "default_2033")] + #[serde(default = "default_2039")] pub uncertainty: String, pub code: String, pub severity: NamespaceAuditFindingSeverity, pub count: Integer, pub share: f64, - #[serde(default = "default_2034")] + #[serde(default = "default_2040")] pub bytes: Integer, - #[serde(default = "default_2035")] + #[serde(default = "default_2041")] pub samples: Vec>, pub detail: String, pub remedy: String, @@ -45714,7 +46012,7 @@ pub struct NamespaceAuditOutput { pub window_seconds: Integer, pub summary: NamespaceAuditSummary, pub findings: Vec, - #[serde(default = "default_2036")] + #[serde(default = "default_2042")] pub skipped: Vec, pub coverage: ReportCoverage, pub healthy: bool, @@ -45805,29 +46103,29 @@ pub enum BrowseEntryMyStatus { #[non_exhaustive] pub struct BrowseEntry { pub namespace: String, - #[serde(default = "default_2037")] + #[serde(default = "default_2043")] pub kind: String, pub description: String, pub owner_email: String, pub member_count: Integer, - #[serde(default = "default_2038")] + #[serde(default = "default_2044")] pub requires_approval: bool, pub created_at: String, - #[serde(default = "default_2039")] + #[serde(default = "default_2045")] pub join_policy: String, - #[serde(default = "default_2040")] + #[serde(default = "default_2046")] pub visibility: String, - #[serde(default = "default_2041")] + #[serde(default = "default_2047")] pub my_status: BrowseEntryMyStatus, - #[serde(default = "default_2042")] + #[serde(default = "default_2048")] pub my_role: String, - #[serde(default = "default_2043")] + #[serde(default = "default_2049")] pub repo: String, - #[serde(default = "default_2044")] + #[serde(default = "default_2050")] pub branch: String, - #[serde(default = "default_2045")] + #[serde(default = "default_2051")] pub guide_revision: Integer, - #[serde(default = "default_2046")] + #[serde(default = "default_2052")] pub guide_summary: String, } @@ -45931,9 +46229,9 @@ pub enum NamespaceCancelRequestOutputClearedRole { pub struct NamespaceCancelRequestOutput { pub cancelled: bool, pub namespace: String, - #[serde(default = "default_2047")] + #[serde(default = "default_2053")] pub cleared_role: Option, - #[serde(default = "default_2048")] + #[serde(default = "default_2054")] pub cancelled_at: Option, } @@ -46005,7 +46303,7 @@ pub struct NamespaceDeleteOutput { pub deleted: bool, pub namespace: String, pub updated_at: String, - #[serde(default = "default_2049")] + #[serde(default = "default_2055")] pub sources_retired: Vec, } @@ -46074,67 +46372,67 @@ pub enum NamespaceGetOutputClassification { pub struct NamespaceGetOutput { pub found: bool, pub namespace: String, - #[serde(default = "default_2050")] + #[serde(default = "default_2056")] pub kind: Option, - #[serde(default = "default_2051")] + #[serde(default = "default_2057")] pub owner_email: Option, - #[serde(default = "default_2052")] + #[serde(default = "default_2058")] pub description: Option, - #[serde(default = "default_2053")] + #[serde(default = "default_2059")] pub tags: Option>, - #[serde(default = "default_2054")] + #[serde(default = "default_2060")] pub active: Option, - #[serde(default = "default_2055")] + #[serde(default = "default_2061")] pub conversation_logging_enabled: Option, - #[serde(default = "default_2056")] + #[serde(default = "default_2062")] pub capture_generation_io: Option, - #[serde(default = "default_2057")] + #[serde(default = "default_2063")] pub coverage_sweep: Option, - #[serde(default = "default_2058")] + #[serde(default = "default_2064")] pub consolidation_enabled: Option, - #[serde(default = "default_2059")] + #[serde(default = "default_2065")] pub daily_cost_cap_usd: Option, - #[serde(default = "default_2060")] + #[serde(default = "default_2066")] pub daily_user_cost_cap_usd: Option, - #[serde(default = "default_2061")] + #[serde(default = "default_2067")] pub budget_alert_inbox: Option, - #[serde(default = "default_2062")] + #[serde(default = "default_2068")] pub conflict_threshold: Option, - #[serde(default = "default_2063")] + #[serde(default = "default_2069")] pub retention_days: Option, - #[serde(default = "default_2064")] + #[serde(default = "default_2070")] pub warm_days: Option, - #[serde(default = "default_2065")] + #[serde(default = "default_2071")] pub visibility: Option, - #[serde(default = "default_2066")] + #[serde(default = "default_2072")] pub requires_approval: Option, - #[serde(default = "default_2067")] + #[serde(default = "default_2073")] pub join_policy: Option, - #[serde(default = "default_2068")] + #[serde(default = "default_2074")] pub effective_join_policy: Option, - #[serde(default = "default_2069")] + #[serde(default = "default_2075")] pub retrieval_defaults: Option>, - #[serde(default = "default_2070")] + #[serde(default = "default_2076")] pub rerank_endpoint: Option, - #[serde(default = "default_2071")] + #[serde(default = "default_2077")] pub classify_endpoint: Option, - #[serde(default = "default_2072")] + #[serde(default = "default_2078")] pub default_conflict_policy: Option, - #[serde(default = "default_2073")] + #[serde(default = "default_2079")] pub proposal_policy: Option, - #[serde(default = "default_2074")] + #[serde(default = "default_2080")] pub code_change_policy: Option, - #[serde(default = "default_2075")] + #[serde(default = "default_2081")] pub tag_registry: Option>>, - #[serde(default = "default_2076")] + #[serde(default = "default_2082")] pub classification: Option, - #[serde(default = "default_2077")] + #[serde(default = "default_2083")] pub guide_revision: Option, - #[serde(default = "default_2078")] + #[serde(default = "default_2084")] pub guide_summary: Option, - #[serde(default = "default_2079")] + #[serde(default = "default_2085")] pub created_at: Option, - #[serde(default = "default_2080")] + #[serde(default = "default_2086")] pub updated_at: Option, } @@ -46187,17 +46485,17 @@ impl NamespaceGetInput { #[non_exhaustive] pub struct NamespaceGuideGetOutput { pub found: bool, - #[serde(default = "default_2081")] + #[serde(default = "default_2087")] pub revision: Integer, - #[serde(default = "default_2082")] + #[serde(default = "default_2088")] pub content: String, - #[serde(default = "default_2083")] + #[serde(default = "default_2089")] pub summary: String, - #[serde(default = "default_2084")] + #[serde(default = "default_2090")] pub note: String, - #[serde(default = "default_2085")] + #[serde(default = "default_2091")] pub updated_by: String, - #[serde(default = "default_2086")] + #[serde(default = "default_2092")] pub updated_at: Option, } @@ -46334,17 +46632,17 @@ impl NamespaceGuideHistoryInput { #[non_exhaustive] pub struct NamespaceGuideSetOutputNamespaceGuideGetOutput { pub found: bool, - #[serde(default = "default_2088")] + #[serde(default = "default_2094")] pub revision: Integer, - #[serde(default = "default_2089")] + #[serde(default = "default_2095")] pub content: String, - #[serde(default = "default_2090")] + #[serde(default = "default_2096")] pub summary: String, - #[serde(default = "default_2091")] + #[serde(default = "default_2097")] pub note: String, - #[serde(default = "default_2092")] + #[serde(default = "default_2098")] pub updated_by: String, - #[serde(default = "default_2093")] + #[serde(default = "default_2099")] pub updated_at: Option, } @@ -46352,10 +46650,10 @@ pub struct NamespaceGuideSetOutputNamespaceGuideGetOutput { #[non_exhaustive] pub struct NamespaceGuideSetOutput { pub written: bool, - #[serde(default = "default_2087")] + #[serde(default = "default_2093")] pub conflict: bool, pub revision: Integer, - #[serde(default = "default_2094")] + #[serde(default = "default_2100")] pub current: Option, } @@ -46476,7 +46774,7 @@ pub struct InventorySection { #[serde(deserialize_with = "required_nullable")] pub latest_at: Option, pub complete: bool, - #[serde(default = "default_2095")] + #[serde(default = "default_2101")] pub reason: String, } @@ -46506,10 +46804,10 @@ pub struct InventoryPopulation { pub population: InventoryPopulationPopulation, #[serde(deserialize_with = "required_nullable")] pub total: Option, - #[serde(default = "default_2096")] + #[serde(default = "default_2102")] pub top: Vec, pub complete: bool, - #[serde(default = "default_2097")] + #[serde(default = "default_2103")] pub reason: String, } @@ -46675,11 +46973,11 @@ pub struct NamespaceJoinOutput { pub joined: bool, pub namespace: String, pub role: NamespaceJoinOutputRole, - #[serde(default = "default_2098")] + #[serde(default = "default_2104")] pub status: String, - #[serde(default = "default_2099")] + #[serde(default = "default_2105")] pub requested_role: Option, - #[serde(default = "default_2100")] + #[serde(default = "default_2106")] pub pending_admins: Vec, pub joined_at: String, } @@ -46771,7 +47069,7 @@ impl NamespaceJoinInput { pub struct NamespaceLeaveOutput { pub left: bool, pub namespace: String, - #[serde(default = "default_2101")] + #[serde(default = "default_2107")] pub left_at: Option, } @@ -46848,27 +47146,27 @@ pub enum NamespaceEntryVisibility { #[non_exhaustive] pub struct NamespaceEntry { pub namespace: String, - #[serde(default = "default_2102")] + #[serde(default = "default_2108")] pub kind: String, pub owner_email: String, pub description: String, pub tags: Vec, pub active: bool, - #[serde(default = "default_2103")] + #[serde(default = "default_2109")] pub consolidation_enabled: bool, - #[serde(default = "default_2104")] + #[serde(default = "default_2110")] pub daily_cost_cap_usd: f64, - #[serde(default = "default_2105")] + #[serde(default = "default_2111")] pub daily_user_cost_cap_usd: f64, - #[serde(default = "default_2106")] + #[serde(default = "default_2112")] pub budget_alert_inbox: String, - #[serde(default = "default_2107")] + #[serde(default = "default_2113")] pub conflict_threshold: Option, - #[serde(default = "default_2108")] + #[serde(default = "default_2114")] pub retention_days: Integer, - #[serde(default = "default_2109")] + #[serde(default = "default_2115")] pub warm_days: Integer, - #[serde(default = "default_2110")] + #[serde(default = "default_2116")] pub visibility: NamespaceEntryVisibility, pub created_at: String, pub updated_at: String, @@ -47023,27 +47321,27 @@ pub enum MineEntryVisibility { pub struct MineEntry { pub namespace: String, pub role: String, - #[serde(default = "default_2111")] + #[serde(default = "default_2117")] pub status: String, - #[serde(default = "default_2112")] + #[serde(default = "default_2118")] pub pending_role: Option, - #[serde(default = "default_2113")] + #[serde(default = "default_2119")] pub pending_since: Option, - #[serde(default = "default_2114")] + #[serde(default = "default_2120")] pub pending_admins: Vec, - #[serde(default = "default_2115")] + #[serde(default = "default_2121")] pub visibility: MineEntryVisibility, - #[serde(default = "default_2116")] + #[serde(default = "default_2122")] pub kind: String, - #[serde(default = "default_2117")] + #[serde(default = "default_2123")] pub title: String, - #[serde(default = "default_2118")] + #[serde(default = "default_2124")] pub description: String, - #[serde(default = "default_2119")] + #[serde(default = "default_2125")] pub joined_at: Option, - #[serde(default = "default_2120")] + #[serde(default = "default_2126")] pub is_new: bool, - #[serde(default = "default_2121")] + #[serde(default = "default_2127")] pub inherited: bool, } @@ -47109,7 +47407,7 @@ pub struct OntologyEntry { pub name: String, pub status: String, pub description: String, - #[serde(default = "default_2122")] + #[serde(default = "default_2128")] pub cardinality: String, pub created_by: String, pub updated_at: String, @@ -47302,7 +47600,7 @@ pub struct NamespaceRegisterOutput { pub registered: bool, pub namespace: String, pub updated_at: String, - #[serde(default = "default_2123")] + #[serde(default = "default_2129")] pub visibility: NamespaceRegisterOutputVisibility, } @@ -48382,7 +48680,7 @@ impl NamespaceRegisterOntologyInput { #[non_exhaustive] pub struct NamespaceRestoreOutput { pub restored: bool, - #[serde(default = "default_2124")] + #[serde(default = "default_2130")] pub publication_pending: bool, pub target_namespace: String, pub snapshot_id: String, @@ -49269,15 +49567,15 @@ pub struct NamespaceRollbackOutput { pub version_at: Integer, pub reinstate: Integer, pub remove: Integer, - #[serde(default = "default_2125")] + #[serde(default = "default_2131")] pub skipped_no_head: Integer, - #[serde(default = "default_2126")] + #[serde(default = "default_2132")] pub skipped_already_gone: Integer, - #[serde(default = "default_2127")] + #[serde(default = "default_2133")] pub truncated: bool, - #[serde(default = "default_2128")] + #[serde(default = "default_2134")] pub sample: Vec>, - #[serde(default = "default_2129")] + #[serde(default = "default_2135")] pub applied_at: Option, } @@ -49456,101 +49754,101 @@ pub struct NamespaceSnapshotOutputSnapshotMemoryRow { pub confidence: f64, pub source_trace: String, pub pinned: bool, - #[serde(default = "default_2130")] + #[serde(default = "default_2136")] pub expires_at: Option, - #[serde(default = "default_2131")] + #[serde(default = "default_2137")] pub entities: Vec, - #[serde(default = "default_2132")] + #[serde(default = "default_2138")] pub version: Integer, - #[serde(default = "default_2133")] + #[serde(default = "default_2139")] pub content_sha256: String, - #[serde(default = "default_2134")] + #[serde(default = "default_2140")] pub actor: String, - #[serde(default = "default_2135")] + #[serde(default = "default_2141")] pub source_class: String, - #[serde(default = "default_2136")] + #[serde(default = "default_2142")] pub source_resource_id: String, - #[serde(default = "default_2137")] + #[serde(default = "default_2143")] pub verified_by: String, - #[serde(default = "default_2138")] + #[serde(default = "default_2144")] pub verified_at: Option, - #[serde(default = "default_2139")] + #[serde(default = "default_2145")] pub verified_sha256: String, - #[serde(default = "default_2140")] + #[serde(default = "default_2146")] pub grounding: String, - #[serde(default = "default_2141")] + #[serde(default = "default_2147")] pub evidence: String, - #[serde(default = "default_2142")] + #[serde(default = "default_2148")] pub tags: Vec, - #[serde(default = "default_2143")] + #[serde(default = "default_2149")] pub valid_at: Option, - #[serde(default = "default_2144")] + #[serde(default = "default_2150")] pub valid_to: Option, - #[serde(default = "default_2145")] + #[serde(default = "default_2151")] pub created_at: Option, - #[serde(default = "default_2146")] + #[serde(default = "default_2152")] pub updated_at: Option, - #[serde(default = "default_2147")] + #[serde(default = "default_2153")] pub value_json: String, - #[serde(default = "default_2148")] + #[serde(default = "default_2154")] pub status: NamespaceSnapshotOutputSnapshotMemoryRowStatus, - #[serde(default = "default_2149")] + #[serde(default = "default_2155")] pub requires_review: Option, - #[serde(default = "default_2150")] + #[serde(default = "default_2156")] pub conflict_with: Vec, - #[serde(default = "default_2151")] + #[serde(default = "default_2157")] pub duplicate_of: String, - #[serde(default = "default_2152")] + #[serde(default = "default_2158")] pub evidence_count: Integer, - #[serde(default = "default_2153")] + #[serde(default = "default_2159")] pub recall_count: Integer, - #[serde(default = "default_2154")] + #[serde(default = "default_2160")] pub last_recalled_at: Option, - #[serde(default = "default_2155")] + #[serde(default = "default_2161")] pub cross_promoted_from_memory_id: String, - #[serde(default = "default_2156")] + #[serde(default = "default_2162")] pub cross_promoted_from_namespace: String, - #[serde(default = "default_2157")] + #[serde(default = "default_2163")] pub superseded_by: String, - #[serde(default = "default_2158")] + #[serde(default = "default_2164")] pub rejection_reason: String, - #[serde(default = "default_2159")] + #[serde(default = "default_2165")] pub temporal_anchor: Option, - #[serde(default = "default_2160")] + #[serde(default = "default_2166")] pub temporal_confidence: f64, - #[serde(default = "default_2161")] + #[serde(default = "default_2167")] pub invalid_at: Option, - #[serde(default = "default_2162")] + #[serde(default = "default_2168")] pub char_limit: Option, - #[serde(default = "default_2163")] + #[serde(default = "default_2169")] pub reinforcement_count: Integer, - #[serde(default = "default_2164")] + #[serde(default = "default_2170")] pub last_reinforced_at: Option, - #[serde(default = "default_2165")] + #[serde(default = "default_2171")] pub mentioned_at: Option, - #[serde(default = "default_2166")] + #[serde(default = "default_2172")] pub sensitivity: String, - #[serde(default = "default_2167")] + #[serde(default = "default_2173")] pub redacted_at: Option, - #[serde(default = "default_2168")] + #[serde(default = "default_2174")] pub redaction_reason: String, - #[serde(default = "default_2169")] + #[serde(default = "default_2175")] pub lock_mode: String, - #[serde(default = "default_2170")] + #[serde(default = "default_2176")] pub lock_reason: String, - #[serde(default = "default_2171")] + #[serde(default = "default_2177")] pub lock_until: Option, - #[serde(default = "default_2172")] + #[serde(default = "default_2178")] pub locked_by: String, - #[serde(default = "default_2173")] + #[serde(default = "default_2179")] pub locked_at: Option, - #[serde(default = "default_2174")] + #[serde(default = "default_2180")] pub on_expire: String, - #[serde(default = "default_2175")] + #[serde(default = "default_2181")] pub expire_reason: String, - #[serde(default = "default_2176")] + #[serde(default = "default_2182")] pub files: Vec, - #[serde(default = "default_2177")] + #[serde(default = "default_2183")] pub concepts: Vec, } @@ -49559,11 +49857,11 @@ pub struct NamespaceSnapshotOutputSnapshotMemoryRow { pub struct NamespaceSnapshotOutputSnapshotTypeRow { pub memory_type: String, pub retention_days: Integer, - #[serde(default = "default_2178")] + #[serde(default = "default_2184")] pub dedup_threshold: Option, - #[serde(default = "default_2179")] + #[serde(default = "default_2185")] pub hot_quota: Integer, - #[serde(default = "default_2180")] + #[serde(default = "default_2186")] pub conflict_policy: String, } @@ -49778,7 +50076,7 @@ pub struct TaxonomyCommunity { pub community_id: Integer, pub label: String, pub size: Integer, - #[serde(default = "default_2181")] + #[serde(default = "default_2187")] pub top_entities: Vec, } @@ -49789,9 +50087,9 @@ pub struct NamespaceTaxonomyOutput { pub entities: Vec, pub memory_count: Integer, pub memory_types: Vec, - #[serde(default = "default_2182")] + #[serde(default = "default_2188")] pub communities: Vec, - #[serde(default = "default_2183")] + #[serde(default = "default_2189")] pub communities_computed_at: String, } @@ -49891,15 +50189,15 @@ pub enum TuneProposalTarget { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct TuneEvidence { - #[serde(default = "default_2185")] + #[serde(default = "default_2191")] pub finding_codes: Vec, - #[serde(default = "default_2186")] + #[serde(default = "default_2192")] pub supporting_count: Integer, - #[serde(default = "default_2187")] + #[serde(default = "default_2193")] pub supporting: Vec, - #[serde(default = "default_2188")] + #[serde(default = "default_2194")] pub counter_count: Option, - #[serde(default = "default_2189")] + #[serde(default = "default_2195")] pub documents: Vec, } @@ -49925,10 +50223,10 @@ pub enum TuneApplyVia { #[non_exhaustive] pub struct TuneApply { pub op: String, - #[serde(default = "default_2193")] + #[serde(default = "default_2199")] pub via: TuneApplyVia, pub args: std::collections::HashMap, - #[serde(default = "default_2194")] + #[serde(default = "default_2200")] pub args_complete: bool, pub required_role: String, pub guard: String, @@ -49947,7 +50245,7 @@ pub struct ChunkStats { pub sections: Integer, pub sections_cut: Integer, pub max_input_tokens: Integer, - #[serde(default = "default_2196")] + #[serde(default = "default_2202")] pub over_input_limit: Option, } @@ -49967,25 +50265,25 @@ pub struct TuneProposal { pub title: String, pub rationale: String, pub current: String, - #[serde(default = "default_2184")] + #[serde(default = "default_2190")] pub current_revision: Option, pub proposed: String, pub evidence: TuneEvidence, - #[serde(default = "default_2190")] + #[serde(default = "default_2196")] pub affected_agents: Vec, - #[serde(default = "default_2191")] + #[serde(default = "default_2197")] pub affected_agents_total: Option, - #[serde(default = "default_2192")] + #[serde(default = "default_2198")] pub effect: TuneProposalEffect, pub historical: String, pub apply: TuneApply, - #[serde(default = "default_2195")] + #[serde(default = "default_2201")] pub apply_also: Vec, - #[serde(default = "default_2197")] + #[serde(default = "default_2203")] pub preview: Option, - #[serde(default = "default_2198")] + #[serde(default = "default_2204")] pub limits: String, - #[serde(default = "default_2199")] + #[serde(default = "default_2205")] pub refs: Vec, } @@ -49993,13 +50291,13 @@ pub struct TuneProposal { #[non_exhaustive] pub struct ChunkingSample { pub cap: Integer, - #[serde(default = "default_2205")] + #[serde(default = "default_2211")] pub population: Option, pub documents: Integer, pub unread: Integer, pub load_cap: Integer, pub embedder_model: String, - #[serde(default = "default_2206")] + #[serde(default = "default_2212")] pub input_token_limit: Option, pub current: ChunkStats, } @@ -50010,21 +50308,21 @@ pub struct NamespaceTuneOutput { pub org: String, pub namespace: String, pub computed_at: String, - #[serde(default = "default_2200")] + #[serde(default = "default_2206")] pub proposals: Vec, - #[serde(default = "default_2201")] + #[serde(default = "default_2207")] pub guide_revision: Option, - #[serde(default = "default_2202")] + #[serde(default = "default_2208")] pub categories_registered: Option, - #[serde(default = "default_2203")] + #[serde(default = "default_2209")] pub extraction_policy: Option, - #[serde(default = "default_2204")] + #[serde(default = "default_2210")] pub extraction_policy_unavailable: String, - #[serde(default = "default_2207")] + #[serde(default = "default_2213")] pub chunking: Option, - #[serde(default = "default_2208")] + #[serde(default = "default_2214")] pub skipped: Vec, - #[serde(default = "default_2209")] + #[serde(default = "default_2215")] pub model_used: bool, } @@ -50145,25 +50443,25 @@ pub struct NamespaceValidateFinding { pub kind: NamespaceValidateFindingKind, pub rule_version: Integer, pub source_op: String, - #[serde(default = "default_2210")] + #[serde(default = "default_2216")] pub window_seconds: Option, - #[serde(default = "default_2211")] + #[serde(default = "default_2217")] pub population: Option, pub sample_limit: Integer, pub samples_complete: bool, - #[serde(default = "default_2212")] + #[serde(default = "default_2218")] pub evidence: Vec, - #[serde(default = "default_2213")] + #[serde(default = "default_2219")] pub exceptions: String, - #[serde(default = "default_2214")] + #[serde(default = "default_2220")] pub uncertainty: String, pub check: String, pub severity: NamespaceValidateFindingSeverity, pub count: Integer, - #[serde(default = "default_2215")] + #[serde(default = "default_2221")] pub samples: Vec>, pub detail: String, - #[serde(default = "default_2216")] + #[serde(default = "default_2222")] pub totals: std::collections::HashMap, } @@ -50177,9 +50475,9 @@ pub struct NamespaceValidateOutput { pub warnings: Integer, pub infos: Integer, pub findings: Vec, - #[serde(default = "default_2217")] + #[serde(default = "default_2223")] pub skipped: Vec, - #[serde(default = "default_2218")] + #[serde(default = "default_2224")] pub keys_scoped: Integer, pub coverage: ReportCoverage, pub checked_at: String, @@ -50299,9 +50597,9 @@ impl NamespaceValidateInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct ObserveCrystallizeOutput { - #[serde(default = "default_2219")] + #[serde(default = "default_2225")] pub enqueued: Integer, - #[serde(default = "default_2220")] + #[serde(default = "default_2226")] pub session_id: String, } @@ -50398,23 +50696,23 @@ impl ObserveCrystallizeInput { #[non_exhaustive] pub struct ObserveRecordOutput { pub memory_key: String, - #[serde(default = "default_2221")] + #[serde(default = "default_2227")] pub memory_id: String, - #[serde(default = "default_2222")] + #[serde(default = "default_2228")] pub kind: String, - #[serde(default = "default_2223")] + #[serde(default = "default_2229")] pub tags: Vec, - #[serde(default = "default_2224")] + #[serde(default = "default_2230")] pub file_paths: Vec, - #[serde(default = "default_2225")] + #[serde(default = "default_2231")] pub content_sha256: String, - #[serde(default = "default_2226")] + #[serde(default = "default_2232")] pub tool_name: String, - #[serde(default = "default_2227")] + #[serde(default = "default_2233")] pub has_error: bool, - #[serde(default = "default_2228")] + #[serde(default = "default_2234")] pub narrative_chars: Integer, - #[serde(default = "default_2229")] + #[serde(default = "default_2235")] pub skipped_reason: String, } @@ -50645,7 +50943,7 @@ pub struct OpsIncident { pub subject: String, pub severity: OpsIncidentSeverity, pub detail: String, - #[serde(default = "default_2230")] + #[serde(default = "default_2236")] pub age_s: Option, } @@ -50664,7 +50962,7 @@ pub enum OpsIncidentsOutputRequests { #[non_exhaustive] pub struct OpsIncidentsOutput { pub status: OpsIncidentsOutputStatus, - #[serde(default = "default_2231")] + #[serde(default = "default_2237")] pub incidents: Vec, pub window_minutes: Integer, pub requests: OpsIncidentsOutputRequests, @@ -50708,26 +51006,26 @@ pub struct ProjectionFailureRow { pub failure_id: String, pub org: String, pub namespace: String, - #[serde(default = "default_2232")] + #[serde(default = "default_2238")] pub agent: String, pub projection: String, - #[serde(default = "default_2233")] + #[serde(default = "default_2239")] pub source_operation: String, - #[serde(default = "default_2234")] + #[serde(default = "default_2240")] pub source_resource_id: String, - #[serde(default = "default_2235")] + #[serde(default = "default_2241")] pub memory_keys: Vec, - #[serde(default = "default_2236")] + #[serde(default = "default_2242")] pub error_type: String, - #[serde(default = "default_2237")] + #[serde(default = "default_2243")] pub error_message: String, - #[serde(default = "default_2238")] + #[serde(default = "default_2244")] pub payload: std::collections::HashMap, - #[serde(default = "default_2239")] + #[serde(default = "default_2245")] pub status: String, - #[serde(default = "default_2240")] + #[serde(default = "default_2246")] pub created_at: Option, - #[serde(default = "default_2241")] + #[serde(default = "default_2247")] pub resolved_at: Option, } @@ -50881,22 +51179,22 @@ pub struct ProjectionFailureRetryRow { pub projection: String, pub retried: bool, pub resolved: bool, - #[serde(default = "default_2242")] + #[serde(default = "default_2248")] pub abandoned: bool, - #[serde(default = "default_2243")] + #[serde(default = "default_2249")] pub reason: String, - #[serde(default = "default_2244")] + #[serde(default = "default_2250")] pub error: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct ProjectionFailureRetryOutput { - #[serde(default = "default_2245")] + #[serde(default = "default_2251")] pub results: Vec, pub retried: Integer, pub resolved: Integer, - #[serde(default = "default_2246")] + #[serde(default = "default_2252")] pub abandoned: Integer, } @@ -50978,15 +51276,15 @@ impl ProjectionFailureRetryInput { pub struct OrgModelCallsOutput { pub org: String, pub enabled: bool, - #[serde(default = "default_2247")] + #[serde(default = "default_2253")] pub reason: String, - #[serde(default = "default_2248")] + #[serde(default = "default_2254")] pub updated_by: String, - #[serde(default = "default_2249")] + #[serde(default = "default_2255")] pub updated_at: Option, - #[serde(default = "default_2250")] + #[serde(default = "default_2256")] pub locked: bool, - #[serde(default = "default_2251")] + #[serde(default = "default_2257")] pub locked_by: String, } @@ -51325,7 +51623,7 @@ impl PolicyDecisionsInput { #[non_exhaustive] pub struct PolicyDeleteOutput { pub removed: bool, - #[serde(default = "default_2252")] + #[serde(default = "default_2258")] pub widening: bool, } @@ -51391,12 +51689,12 @@ pub struct PolicyRuleOut { pub condition: std::collections::HashMap, pub description: String, pub enabled: bool, - #[serde(default = "default_2253")] + #[serde(default = "default_2259")] pub mode: String, pub created_by: String, - #[serde(default = "default_2254")] + #[serde(default = "default_2260")] pub created_at: Option, - #[serde(default = "default_2255")] + #[serde(default = "default_2261")] pub updated_at: Option, } @@ -51468,9 +51766,9 @@ impl PolicyListInput { pub struct PolicySetOutput { pub rule: PolicyRuleOut, pub leaf_count: Integer, - #[serde(default = "default_2256")] + #[serde(default = "default_2262")] pub widening: bool, - #[serde(default = "default_2257")] + #[serde(default = "default_2263")] pub change: Vec, } @@ -51740,37 +52038,37 @@ pub struct ProcedureEvolveOutput { pub revision: Integer, pub changed: bool, pub template: bool, - #[serde(default = "default_2258")] + #[serde(default = "default_2264")] pub folded_runs: Integer, - #[serde(default = "default_2259")] + #[serde(default = "default_2265")] pub gate: ProcedureEvolveOutputGate, - #[serde(default = "default_2260")] + #[serde(default = "default_2266")] pub gate_mode: String, - #[serde(default = "default_2261")] + #[serde(default = "default_2267")] pub gate_llr: f64, - #[serde(default = "default_2262")] + #[serde(default = "default_2268")] pub gate_before: std::collections::HashMap, - #[serde(default = "default_2263")] + #[serde(default = "default_2269")] pub gate_after: std::collections::HashMap, - #[serde(default = "default_2264")] + #[serde(default = "default_2270")] pub gate_cost_before: std::collections::HashMap, - #[serde(default = "default_2265")] + #[serde(default = "default_2271")] pub gate_cost_after: std::collections::HashMap, - #[serde(default = "default_2266")] + #[serde(default = "default_2272")] pub gate_reason: String, - #[serde(default = "default_2267")] + #[serde(default = "default_2273")] pub dead_end_steps: Vec, - #[serde(default = "default_2268")] + #[serde(default = "default_2274")] pub fail_prone_steps: Vec, - #[serde(default = "default_2269")] + #[serde(default = "default_2275")] pub fail_prone_transitions: Vec, - #[serde(default = "default_2270")] + #[serde(default = "default_2276")] pub run_stats: std::collections::HashMap, - #[serde(default = "default_2271")] + #[serde(default = "default_2277")] pub strikes: Integer, - #[serde(default = "default_2272")] + #[serde(default = "default_2278")] pub quarantined: bool, - #[serde(default = "default_2273")] + #[serde(default = "default_2279")] pub retention: std::collections::HashMap, } @@ -51993,9 +52291,9 @@ pub struct ProcedureForkOutput { pub memory_key: String, pub version: Integer, pub name: String, - #[serde(default = "default_2274")] + #[serde(default = "default_2280")] pub steps: Vec, - #[serde(default = "default_2275")] + #[serde(default = "default_2281")] pub forked_from: std::collections::HashMap, } @@ -52255,32 +52553,32 @@ pub enum ProcedureLocateOutputStatus { #[non_exhaustive] pub struct ProcedureLocateOutput { pub memory_key: String, - #[serde(default = "default_2276")] + #[serde(default = "default_2282")] pub name: String, - #[serde(default = "default_2277")] + #[serde(default = "default_2283")] pub status: ProcedureLocateOutputStatus, pub matched: bool, - #[serde(default = "default_2278")] + #[serde(default = "default_2284")] pub active: Option>, - #[serde(default = "default_2279")] + #[serde(default = "default_2285")] pub hops: Vec>>, - #[serde(default = "default_2280")] + #[serde(default = "default_2286")] pub entry_nodes: Vec, - #[serde(default = "default_2281")] + #[serde(default = "default_2287")] pub dominant_next: Vec, - #[serde(default = "default_2282")] + #[serde(default = "default_2288")] pub revisits: std::collections::HashMap, - #[serde(default = "default_2283")] + #[serde(default = "default_2289")] pub looping: bool, - #[serde(default = "default_2284")] + #[serde(default = "default_2290")] pub exits: Vec, - #[serde(default = "default_2285")] + #[serde(default = "default_2291")] pub failure_notes: Vec>, - #[serde(default = "default_2286")] + #[serde(default = "default_2292")] pub rendered: String, - #[serde(default = "default_2287")] + #[serde(default = "default_2293")] pub run_stats: std::collections::HashMap, - #[serde(default = "default_2288")] + #[serde(default = "default_2294")] pub for_agent: std::collections::HashMap, } @@ -52435,43 +52733,43 @@ pub struct ProcedureMatch { pub name: String, pub situation: String, pub steps: Vec, - #[serde(default = "default_2289")] + #[serde(default = "default_2295")] pub tags: Vec, - #[serde(default = "default_2290")] + #[serde(default = "default_2296")] pub metadata: std::collections::HashMap, pub similarity: f64, pub memory_key: String, pub namespace: String, - #[serde(default = "default_2291")] + #[serde(default = "default_2297")] pub graph: Option>, - #[serde(default = "default_2292")] + #[serde(default = "default_2298")] pub template: bool, - #[serde(default = "default_2293")] + #[serde(default = "default_2299")] pub run_stats: std::collections::HashMap, - #[serde(default = "default_2294")] + #[serde(default = "default_2300")] pub status: ProcedureMatchStatus, - #[serde(default = "default_2295")] + #[serde(default = "default_2301")] pub quarantined: Option>, - #[serde(default = "default_2296")] + #[serde(default = "default_2302")] pub fail_prone_steps: Vec, - #[serde(default = "default_2297")] + #[serde(default = "default_2303")] pub revision: Integer, - #[serde(default = "default_2298")] + #[serde(default = "default_2304")] pub rejected_revisions: Vec>, - #[serde(default = "default_2299")] + #[serde(default = "default_2305")] pub tool_overlap: f64, - #[serde(default = "default_2300")] + #[serde(default = "default_2306")] pub score: f64, - #[serde(default = "default_2301")] + #[serde(default = "default_2307")] pub utility: f64, - #[serde(default = "default_2302")] + #[serde(default = "default_2308")] pub goal_similarity: Option, - #[serde(default = "default_2303")] + #[serde(default = "default_2309")] pub for_agent: std::collections::HashMap, - #[serde(default = "default_2304")] + #[serde(default = "default_2310")] pub run_stats_by_agent: std::collections::HashMap>, - #[serde(default = "default_2305")] + #[serde(default = "default_2311")] pub actor: String, } @@ -52479,11 +52777,11 @@ pub struct ProcedureMatch { #[non_exhaustive] pub struct ProcedureMatchOutput { pub matches: Vec, - #[serde(default = "default_2306")] + #[serde(default = "default_2312")] pub matched: Integer, - #[serde(default = "default_2307")] + #[serde(default = "default_2313")] pub procedure_key: String, - #[serde(default = "default_2308")] + #[serde(default = "default_2314")] pub score: f64, } @@ -52875,9 +53173,9 @@ pub struct ProcedureReviseOutput { pub revision: Integer, pub prior_revision: Integer, pub digest: String, - #[serde(default = "default_2309")] + #[serde(default = "default_2315")] pub steps: Vec, - #[serde(default = "default_2310")] + #[serde(default = "default_2316")] pub outcome: ProcedureReviseOutputOutcome, } @@ -52989,14 +53287,14 @@ pub struct ProfileActivityEntry { pub agent: String, pub last_activated_at: String, pub event_count: Integer, - #[serde(default = "default_2311")] + #[serde(default = "default_2317")] pub operations: Vec, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct ProfileActivityOutput { - #[serde(default = "default_2312")] + #[serde(default = "default_2318")] pub entries: Vec, } @@ -53104,17 +53402,17 @@ impl ProfileActivityInput { #[non_exhaustive] pub struct ProfileMutationOutput { pub version: Integer, - #[serde(default = "default_2313")] + #[serde(default = "default_2319")] pub memory_id: String, - #[serde(default = "default_2314")] + #[serde(default = "default_2320")] pub content_sha256: String, - #[serde(default = "default_2315")] + #[serde(default = "default_2321")] pub namespace: String, - #[serde(default = "default_2316")] + #[serde(default = "default_2322")] pub label: String, - #[serde(default = "default_2317")] + #[serde(default = "default_2323")] pub char_limit: Option, - #[serde(default = "default_2318")] + #[serde(default = "default_2324")] pub value_length: Integer, } @@ -53223,7 +53521,7 @@ pub struct ProfileRenderOutput { pub rendered: String, pub section_count: Integer, pub total_chars: Integer, - #[serde(default = "default_2319")] + #[serde(default = "default_2325")] pub labels: Vec, } @@ -53608,17 +53906,17 @@ pub enum ProfileStructuredOutputStatus { #[non_exhaustive] pub struct ProfileStructuredOutput { pub status: ProfileStructuredOutputStatus, - #[serde(default = "default_2320")] + #[serde(default = "default_2326")] pub profile: std::collections::HashMap, - #[serde(default = "default_2321")] + #[serde(default = "default_2327")] pub built_at: Option, - #[serde(default = "default_2322")] + #[serde(default = "default_2328")] pub memory_id: String, - #[serde(default = "default_2323")] + #[serde(default = "default_2329")] pub version: Integer, - #[serde(default = "default_2324")] + #[serde(default = "default_2330")] pub version_text: String, - #[serde(default = "default_2325")] + #[serde(default = "default_2331")] pub schema_sha256: String, } @@ -53735,13 +54033,13 @@ impl ProfileStructuredInput { #[non_exhaustive] pub struct ProfileSchemaOutput { pub found: bool, - #[serde(default = "default_2326")] + #[serde(default = "default_2332")] pub json_schema: std::collections::HashMap, - #[serde(default = "default_2327")] + #[serde(default = "default_2333")] pub schema_sha256: String, - #[serde(default = "default_2328")] + #[serde(default = "default_2334")] pub updated_by: String, - #[serde(default = "default_2329")] + #[serde(default = "default_2335")] pub updated_at: Option, } @@ -53894,10 +54192,10 @@ pub enum RunBeginOutputStatus { #[non_exhaustive] pub struct RunBeginOutput { pub run_id: String, - #[serde(default = "default_2330")] + #[serde(default = "default_2336")] pub status: RunBeginOutputStatus, pub started_at: String, - #[serde(default = "default_2331")] + #[serde(default = "default_2337")] pub next: String, } @@ -54105,31 +54403,31 @@ pub struct RunCompleteOutput { pub run_id: String, pub status: RunCompleteOutputStatus, pub duration_ms: Integer, - #[serde(default = "default_2332")] + #[serde(default = "default_2338")] pub used_applied: Integer, - #[serde(default = "default_2333")] + #[serde(default = "default_2339")] pub undelivered: Integer, - #[serde(default = "default_2334")] + #[serde(default = "default_2340")] pub evidence_applied: Integer, - #[serde(default = "default_2335")] + #[serde(default = "default_2341")] pub harm_applied: Integer, - #[serde(default = "default_2336")] + #[serde(default = "default_2342")] pub memories_written: Vec, - #[serde(default = "default_2337")] + #[serde(default = "default_2343")] pub recalled: Integer, - #[serde(default = "default_2338")] + #[serde(default = "default_2344")] pub observations: Integer, - #[serde(default = "default_2339")] + #[serde(default = "default_2345")] pub procedure_runs_recorded: Integer, - #[serde(default = "default_2340")] + #[serde(default = "default_2346")] pub reflection_key: String, - #[serde(default = "default_2341")] + #[serde(default = "default_2347")] pub retain: String, - #[serde(default = "default_2342")] + #[serde(default = "default_2348")] pub retained: Integer, - #[serde(default = "default_2343")] + #[serde(default = "default_2349")] pub demoted: Integer, - #[serde(default = "default_2344")] + #[serde(default = "default_2350")] pub expiring: Integer, } @@ -54670,25 +54968,25 @@ pub enum RunGetOutputOverBudgetItem { #[non_exhaustive] pub struct RunGetOutput { pub found: bool, - #[serde(default = "default_2345")] + #[serde(default = "default_2351")] pub run: Option, - #[serde(default = "default_2346")] + #[serde(default = "default_2352")] pub recalled: Integer, - #[serde(default = "default_2347")] + #[serde(default = "default_2353")] pub recalled_keys: Vec, - #[serde(default = "default_2348")] + #[serde(default = "default_2354")] pub memories_written: Vec, - #[serde(default = "default_2349")] + #[serde(default = "default_2355")] pub observations: Integer, - #[serde(default = "default_2350")] + #[serde(default = "default_2356")] pub turns: Integer, - #[serde(default = "default_2351")] + #[serde(default = "default_2357")] pub unpriced_turns: Integer, - #[serde(default = "default_2352")] + #[serde(default = "default_2358")] pub cost_usd: f64, - #[serde(default = "default_2353")] + #[serde(default = "default_2359")] pub elapsed_seconds: Integer, - #[serde(default = "default_2354")] + #[serde(default = "default_2360")] pub over_budget: Vec, } @@ -54755,17 +55053,17 @@ pub struct RunGradeProposal { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct RunGradeOutput { - #[serde(default = "default_2355")] + #[serde(default = "default_2361")] pub graded: Integer, - #[serde(default = "default_2356")] + #[serde(default = "default_2362")] pub run_ids: Vec, - #[serde(default = "default_2357")] + #[serde(default = "default_2363")] pub skipped_active: Integer, - #[serde(default = "default_2358")] + #[serde(default = "default_2364")] pub unchanged: Integer, - #[serde(default = "default_2359")] + #[serde(default = "default_2365")] pub memories_counted: Integer, - #[serde(default = "default_2360")] + #[serde(default = "default_2366")] pub proposals_decided: Vec, } @@ -54880,7 +55178,7 @@ impl RunGradeInput { #[non_exhaustive] pub struct RunListOutput { pub runs: Vec, - #[serde(default = "default_2361")] + #[serde(default = "default_2367")] pub total: Option, } @@ -55104,19 +55402,19 @@ impl RunListInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct RunRetractCreditOutput { - #[serde(default = "default_2362")] + #[serde(default = "default_2368")] pub run_id: String, - #[serde(default = "default_2363")] + #[serde(default = "default_2369")] pub used_retracted: Integer, - #[serde(default = "default_2364")] + #[serde(default = "default_2370")] pub evidence_retracted: Integer, - #[serde(default = "default_2365")] + #[serde(default = "default_2371")] pub harm_retracted: Integer, - #[serde(default = "default_2366")] + #[serde(default = "default_2372")] pub events_written: Integer, - #[serde(default = "default_2367")] + #[serde(default = "default_2373")] pub more: bool, - #[serde(default = "default_2368")] + #[serde(default = "default_2374")] pub dry_run: bool, } @@ -55273,39 +55571,39 @@ pub struct LiveSearchHit { pub title: String, pub url: String, pub provider: LiveSearchHitProvider, - #[serde(default = "default_2371")] + #[serde(default = "default_2377")] pub content: String, - #[serde(default = "default_2372")] + #[serde(default = "default_2378")] pub live: LiveSearchHitLive, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct LiveSearchResults { - #[serde(default = "default_2370")] + #[serde(default = "default_2376")] pub live: LiveSearchResultsLive, - #[serde(default = "default_2373")] + #[serde(default = "default_2379")] pub results: Vec, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct SearchOutput { - #[serde(default = "default_2369")] + #[serde(default = "default_2375")] pub tracker: Option>, - #[serde(default = "default_2374")] + #[serde(default = "default_2380")] pub live: Option, - #[serde(default = "default_2375")] + #[serde(default = "default_2381")] pub memory: std::collections::HashMap, - #[serde(default = "default_2376")] + #[serde(default = "default_2382")] pub knowledge: std::collections::HashMap, - #[serde(default = "default_2377")] + #[serde(default = "default_2383")] pub profile: std::collections::HashMap, - #[serde(default = "default_2378")] + #[serde(default = "default_2384")] pub conversations: std::collections::HashMap, - #[serde(default = "default_2379")] + #[serde(default = "default_2385")] pub withheld: Option>, - #[serde(default = "default_2380")] + #[serde(default = "default_2386")] pub namespaces_skipped: Vec, } @@ -55509,7 +55807,7 @@ impl SearchInput { pub struct SessionBriefDeleteOutput { pub deleted: bool, pub brief_key: String, - #[serde(default = "default_2381")] + #[serde(default = "default_2387")] pub revision: Integer, } @@ -55602,67 +55900,67 @@ impl SessionBriefDeleteInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct BriefDecision { - #[serde(default = "default_2390")] + #[serde(default = "default_2396")] pub what: String, - #[serde(default = "default_2391")] + #[serde(default = "default_2397")] pub why: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct BriefDeadEnd { - #[serde(default = "default_2393")] + #[serde(default = "default_2399")] pub tried: String, - #[serde(default = "default_2394")] + #[serde(default = "default_2400")] pub why_not: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct BriefDone { - #[serde(default = "default_2396")] + #[serde(default = "default_2402")] pub what: String, - #[serde(rename = "ref", default = "default_2397")] + #[serde(rename = "ref", default = "default_2403")] pub r#ref: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct BriefFile { - #[serde(default = "default_2401")] + #[serde(default = "default_2407")] pub path: String, - #[serde(default = "default_2402")] + #[serde(default = "default_2408")] pub role: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct BriefSections { - #[serde(default = "default_2387")] + #[serde(default = "default_2393")] pub goal: String, - #[serde(default = "default_2388")] + #[serde(default = "default_2394")] pub status: String, - #[serde(default = "default_2389")] + #[serde(default = "default_2395")] pub verification: String, - #[serde(default = "default_2392")] + #[serde(default = "default_2398")] pub decisions: Vec, - #[serde(default = "default_2395")] + #[serde(default = "default_2401")] pub dead_ends: Vec, - #[serde(default = "default_2398")] + #[serde(default = "default_2404")] pub done: Vec, - #[serde(default = "default_2399")] + #[serde(default = "default_2405")] pub open_questions: Vec, - #[serde(default = "default_2400")] + #[serde(default = "default_2406")] pub next_steps: Vec, - #[serde(default = "default_2403")] + #[serde(default = "default_2409")] pub files: Vec, - #[serde(default = "default_2404")] + #[serde(default = "default_2410")] pub constraints: Vec, - #[serde(default = "default_2405")] + #[serde(default = "default_2411")] pub pointers: Vec, - #[serde(default = "default_2406")] + #[serde(default = "default_2412")] pub client_summary: String, - #[serde(default = "default_2407")] + #[serde(default = "default_2413")] pub client_summary_at: String, } @@ -55670,45 +55968,45 @@ pub struct BriefSections { #[non_exhaustive] pub struct SessionBriefGetOutput { pub found: bool, - #[serde(default = "default_2382")] + #[serde(default = "default_2388")] pub brief_key: String, - #[serde(default = "default_2383")] + #[serde(default = "default_2389")] pub revision: Integer, - #[serde(default = "default_2384")] + #[serde(default = "default_2390")] pub snapshot_id: String, - #[serde(default = "default_2385")] + #[serde(default = "default_2391")] pub snapshot_key: String, - #[serde(default = "default_2386")] + #[serde(default = "default_2392")] pub rendered: String, - #[serde(default = "default_2408")] + #[serde(default = "default_2414")] pub sections: Option, - #[serde(default = "default_2409")] + #[serde(default = "default_2415")] pub project: String, - #[serde(default = "default_2410")] + #[serde(default = "default_2416")] pub branch: String, - #[serde(default = "default_2411")] + #[serde(default = "default_2417")] pub head_sha: String, - #[serde(default = "default_2412")] + #[serde(default = "default_2418")] pub author: String, - #[serde(default = "default_2413")] + #[serde(default = "default_2419")] pub trigger: String, - #[serde(default = "default_2414")] + #[serde(default = "default_2420")] pub actor: String, - #[serde(default = "default_2415")] + #[serde(default = "default_2421")] pub source_sessions: Vec, - #[serde(default = "default_2416")] + #[serde(default = "default_2422")] pub updated_at: Option, - #[serde(default = "default_2417")] + #[serde(default = "default_2423")] pub age_seconds: Integer, - #[serde(default = "default_2418")] + #[serde(default = "default_2424")] pub revisions: Integer, - #[serde(default = "default_2419")] + #[serde(default = "default_2425")] pub events_total: Integer, - #[serde(default = "default_2420")] + #[serde(default = "default_2426")] pub source_chars: Integer, - #[serde(default = "default_2421")] + #[serde(default = "default_2427")] pub brief_chars: Integer, - #[serde(default = "default_2422")] + #[serde(default = "default_2428")] pub deleted: bool, } @@ -55883,34 +56181,34 @@ impl SessionBriefGetInput { pub struct SessionBriefSummary { pub brief_key: String, pub revision: Integer, - #[serde(default = "default_2423")] + #[serde(default = "default_2429")] pub project: String, - #[serde(default = "default_2424")] + #[serde(default = "default_2430")] pub branch: String, - #[serde(default = "default_2425")] + #[serde(default = "default_2431")] pub agent: String, - #[serde(default = "default_2426")] + #[serde(default = "default_2432")] pub goal: String, - #[serde(default = "default_2427")] + #[serde(default = "default_2433")] pub status: String, - #[serde(default = "default_2428")] + #[serde(default = "default_2434")] pub author: String, - #[serde(default = "default_2429")] + #[serde(default = "default_2435")] pub actor: String, - #[serde(default = "default_2430")] + #[serde(default = "default_2436")] pub updated_at: Option, - #[serde(default = "default_2431")] + #[serde(default = "default_2437")] pub age_seconds: Integer, - #[serde(default = "default_2432")] + #[serde(default = "default_2438")] pub brief_chars: Integer, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct SessionBriefListOutput { - #[serde(default = "default_2433")] + #[serde(default = "default_2439")] pub briefs: Vec, - #[serde(default = "default_2434")] + #[serde(default = "default_2440")] pub rendered: String, } @@ -56050,25 +56348,25 @@ impl SessionBriefListInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct SessionBriefStats { - #[serde(default = "default_2438")] + #[serde(default = "default_2444")] pub events_in: Integer, - #[serde(default = "default_2439")] + #[serde(default = "default_2445")] pub windows: Integer, - #[serde(default = "default_2440")] + #[serde(default = "default_2446")] pub events_total: Integer, - #[serde(default = "default_2441")] + #[serde(default = "default_2447")] pub source_chars: Integer, - #[serde(default = "default_2442")] + #[serde(default = "default_2448")] pub brief_chars: Integer, - #[serde(default = "default_2443")] + #[serde(default = "default_2449")] pub compression_ratio: f64, - #[serde(default = "default_2444")] + #[serde(default = "default_2450")] pub dropped_ungrounded: Integer, - #[serde(default = "default_2445")] + #[serde(default = "default_2451")] pub tokens_in: Integer, - #[serde(default = "default_2446")] + #[serde(default = "default_2452")] pub tokens_out: Integer, - #[serde(default = "default_2447")] + #[serde(default = "default_2453")] pub llm_model: String, } @@ -56078,13 +56376,13 @@ pub struct SessionBriefSaveOutput { pub brief_key: String, pub revision: Integer, pub changed: bool, - #[serde(default = "default_2435")] + #[serde(default = "default_2441")] pub author: String, - #[serde(default = "default_2436")] + #[serde(default = "default_2442")] pub reason: String, - #[serde(default = "default_2437")] + #[serde(default = "default_2443")] pub rendered: String, - #[serde(default = "default_2448")] + #[serde(default = "default_2454")] pub stats: SessionBriefStats, } @@ -56829,39 +57127,39 @@ pub struct TaskPayload { pub priority: Integer, pub disclosure: TaskPayloadDisclosure, pub status: TaskPayloadStatus, - #[serde(default = "default_2449")] + #[serde(default = "default_2455")] pub reason: String, - #[serde(default = "default_2450")] + #[serde(default = "default_2456")] pub blocked_on: String, - #[serde(default = "default_2451")] + #[serde(default = "default_2457")] pub not_before: Option, - #[serde(default = "default_2452")] + #[serde(default = "default_2458")] pub resume_at: Option, - #[serde(default = "default_2453")] + #[serde(default = "default_2459")] pub deadline: Option, - #[serde(default = "default_2454")] + #[serde(default = "default_2460")] pub defer_count: Integer, pub title: String, - #[serde(default = "default_2455")] + #[serde(default = "default_2461")] pub brief: std::collections::HashMap, pub from_agent: String, - #[serde(default = "default_2456")] + #[serde(default = "default_2462")] pub from_subject: String, - #[serde(default = "default_2457")] + #[serde(default = "default_2463")] pub origin: String, - #[serde(default = "default_2458")] + #[serde(default = "default_2464")] pub parent_task_id: Option, - #[serde(default = "default_2459")] + #[serde(default = "default_2465")] pub owner: String, - #[serde(default = "default_2460")] + #[serde(default = "default_2466")] pub attempt: Integer, - #[serde(default = "default_2461")] + #[serde(default = "default_2467")] pub fence: Integer, - #[serde(default = "default_2462")] + #[serde(default = "default_2468")] pub lease_until: Option, - #[serde(default = "default_2463")] + #[serde(default = "default_2469")] pub outcome: std::collections::HashMap, - #[serde(default = "default_2464")] + #[serde(default = "default_2470")] pub last_actor: String, pub created_at: String, pub updated_at: String, @@ -56872,7 +57170,7 @@ pub struct TaskPayload { #[non_exhaustive] pub struct TaskOutput { pub task: TaskPayload, - #[serde(default = "default_2465")] + #[serde(default = "default_2471")] pub seq: Integer, } @@ -57273,10 +57571,10 @@ impl TaskCompleteInput { pub struct InboxCount { pub inbox: String, pub status: String, - #[serde(default = "default_2466")] + #[serde(default = "default_2472")] pub blocked_on: String, pub n: Integer, - #[serde(default = "default_2467")] + #[serde(default = "default_2473")] pub oldest: Option, } @@ -57363,7 +57661,7 @@ pub struct TaskCreateOutput { pub task: TaskPayload, pub created: bool, pub seq: Integer, - #[serde(default = "default_2468")] + #[serde(default = "default_2474")] pub next: String, } @@ -57702,7 +58000,7 @@ impl TaskFailInput { #[non_exhaustive] pub struct TaskGetOutput { pub found: bool, - #[serde(default = "default_2469")] + #[serde(default = "default_2475")] pub task: Option, } @@ -57836,23 +58134,23 @@ pub struct TaskEventPayload { pub task_id: String, pub inbox: String, pub event: String, - #[serde(default = "default_2470")] + #[serde(default = "default_2476")] pub from_status: String, - #[serde(default = "default_2471")] + #[serde(default = "default_2477")] pub to_status: String, - #[serde(default = "default_2472")] + #[serde(default = "default_2478")] pub actor: String, - #[serde(default = "default_2473")] + #[serde(default = "default_2479")] pub agent: String, - #[serde(default = "default_2474")] + #[serde(default = "default_2480")] pub fence: Integer, - #[serde(default = "default_2475")] + #[serde(default = "default_2481")] pub version: Integer, - #[serde(default = "default_2476")] + #[serde(default = "default_2482")] pub reason: String, - #[serde(default = "default_2477")] + #[serde(default = "default_2483")] pub patch: std::collections::HashMap, - #[serde(default = "default_2478")] + #[serde(default = "default_2484")] pub note: String, pub ts: String, } @@ -58192,7 +58490,7 @@ pub struct TaskPullOutput { pub tasks: Vec, pub waited_ms: Integer, pub backend: String, - #[serde(default = "default_2479")] + #[serde(default = "default_2485")] pub note: String, } @@ -58588,7 +58886,7 @@ impl TaskUnblockInput { pub struct TaskUpdateOutput { pub task: TaskPayload, pub seq: Integer, - #[serde(default = "default_2480")] + #[serde(default = "default_2486")] pub conflict: bool, } @@ -58951,19 +59249,19 @@ impl TaskReasonInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct TrackerAnswerOutput { - #[serde(default = "default_2481")] + #[serde(default = "default_2487")] pub intent: String, - #[serde(default = "default_2482")] + #[serde(default = "default_2488")] pub anchors: std::collections::HashMap, - #[serde(default = "default_2483")] + #[serde(default = "default_2489")] pub sections: Vec>, - #[serde(default = "default_2484")] + #[serde(default = "default_2490")] pub searched: Vec, - #[serde(default = "default_2485")] + #[serde(default = "default_2491")] pub lines: Vec, - #[serde(default = "default_2486")] + #[serde(default = "default_2492")] pub restricted: bool, - #[serde(default = "default_2487")] + #[serde(default = "default_2493")] pub verdict: String, } @@ -59059,17 +59357,17 @@ impl TrackerAnswerInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct TrackerBindingOutput { - #[serde(default = "default_2488")] + #[serde(default = "default_2494")] pub tracker_namespace: String, - #[serde(default = "default_2489")] + #[serde(default = "default_2495")] pub tracker_namespaces: Vec, - #[serde(default = "default_2490")] + #[serde(default = "default_2496")] pub restricted: bool, - #[serde(default = "default_2491")] + #[serde(default = "default_2497")] pub kind: String, - #[serde(default = "default_2492")] + #[serde(default = "default_2498")] pub authorized: bool, - #[serde(default = "default_2493")] + #[serde(default = "default_2499")] pub templates: Vec, } @@ -59122,13 +59420,13 @@ impl TrackerBindingInput { #[non_exhaustive] pub struct TrackerComponentOutput { pub component: String, - #[serde(default = "default_2494")] + #[serde(default = "default_2500")] pub risk: std::collections::HashMap, - #[serde(default = "default_2495")] + #[serde(default = "default_2501")] pub open_issues: Vec>, - #[serde(default = "default_2496")] + #[serde(default = "default_2502")] pub known: bool, - #[serde(default = "default_2497")] + #[serde(default = "default_2503")] pub tracker_unavailable: bool, } @@ -59189,9 +59487,9 @@ impl TrackerComponentInput { #[non_exhaustive] pub struct TrackerContractOutput { pub database: String, - #[serde(default = "default_2498")] + #[serde(default = "default_2504")] pub tables: Vec>, - #[serde(default = "default_2499")] + #[serde(default = "default_2505")] pub templates: std::collections::HashMap, } @@ -59244,66 +59542,66 @@ impl TrackerContractInput { #[non_exhaustive] pub struct TrackerLegStatus { pub name: String, - #[serde(default = "default_2510")] + #[serde(default = "default_2516")] pub status: String, - #[serde(default = "default_2511")] + #[serde(default = "default_2517")] pub reason: String, - #[serde(default = "default_2512")] + #[serde(default = "default_2518")] pub message: String, - #[serde(default = "default_2513")] + #[serde(default = "default_2519")] pub retried: bool, - #[serde(default = "default_2514")] + #[serde(default = "default_2520")] pub ms: Integer, - #[serde(default = "default_2515")] + #[serde(default = "default_2521")] pub cause: String, - #[serde(default = "default_2516")] + #[serde(default = "default_2522")] pub namespace: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct TrackerDuplicateCheckOutput { - #[serde(default = "default_2500")] + #[serde(default = "default_2506")] pub verdict: String, - #[serde(default = "default_2501")] + #[serde(default = "default_2507")] pub items: Vec>, - #[serde(default = "default_2502")] + #[serde(default = "default_2508")] pub undecided: bool, - #[serde(default = "default_2503")] + #[serde(default = "default_2509")] pub epistemic: String, - #[serde(default = "default_2504")] + #[serde(default = "default_2510")] pub thresholds: std::collections::HashMap, - #[serde(default = "default_2505")] + #[serde(default = "default_2511")] pub judge: std::collections::HashMap, - #[serde(default = "default_2506")] + #[serde(default = "default_2512")] pub fit_at: String, - #[serde(default = "default_2507")] + #[serde(default = "default_2513")] pub fit: std::collections::HashMap, - #[serde(default = "default_2508")] + #[serde(default = "default_2514")] pub query: std::collections::HashMap, - #[serde(default = "default_2509")] + #[serde(default = "default_2515")] pub legs: std::collections::HashMap, - #[serde(default = "default_2517")] + #[serde(default = "default_2523")] pub leg_status: Vec, - #[serde(default = "default_2518")] + #[serde(default = "default_2524")] pub tracker_unavailable: bool, - #[serde(default = "default_2519")] + #[serde(default = "default_2525")] pub namespaces: Vec, - #[serde(default = "default_2520")] + #[serde(default = "default_2526")] pub by_namespace: std::collections::HashMap>, - #[serde(default = "default_2521")] + #[serde(default = "default_2527")] pub closest: Vec>, - #[serde(default = "default_2522")] + #[serde(default = "default_2528")] pub needs: Vec>, - #[serde(default = "default_2523")] + #[serde(default = "default_2529")] pub closest_note: String, - #[serde(default = "default_2524")] + #[serde(default = "default_2530")] pub nearest: Vec>, - #[serde(default = "default_2525")] + #[serde(default = "default_2531")] pub rerank: std::collections::HashMap, - #[serde(default = "default_2526")] + #[serde(default = "default_2532")] pub answer: String, - #[serde(default = "default_2527")] + #[serde(default = "default_2533")] pub related_prs: Vec>, } @@ -59510,17 +59808,17 @@ impl TrackerDuplicateCheckInput { #[non_exhaustive] pub struct TrackerFlakyOutput { pub test_name: String, - #[serde(default = "default_2528")] + #[serde(default = "default_2534")] pub known_flaky: bool, - #[serde(default = "default_2529")] + #[serde(default = "default_2535")] pub open_issues: Integer, - #[serde(default = "default_2530")] + #[serde(default = "default_2536")] pub issues: Vec>, - #[serde(default = "default_2531")] + #[serde(default = "default_2537")] pub verdict: String, - #[serde(default = "default_2532")] + #[serde(default = "default_2538")] pub tracker_unavailable: bool, - #[serde(default = "default_2533")] + #[serde(default = "default_2539")] pub signal: Option>, } @@ -59603,9 +59901,9 @@ impl TrackerFlakyInput { #[non_exhaustive] pub struct TrackerItemOutput { pub items: Vec>, - #[serde(default = "default_2534")] + #[serde(default = "default_2540")] pub unknown: Vec, - #[serde(default = "default_2535")] + #[serde(default = "default_2541")] pub tracker_unavailable: bool, } @@ -59654,19 +59952,19 @@ impl TrackerItemInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct TrackerLinksOutput { - #[serde(default = "default_2536")] + #[serde(default = "default_2542")] pub subject: std::collections::HashMap, - #[serde(default = "default_2537")] + #[serde(default = "default_2543")] pub verdict: String, - #[serde(default = "default_2538")] + #[serde(default = "default_2544")] pub items: Vec>, - #[serde(default = "default_2539")] + #[serde(default = "default_2545")] pub epistemic: String, - #[serde(default = "default_2540")] + #[serde(default = "default_2546")] pub record: std::collections::HashMap, - #[serde(default = "default_2541")] + #[serde(default = "default_2547")] pub computed_at: String, - #[serde(default = "default_2542")] + #[serde(default = "default_2548")] pub tracker_unavailable: bool, } @@ -59764,11 +60062,11 @@ impl TrackerLinksInput { pub struct TrackerReleaseOutput { pub version: String, pub blockers: Vec>, - #[serde(default = "default_2543")] + #[serde(default = "default_2549")] pub active_blockers: Integer, - #[serde(default = "default_2544")] + #[serde(default = "default_2550")] pub health: std::collections::HashMap, - #[serde(default = "default_2545")] + #[serde(default = "default_2551")] pub tracker_unavailable: bool, } @@ -59817,17 +60115,17 @@ impl TrackerReleaseInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct TrackerSimilarOutput { - #[serde(default = "default_2546")] + #[serde(default = "default_2552")] pub items: Vec>, - #[serde(default = "default_2547")] + #[serde(default = "default_2553")] pub query: std::collections::HashMap, - #[serde(default = "default_2548")] + #[serde(default = "default_2554")] pub legs: std::collections::HashMap, - #[serde(default = "default_2549")] + #[serde(default = "default_2555")] pub epistemic: String, - #[serde(default = "default_2550")] + #[serde(default = "default_2556")] pub tracker_unavailable: bool, - #[serde(default = "default_2551")] + #[serde(default = "default_2557")] pub namespaces: Vec, } @@ -59948,19 +60246,19 @@ pub struct TrackerSourceAddOutput { pub name: String, pub host: String, pub database: String, - #[serde(default = "default_2552")] + #[serde(default = "default_2558")] pub namespaces: Vec>, - #[serde(default = "default_2553")] + #[serde(default = "default_2559")] pub contract: std::collections::HashMap, - #[serde(default = "default_2554")] + #[serde(default = "default_2560")] pub roles: Vec, - #[serde(default = "default_2555")] + #[serde(default = "default_2561")] pub my_role: String, - #[serde(default = "default_2556")] + #[serde(default = "default_2562")] pub dry_run: bool, - #[serde(default = "default_2557")] + #[serde(default = "default_2563")] pub written: bool, - #[serde(default = "default_2558")] + #[serde(default = "default_2564")] pub view_templates: std::collections::HashMap, } @@ -60123,13 +60421,13 @@ impl TrackerSourceAddInput { #[non_exhaustive] pub struct TrackerSourceCheckOutput { pub name: String, - #[serde(default = "default_2559")] + #[serde(default = "default_2565")] pub database: String, - #[serde(default = "default_2560")] + #[serde(default = "default_2566")] pub reachable: bool, - #[serde(default = "default_2561")] + #[serde(default = "default_2567")] pub contract: std::collections::HashMap, - #[serde(default = "default_2562")] + #[serde(default = "default_2568")] pub view_templates: std::collections::HashMap, } @@ -60169,11 +60467,11 @@ impl TrackerSourceCheckInput { pub struct TrackerSourceInspectOutput { pub host: String, pub database: String, - #[serde(default = "default_2563")] + #[serde(default = "default_2569")] pub tables: Vec>, - #[serde(default = "default_2564")] + #[serde(default = "default_2570")] pub roles: Vec, - #[serde(default = "default_2565")] + #[serde(default = "default_2571")] pub proposal: std::collections::HashMap, } @@ -60302,9 +60600,9 @@ impl TrackerSourceInspectInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct TrackerSourceListOutput { - #[serde(default = "default_2566")] + #[serde(default = "default_2572")] pub sources: Vec>, - #[serde(default = "default_2567")] + #[serde(default = "default_2573")] pub self_service: bool, } @@ -60357,9 +60655,9 @@ impl TrackerSourceListInput { #[non_exhaustive] pub struct TrackerSourceRemoveOutput { pub name: String, - #[serde(default = "default_2568")] + #[serde(default = "default_2574")] pub deactivated: bool, - #[serde(default = "default_2569")] + #[serde(default = "default_2575")] pub namespaces_retired: Vec, } @@ -60400,9 +60698,9 @@ impl TrackerSourceRemoveInput { #[non_exhaustive] pub struct TrackerSourceRotateOutput { pub name: String, - #[serde(default = "default_2570")] + #[serde(default = "default_2576")] pub contract: std::collections::HashMap, - #[serde(default = "default_2571")] + #[serde(default = "default_2577")] pub rotated_at: String, } @@ -60449,11 +60747,11 @@ impl TrackerSourceRotateInput { #[non_exhaustive] pub struct TrackerSourceSetMappingOutput { pub name: String, - #[serde(default = "default_2572")] + #[serde(default = "default_2578")] pub contract: std::collections::HashMap, - #[serde(default = "default_2573")] + #[serde(default = "default_2579")] pub dry_run: bool, - #[serde(default = "default_2574")] + #[serde(default = "default_2580")] pub written: bool, } @@ -60520,45 +60818,45 @@ impl TrackerSourceSetMappingInput { #[non_exhaustive] pub struct TrackerTestSignalOutput { pub test_name: String, - #[serde(default = "default_2575")] + #[serde(default = "default_2581")] pub verdict: String, - #[serde(default = "default_2576")] + #[serde(default = "default_2582")] pub why: Vec, - #[serde(default = "default_2577")] + #[serde(default = "default_2583")] pub lower_bound: f64, - #[serde(default = "default_2578")] + #[serde(default = "default_2584")] pub window_days: Integer, - #[serde(default = "default_2579")] + #[serde(default = "default_2585")] pub since: String, - #[serde(default = "default_2580")] + #[serde(default = "default_2586")] pub features: std::collections::HashMap, - #[serde(default = "default_2581")] + #[serde(default = "default_2587")] pub infra: std::collections::HashMap, - #[serde(default = "default_2582")] + #[serde(default = "default_2588")] pub churn: std::collections::HashMap, - #[serde(default = "default_2583")] + #[serde(default = "default_2589")] pub thresholds: std::collections::HashMap, - #[serde(default = "default_2584")] + #[serde(default = "default_2590")] pub source: String, - #[serde(default = "default_2585")] + #[serde(default = "default_2591")] pub timings_ms: std::collections::HashMap, - #[serde(default = "default_2586")] + #[serde(default = "default_2592")] pub tracker_unavailable: bool, - #[serde(default = "default_2587")] + #[serde(default = "default_2593")] pub rollup: std::collections::HashMap, - #[serde(default = "default_2588")] + #[serde(default = "default_2594")] pub streak: std::collections::HashMap, - #[serde(default = "default_2589")] + #[serde(default = "default_2595")] pub smells: std::collections::HashMap, - #[serde(default = "default_2590")] + #[serde(default = "default_2596")] pub prior: std::collections::HashMap, - #[serde(default = "default_2591")] + #[serde(default = "default_2597")] pub unavailable_reason: String, - #[serde(default = "default_2592")] + #[serde(default = "default_2598")] pub candidates: Vec>, - #[serde(default = "default_2593")] + #[serde(default = "default_2599")] pub candidate_matches: Integer, - #[serde(default = "default_2594")] + #[serde(default = "default_2600")] pub resolved_from: String, } @@ -60662,9 +60960,9 @@ impl TrackerTestSignalInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct UiVitalsOutput { - #[serde(default = "default_2595")] + #[serde(default = "default_2601")] pub recorded: bool, - #[serde(default = "default_2596")] + #[serde(default = "default_2602")] pub route: String, } @@ -60848,7 +61146,7 @@ pub struct WebhookDelivery { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct WebhookDeliveriesOutput { - #[serde(default = "default_2597")] + #[serde(default = "default_2603")] pub deliveries: Vec, } @@ -60970,14 +61268,14 @@ pub struct WebhookInfo { pub secret_ref: String, pub events: Vec, pub created_at: String, - #[serde(default = "default_2598")] + #[serde(default = "default_2604")] pub secret_present: bool, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct WebhookListOutput { - #[serde(default = "default_2599")] + #[serde(default = "default_2605")] pub webhooks: Vec, } @@ -61159,7 +61457,7 @@ pub struct WorkingMemoryMutationOutput { pub version: Integer, pub char_limit: Integer, pub value_length: Integer, - #[serde(default = "default_2600")] + #[serde(default = "default_2606")] pub fill_ratio: f64, } @@ -61383,15 +61681,15 @@ impl WorkingMemoryDeleteInput { pub struct WorkingMemoryGetOutput { pub found: bool, pub block_key: String, - #[serde(default = "default_2601")] + #[serde(default = "default_2607")] pub content: String, - #[serde(default = "default_2602")] + #[serde(default = "default_2608")] pub char_limit: Integer, - #[serde(default = "default_2603")] + #[serde(default = "default_2609")] pub version: Integer, - #[serde(default = "default_2604")] + #[serde(default = "default_2610")] pub updated_at: Option, - #[serde(default = "default_2605")] + #[serde(default = "default_2611")] pub fill_ratio: f64, } @@ -61502,7 +61800,7 @@ pub struct WorkingMemoryBlock { pub content: String, pub char_limit: Integer, pub version: Integer, - #[serde(default = "default_2606")] + #[serde(default = "default_2612")] pub updated_at: Option, } @@ -61510,7 +61808,7 @@ pub struct WorkingMemoryBlock { #[non_exhaustive] pub struct WorkingMemoryRenderOutput { pub rendered: String, - #[serde(default = "default_2607")] + #[serde(default = "default_2613")] pub blocks: Vec, pub block_count: Integer, pub total_chars: Integer, @@ -64984,4736 +65282,4754 @@ fn default_1033() -> Vec { fn default_1034() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1035() -> Option { +fn default_1035() -> String { + serde_json::from_str("\"\"").expect("schema default") +} +fn default_1036() -> String { + serde_json::from_str("\"\"").expect("schema default") +} +fn default_1037() -> String { + serde_json::from_str("\"\"").expect("schema default") +} +fn default_1038() -> String { + serde_json::from_str("\"\"").expect("schema default") +} +fn default_1039() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1036() -> bool { +fn default_1040() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1037() -> String { +fn default_1041() -> Option { + serde_json::from_str("null").expect("schema default") +} +fn default_1042() -> bool { + serde_json::from_str("false").expect("schema default") +} +fn default_1043() -> String { serde_json::from_str("\"memory\"").expect("schema default") } -fn default_1038() -> Option { +fn default_1044() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1039() -> Option { +fn default_1045() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1040() -> Option { +fn default_1046() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1041() -> String { +fn default_1047() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1042() -> String { +fn default_1048() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1043() -> String { +fn default_1049() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1044() -> HelpGetOutputAudience { +fn default_1050() -> HelpGetOutputAudience { serde_json::from_str("\"user\"").expect("schema default") } -fn default_1045() -> String { +fn default_1051() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1046() -> bool { +fn default_1052() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1047() -> Integer { +fn default_1053() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1048() -> String { +fn default_1054() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1049() -> Vec { +fn default_1055() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1050() -> String { +fn default_1056() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1051() -> Vec { +fn default_1057() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1052() -> Vec { +fn default_1058() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1053() -> String { +fn default_1059() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1054() -> String { +fn default_1060() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1055() -> String { +fn default_1061() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1056() -> Vec { +fn default_1062() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1057() -> String { +fn default_1063() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1058() -> bool { +fn default_1064() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1059() -> Vec { +fn default_1065() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1060() -> Vec { +fn default_1066() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1061() -> Option { +fn default_1067() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1062() -> bool { +fn default_1068() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1063() -> bool { +fn default_1069() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1064() -> Vec { +fn default_1070() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1065() -> Vec> { +fn default_1071() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_1066() -> Integer { +fn default_1072() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1067() -> bool { +fn default_1073() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1068() -> String { +fn default_1074() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1069() -> String { +fn default_1075() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1070() -> Integer { +fn default_1076() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1071() -> Integer { +fn default_1077() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1072() -> Vec { +fn default_1078() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1073() -> Integer { +fn default_1079() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1074() -> Vec { +fn default_1080() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1075() -> bool { +fn default_1081() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_1076() -> String { +fn default_1082() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1077() -> Option { +fn default_1083() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1078() -> Option { +fn default_1084() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1079() -> Vec> { +fn default_1085() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_1080() -> Option { +fn default_1086() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1081() -> bool { +fn default_1087() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1082() -> Integer { +fn default_1088() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1083() -> Vec { +fn default_1089() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1084() -> Vec> { +fn default_1090() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_1085() -> Vec { +fn default_1091() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1086() -> Vec> { +fn default_1092() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_1087() -> Vec { +fn default_1093() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1088() -> String { +fn default_1094() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1089() -> Vec { +fn default_1095() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1090() -> Vec { +fn default_1096() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1091() -> Option { +fn default_1097() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1092() -> Vec { +fn default_1098() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1093() -> Integer { +fn default_1099() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1094() -> Vec { +fn default_1100() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1095() -> String { +fn default_1101() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1096() -> Vec { +fn default_1102() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1097() -> Vec { +fn default_1103() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1098() -> Option { +fn default_1104() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1099() -> Option { +fn default_1105() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1100() -> bool { +fn default_1106() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1101() -> String { +fn default_1107() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1102() -> String { +fn default_1108() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1103() -> bool { +fn default_1109() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1104() -> String { +fn default_1110() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1105() -> String { +fn default_1111() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1106() -> String { +fn default_1112() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1107() -> Integer { +fn default_1113() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1108() -> String { +fn default_1114() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1109() -> String { +fn default_1115() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1110() -> String { +fn default_1116() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1111() -> Option> { +fn default_1117() -> Option> { serde_json::from_str("null").expect("schema default") } -fn default_1112() -> Vec { +fn default_1118() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1113() -> Integer { +fn default_1119() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1114() -> Integer { +fn default_1120() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1115() -> Option { +fn default_1121() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1116() -> String { +fn default_1122() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1117() -> String { +fn default_1123() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1118() -> bool { +fn default_1124() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1119() -> Option { +fn default_1125() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1120() -> Option { +fn default_1126() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1121() -> Option { +fn default_1127() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1122() -> Option { +fn default_1128() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1123() -> Option { +fn default_1129() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1124() -> Vec { +fn default_1130() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1125() -> Vec { +fn default_1131() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1126() -> Option { +fn default_1132() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1127() -> Option { +fn default_1133() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1128() -> Option { +fn default_1134() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1129() -> String { +fn default_1135() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1130() -> Option { +fn default_1136() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1131() -> Option { +fn default_1137() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1132() -> Option { +fn default_1138() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1133() -> Vec { +fn default_1139() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1134() -> Vec { +fn default_1140() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1135() -> Option { +fn default_1141() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1136() -> String { +fn default_1142() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1137() -> Option { +fn default_1143() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1138() -> Vec { +fn default_1144() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1139() -> Option { +fn default_1145() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1140() -> Option { +fn default_1146() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1141() -> Option { +fn default_1147() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1142() -> String { +fn default_1148() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1143() -> Option { +fn default_1149() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1144() -> Option { +fn default_1150() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1145() -> bool { +fn default_1151() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1146() -> bool { +fn default_1152() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1147() -> Option { +fn default_1153() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1148() -> Vec { +fn default_1154() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1149() -> bool { +fn default_1155() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1150() -> Option { +fn default_1156() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1151() -> Option { +fn default_1157() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1152() -> Vec { +fn default_1158() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1153() -> String { +fn default_1159() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1154() -> String { +fn default_1160() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1155() -> Vec { +fn default_1161() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1156() -> Integer { +fn default_1162() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1157() -> Vec { +fn default_1163() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1158() -> Vec { +fn default_1164() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1159() -> Vec { +fn default_1165() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1160() -> Vec { +fn default_1166() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1161() -> Vec { +fn default_1167() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1162() -> Option { +fn default_1168() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1163() -> Option { +fn default_1169() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1164() -> Option { +fn default_1170() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1165() -> Option { +fn default_1171() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1166() -> Option { +fn default_1172() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1167() -> Option { +fn default_1173() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1168() -> Option { +fn default_1174() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1169() -> Option { +fn default_1175() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1170() -> Option { +fn default_1176() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1171() -> Option { +fn default_1177() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1172() -> Option { +fn default_1178() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1173() -> Option { +fn default_1179() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1174() -> Vec { +fn default_1180() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1175() -> Option { +fn default_1181() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1176() -> Option { +fn default_1182() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1177() -> Vec { +fn default_1183() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1178() -> Option { +fn default_1184() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1179() -> Option { +fn default_1185() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1180() -> Vec { +fn default_1186() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1181() -> String { +fn default_1187() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1182() -> String { +fn default_1188() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1183() -> Vec { +fn default_1189() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1184() -> Vec { +fn default_1190() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1185() -> Integer { +fn default_1191() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1186() -> Vec { +fn default_1192() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1187() -> Vec { +fn default_1193() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1188() -> Vec { +fn default_1194() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1189() -> Vec { +fn default_1195() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1190() -> Option { +fn default_1196() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1191() -> String { +fn default_1197() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1192() -> bool { +fn default_1198() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1193() -> KnowledgeMoveResultReason { +fn default_1199() -> KnowledgeMoveResultReason { serde_json::from_str("\"\"").expect("schema default") } -fn default_1194() -> Vec { +fn default_1200() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1195() -> String { +fn default_1201() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1196() -> bool { +fn default_1202() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1197() -> Integer { +fn default_1203() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1198() -> Vec { +fn default_1204() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1199() -> Option { +fn default_1205() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1200() -> Vec { +fn default_1206() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1201() -> Vec> { +fn default_1207() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_1202() -> bool { +fn default_1208() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1203() -> Vec { +fn default_1209() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1204() -> bool { +fn default_1210() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1205() -> Vec { +fn default_1211() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1206() -> Vec> { +fn default_1212() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_1207() -> KnowledgeRestoreOutputReason { +fn default_1213() -> KnowledgeRestoreOutputReason { serde_json::from_str("\"\"").expect("schema default") } -fn default_1208() -> String { +fn default_1214() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1209() -> Option { +fn default_1215() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1210() -> Integer { +fn default_1216() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1211() -> KnowledgeRestoreOutputOriginal { +fn default_1217() -> KnowledgeRestoreOutputOriginal { serde_json::from_str("\"none\"").expect("schema default") } -fn default_1212() -> Option { +fn default_1218() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1213() -> Vec> { +fn default_1219() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_1214() -> Vec { +fn default_1220() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1215() -> std::collections::HashMap { +fn default_1221() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1216() -> Integer { +fn default_1222() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1217() -> bool { +fn default_1223() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1218() -> Vec { +fn default_1224() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1219() -> Integer { +fn default_1225() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1220() -> bool { +fn default_1226() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1221() -> KnowledgeSourceProbe { +fn default_1227() -> KnowledgeSourceProbe { serde_json::from_str( "{\"documents\":0,\"more\":false,\"sample\":[],\"checked\":0,\"sampled\":false}", ) .expect("schema default") } -fn default_1222() -> bool { +fn default_1228() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1223() -> bool { +fn default_1229() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_1224() -> Integer { +fn default_1230() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1225() -> bool { +fn default_1231() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1226() -> Vec { +fn default_1232() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1227() -> Integer { +fn default_1233() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1228() -> bool { +fn default_1234() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1229() -> String { +fn default_1235() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1230() -> String { +fn default_1236() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1231() -> String { +fn default_1237() -> String { serde_json::from_str("\"shared\"").expect("schema default") } -fn default_1232() -> bool { +fn default_1238() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1233() -> String { +fn default_1239() -> String { serde_json::from_str("\"namespace\"").expect("schema default") } -fn default_1234() -> std::collections::HashMap { +fn default_1240() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1235() -> String { +fn default_1241() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1236() -> Vec> { +fn default_1242() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_1237() -> Vec { +fn default_1243() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1238() -> std::collections::HashMap { +fn default_1244() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1239() -> String { +fn default_1245() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1240() -> String { +fn default_1246() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1241() -> String { +fn default_1247() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1242() -> String { +fn default_1248() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1243() -> String { +fn default_1249() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1244() -> Integer { +fn default_1250() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1245() -> Integer { +fn default_1251() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1246() -> Integer { +fn default_1252() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1247() -> Integer { +fn default_1253() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1248() -> std::collections::HashMap { +fn default_1254() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1249() -> Integer { +fn default_1255() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1250() -> String { +fn default_1256() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1251() -> Integer { +fn default_1257() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1252() -> String { +fn default_1258() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1253() -> Integer { +fn default_1259() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1254() -> Integer { +fn default_1260() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1255() -> Integer { +fn default_1261() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1256() -> String { +fn default_1262() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1257() -> KnowledgeSourceSync { +fn default_1263() -> KnowledgeSourceSync { serde_json::from_str("{\"requested_at\":\"\",\"last_synced_at\":\"\",\"status\":\"\",\"documents_seen\":0,\"changed\":0,\"removed\":0,\"unconverted\":0,\"unconverted_reasons\":{},\"skipped\":0,\"error\":\"\",\"pending_extract\":0,\"last_extracted_at\":\"\",\"extracted\":0,\"flagged_pinned\":0,\"unextracted\":0,\"extract_error\":\"\"}").expect("schema default") } -fn default_1258() -> String { +fn default_1264() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1259() -> String { +fn default_1265() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1260() -> String { +fn default_1266() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1261() -> Vec { +fn default_1267() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1262() -> String { +fn default_1268() -> String { serde_json::from_str("\"shared\"").expect("schema default") } -fn default_1263() -> bool { +fn default_1269() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1264() -> String { +fn default_1270() -> String { serde_json::from_str("\"namespace\"").expect("schema default") } -fn default_1265() -> std::collections::HashMap { +fn default_1271() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1266() -> String { +fn default_1272() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1267() -> Vec> { +fn default_1273() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_1268() -> Vec { +fn default_1274() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1269() -> std::collections::HashMap { +fn default_1275() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1270() -> String { +fn default_1276() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1271() -> String { +fn default_1277() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1272() -> KnowledgeSourceSync { +fn default_1278() -> KnowledgeSourceSync { serde_json::from_str("{\"requested_at\":\"\",\"last_synced_at\":\"\",\"status\":\"\",\"documents_seen\":0,\"changed\":0,\"removed\":0,\"unconverted\":0,\"unconverted_reasons\":{},\"skipped\":0,\"error\":\"\",\"pending_extract\":0,\"last_extracted_at\":\"\",\"extracted\":0,\"flagged_pinned\":0,\"unextracted\":0,\"extract_error\":\"\"}").expect("schema default") } -fn default_1273() -> Vec { +fn default_1279() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1274() -> bool { +fn default_1280() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1275() -> bool { +fn default_1281() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_1276() -> bool { +fn default_1282() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_1277() -> Option { +fn default_1283() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1278() -> String { +fn default_1284() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1279() -> std::collections::HashMap { +fn default_1285() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1280() -> String { +fn default_1286() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1281() -> Vec { +fn default_1287() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1282() -> bool { +fn default_1288() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1283() -> String { +fn default_1289() -> String { serde_json::from_str("\"disabled\"").expect("schema default") } -fn default_1284() -> String { +fn default_1290() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1285() -> String { +fn default_1291() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1286() -> String { +fn default_1292() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1287() -> String { +fn default_1293() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1288() -> String { +fn default_1294() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1289() -> String { +fn default_1295() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1290() -> Integer { +fn default_1296() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1291() -> f64 { +fn default_1297() -> f64 { serde_json::from_str("0").expect("schema default") } -fn default_1292() -> Integer { +fn default_1298() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1293() -> Option { +fn default_1299() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1294() -> KnowledgeSourceProbe { +fn default_1300() -> KnowledgeSourceProbe { serde_json::from_str( "{\"documents\":0,\"more\":false,\"sample\":[],\"checked\":0,\"sampled\":false}", ) .expect("schema default") } -fn default_1295() -> String { +fn default_1301() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1296() -> bool { +fn default_1302() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1297() -> Option { +fn default_1303() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1298() -> Vec> { +fn default_1304() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_1299() -> Vec { +fn default_1305() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1300() -> std::collections::HashMap { +fn default_1306() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1301() -> Vec> { +fn default_1307() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_1302() -> Vec> { +fn default_1308() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_1303() -> KnowledgeSourceProbe { +fn default_1309() -> KnowledgeSourceProbe { serde_json::from_str( "{\"documents\":0,\"more\":false,\"sample\":[],\"checked\":0,\"sampled\":false}", ) .expect("schema default") } -fn default_1304() -> Option { +fn default_1310() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1305() -> Option { +fn default_1311() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1306() -> Option { +fn default_1312() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1307() -> Option { +fn default_1313() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1308() -> Option { +fn default_1314() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1309() -> Option { +fn default_1315() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1310() -> Option { +fn default_1316() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1311() -> Option { +fn default_1317() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1312() -> Option { +fn default_1318() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1313() -> Option { +fn default_1319() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1314() -> Vec { +fn default_1320() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1315() -> Option { +fn default_1321() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1316() -> Option { +fn default_1322() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1317() -> Option { +fn default_1323() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1318() -> Vec { +fn default_1324() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1319() -> Integer { +fn default_1325() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1320() -> Option> { +fn default_1326() -> Option> { serde_json::from_str("null").expect("schema default") } -fn default_1321() -> Vec { +fn default_1327() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1322() -> Vec { +fn default_1328() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1323() -> bool { +fn default_1329() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1324() -> bool { +fn default_1330() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1325() -> String { +fn default_1331() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1326() -> String { +fn default_1332() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1327() -> Vec> { +fn default_1333() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_1328() -> bool { +fn default_1334() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1329() -> Vec { +fn default_1335() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1330() -> Vec { +fn default_1336() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1331() -> String { +fn default_1337() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1332() -> String { +fn default_1338() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1333() -> String { +fn default_1339() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1334() -> Vec { +fn default_1340() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1335() -> Integer { +fn default_1341() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1336() -> String { +fn default_1342() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1337() -> Integer { +fn default_1343() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1338() -> String { +fn default_1344() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1339() -> String { +fn default_1345() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1340() -> Integer { +fn default_1346() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1341() -> Integer { +fn default_1347() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1342() -> String { +fn default_1348() -> String { serde_json::from_str("\"memory_supporters\"").expect("schema default") } -fn default_1343() -> String { +fn default_1349() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1344() -> String { +fn default_1350() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1345() -> Option { +fn default_1351() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1346() -> String { +fn default_1352() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1347() -> String { +fn default_1353() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1348() -> bool { +fn default_1354() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1349() -> bool { +fn default_1355() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1350() -> String { +fn default_1356() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1351() -> std::collections::HashMap { +fn default_1357() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1352() -> Vec { +fn default_1358() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1353() -> String { +fn default_1359() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1354() -> String { +fn default_1360() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1355() -> String { +fn default_1361() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1356() -> Vec { +fn default_1362() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1357() -> String { +fn default_1363() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1358() -> String { +fn default_1364() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1359() -> Vec { +fn default_1365() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1360() -> Vec { +fn default_1366() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1361() -> Vec { +fn default_1367() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1362() -> Vec { +fn default_1368() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1363() -> Integer { +fn default_1369() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1364() -> Vec { +fn default_1370() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1365() -> Vec { +fn default_1371() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1366() -> Vec { +fn default_1372() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1367() -> Integer { +fn default_1373() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1368() -> Vec { +fn default_1374() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1369() -> std::collections::HashMap { +fn default_1375() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1370() -> std::collections::HashMap { +fn default_1376() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1371() -> Integer { +fn default_1377() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1372() -> Integer { +fn default_1378() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1373() -> Integer { +fn default_1379() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1374() -> Integer { +fn default_1380() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1375() -> Integer { +fn default_1381() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1376() -> Integer { +fn default_1382() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1377() -> bool { +fn default_1383() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1378() -> String { +fn default_1384() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1379() -> String { +fn default_1385() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1380() -> String { +fn default_1386() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1381() -> String { +fn default_1387() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1382() -> Option { +fn default_1388() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1383() -> String { +fn default_1389() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1384() -> Vec { +fn default_1390() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1385() -> String { +fn default_1391() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1386() -> MemoryAskOutputSource { +fn default_1392() -> MemoryAskOutputSource { serde_json::from_str("\"synthesized\"").expect("schema default") } -fn default_1387() -> bool { +fn default_1393() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1388() -> String { +fn default_1394() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1389() -> Vec { +fn default_1395() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1390() -> Vec { +fn default_1396() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1391() -> Vec { +fn default_1397() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1392() -> String { +fn default_1398() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1393() -> String { +fn default_1399() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1394() -> MemoryAskOutputRouteTier { +fn default_1400() -> MemoryAskOutputRouteTier { serde_json::from_str("\"\"").expect("schema default") } -fn default_1395() -> String { +fn default_1401() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1396() -> Integer { +fn default_1402() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1397() -> Integer { +fn default_1403() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1398() -> bool { +fn default_1404() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1399() -> f64 { +fn default_1405() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_1400() -> Option { +fn default_1406() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1401() -> Option { +fn default_1407() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1402() -> bool { +fn default_1408() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1403() -> String { +fn default_1409() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1404() -> Integer { +fn default_1410() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1405() -> Integer { +fn default_1411() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1406() -> Integer { +fn default_1412() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1407() -> Integer { +fn default_1413() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1408() -> String { +fn default_1414() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1409() -> Vec { +fn default_1415() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1410() -> Integer { +fn default_1416() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1411() -> MemoryAskOutputConsistency { +fn default_1417() -> MemoryAskOutputConsistency { serde_json::from_str("\"\"").expect("schema default") } -fn default_1412() -> f64 { +fn default_1418() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_1413() -> String { +fn default_1419() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1414() -> Integer { +fn default_1420() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1415() -> Integer { +fn default_1421() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1416() -> String { +fn default_1422() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1417() -> String { +fn default_1423() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1418() -> String { +fn default_1424() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1419() -> String { +fn default_1425() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1420() -> MemoryAskOutputDepth { +fn default_1426() -> MemoryAskOutputDepth { serde_json::from_str("\"\"").expect("schema default") } -fn default_1421() -> bool { +fn default_1427() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1422() -> Vec { +fn default_1428() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1423() -> Integer { +fn default_1429() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1424() -> Integer { +fn default_1430() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1425() -> Integer { +fn default_1431() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1426() -> Vec { +fn default_1432() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1427() -> Integer { +fn default_1433() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1428() -> Integer { +fn default_1434() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1429() -> Integer { +fn default_1435() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1430() -> MemoryAskOutputGrounding { +fn default_1436() -> MemoryAskOutputGrounding { serde_json::from_str("\"\"").expect("schema default") } -fn default_1431() -> String { +fn default_1437() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1432() -> Vec { +fn default_1438() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1433() -> Integer { +fn default_1439() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1434() -> Integer { +fn default_1440() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1435() -> Integer { +fn default_1441() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1436() -> Integer { +fn default_1442() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1437() -> std::collections::HashMap { +fn default_1443() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1438() -> MemoryAskOutputDeepSelector { +fn default_1444() -> MemoryAskOutputDeepSelector { serde_json::from_str("\"\"").expect("schema default") } -fn default_1439() -> MemoryAskOutputDeepFirst { +fn default_1445() -> MemoryAskOutputDeepFirst { serde_json::from_str("\"\"").expect("schema default") } -fn default_1440() -> Integer { +fn default_1446() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1441() -> Integer { +fn default_1447() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1442() -> Integer { +fn default_1448() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1443() -> Integer { +fn default_1449() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1444() -> f64 { +fn default_1450() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_1445() -> Integer { +fn default_1451() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1446() -> Integer { +fn default_1452() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1447() -> Integer { +fn default_1453() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1448() -> Integer { +fn default_1454() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1449() -> Integer { +fn default_1455() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1450() -> bool { +fn default_1456() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1451() -> String { +fn default_1457() -> String { serde_json::from_str("\"-\"").expect("schema default") } -fn default_1452() -> String { +fn default_1458() -> String { serde_json::from_str("\"-\"").expect("schema default") } -fn default_1453() -> String { +fn default_1459() -> String { serde_json::from_str("\"-\"").expect("schema default") } -fn default_1454() -> String { +fn default_1460() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1455() -> String { +fn default_1461() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1456() -> String { +fn default_1462() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1457() -> bool { +fn default_1463() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1458() -> String { +fn default_1464() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1459() -> Option { +fn default_1465() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1460() -> String { +fn default_1466() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1461() -> String { +fn default_1467() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1462() -> Vec { +fn default_1468() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1463() -> Option { +fn default_1469() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1464() -> bool { +fn default_1470() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1465() -> String { +fn default_1471() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1466() -> String { +fn default_1472() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1467() -> Vec { +fn default_1473() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1468() -> String { +fn default_1474() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1469() -> Vec { +fn default_1475() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1470() -> String { +fn default_1476() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1471() -> String { +fn default_1477() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1472() -> Vec { +fn default_1478() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1473() -> Vec { +fn default_1479() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1474() -> Integer { +fn default_1480() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1475() -> Vec { +fn default_1481() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1476() -> Vec { +fn default_1482() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1477() -> String { +fn default_1483() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1478() -> String { +fn default_1484() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1479() -> bool { +fn default_1485() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1480() -> String { +fn default_1486() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1481() -> String { +fn default_1487() -> String { serde_json::from_str("\"fact\"").expect("schema default") } -fn default_1482() -> String { +fn default_1488() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1483() -> bool { +fn default_1489() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1484() -> String { +fn default_1490() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1485() -> String { +fn default_1491() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1486() -> String { +fn default_1492() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1487() -> Vec { +fn default_1493() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1488() -> Vec { +fn default_1494() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1489() -> Vec { +fn default_1495() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1490() -> std::collections::HashMap { +fn default_1496() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1491() -> Vec { +fn default_1497() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1492() -> Integer { +fn default_1498() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1493() -> Vec { +fn default_1499() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1494() -> Integer { +fn default_1500() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1495() -> Integer { +fn default_1501() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1496() -> Integer { +fn default_1502() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1497() -> Integer { +fn default_1503() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1498() -> Integer { +fn default_1504() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1499() -> Integer { +fn default_1505() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1500() -> Integer { +fn default_1506() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1501() -> String { +fn default_1507() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1502() -> String { +fn default_1508() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1503() -> String { +fn default_1509() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1504() -> String { +fn default_1510() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1505() -> bool { +fn default_1511() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_1506() -> Integer { +fn default_1512() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1507() -> Integer { +fn default_1513() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1508() -> Integer { +fn default_1514() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1509() -> Integer { +fn default_1515() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1510() -> Integer { +fn default_1516() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1511() -> bool { +fn default_1517() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1512() -> Vec { +fn default_1518() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1513() -> String { +fn default_1519() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1514() -> String { +fn default_1520() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1515() -> Option { +fn default_1521() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1516() -> Vec { +fn default_1522() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1517() -> bool { +fn default_1523() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1518() -> bool { +fn default_1524() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1519() -> Vec { +fn default_1525() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1520() -> bool { +fn default_1526() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1521() -> Option { +fn default_1527() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1522() -> Vec { +fn default_1528() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1523() -> Option { +fn default_1529() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1524() -> Option { +fn default_1530() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1525() -> Vec { +fn default_1531() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1526() -> Integer { +fn default_1532() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1527() -> bool { +fn default_1533() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_1528() -> String { +fn default_1534() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1529() -> Integer { +fn default_1535() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1530() -> Integer { +fn default_1536() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1531() -> std::collections::HashMap { +fn default_1537() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1532() -> String { +fn default_1538() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1533() -> f64 { +fn default_1539() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_1534() -> bool { +fn default_1540() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1535() -> String { +fn default_1541() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1536() -> String { +fn default_1542() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1537() -> Integer { +fn default_1543() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1538() -> Integer { +fn default_1544() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1539() -> Option { +fn default_1545() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1540() -> Vec { +fn default_1546() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1541() -> Vec { +fn default_1547() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1542() -> Option { +fn default_1548() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1543() -> Option { +fn default_1549() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1544() -> Integer { +fn default_1550() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1545() -> bool { +fn default_1551() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1546() -> String { +fn default_1552() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1547() -> String { +fn default_1553() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1548() -> String { +fn default_1554() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1549() -> String { +fn default_1555() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1550() -> Option { +fn default_1556() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1551() -> String { +fn default_1557() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1552() -> Integer { +fn default_1558() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1553() -> Integer { +fn default_1559() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1554() -> String { +fn default_1560() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1555() -> Vec { +fn default_1561() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1556() -> bool { +fn default_1562() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1557() -> Integer { +fn default_1563() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1558() -> Integer { +fn default_1564() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1559() -> Integer { +fn default_1565() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1560() -> Integer { +fn default_1566() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1561() -> Integer { +fn default_1567() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1562() -> String { +fn default_1568() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1563() -> String { +fn default_1569() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1564() -> String { +fn default_1570() -> String { serde_json::from_str("\"-\"").expect("schema default") } -fn default_1565() -> String { +fn default_1571() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1566() -> Vec { +fn default_1572() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1567() -> Integer { +fn default_1573() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1568() -> Integer { +fn default_1574() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1569() -> String { +fn default_1575() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1570() -> String { +fn default_1576() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1571() -> Vec { +fn default_1577() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1572() -> String { +fn default_1578() -> String { serde_json::from_str("\"-\"").expect("schema default") } -fn default_1573() -> String { +fn default_1579() -> String { serde_json::from_str("\"-\"").expect("schema default") } -fn default_1574() -> Vec { +fn default_1580() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1575() -> Vec { +fn default_1581() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1576() -> String { +fn default_1582() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1577() -> String { +fn default_1583() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1578() -> Vec { +fn default_1584() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1579() -> f64 { +fn default_1585() -> f64 { serde_json::from_str("1.0").expect("schema default") } -fn default_1580() -> String { +fn default_1586() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1581() -> String { +fn default_1587() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1582() -> Vec { +fn default_1588() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1583() -> bool { +fn default_1589() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1584() -> String { +fn default_1590() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1585() -> Integer { +fn default_1591() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1586() -> Vec { +fn default_1592() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1587() -> Vec { +fn default_1593() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1588() -> Vec { +fn default_1594() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1589() -> Vec { +fn default_1595() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1590() -> Vec { +fn default_1596() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1591() -> Option { +fn default_1597() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1592() -> Option { +fn default_1598() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1593() -> Vec { +fn default_1599() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1594() -> Integer { +fn default_1600() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1595() -> Integer { +fn default_1601() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1596() -> Vec { +fn default_1602() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1597() -> Vec { +fn default_1603() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1598() -> Integer { +fn default_1604() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1599() -> Integer { +fn default_1605() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1600() -> bool { +fn default_1606() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1601() -> Vec { +fn default_1607() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1602() -> f64 { +fn default_1608() -> f64 { serde_json::from_str("1.0").expect("schema default") } -fn default_1603() -> bool { +fn default_1609() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1604() -> String { +fn default_1610() -> String { serde_json::from_str("\"active\"").expect("schema default") } -fn default_1605() -> String { +fn default_1611() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1606() -> Option { +fn default_1612() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1607() -> String { +fn default_1613() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1608() -> String { +fn default_1614() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1609() -> String { +fn default_1615() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1610() -> String { +fn default_1616() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1611() -> MemoryForFileHitSupersedesKind { +fn default_1617() -> MemoryForFileHitSupersedesKind { serde_json::from_str("\"\"").expect("schema default") } -fn default_1612() -> Vec { +fn default_1618() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1613() -> String { +fn default_1619() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1614() -> MemoryForFileHitVerification { +fn default_1620() -> MemoryForFileHitVerification { serde_json::from_str("\"none\"").expect("schema default") } -fn default_1615() -> MemoryForFileHitCodeState { +fn default_1621() -> MemoryForFileHitCodeState { serde_json::from_str("\"\"").expect("schema default") } -fn default_1616() -> Vec { +fn default_1622() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1617() -> String { +fn default_1623() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1618() -> Integer { +fn default_1624() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1619() -> bool { +fn default_1625() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1620() -> bool { +fn default_1626() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1621() -> Vec { +fn default_1627() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1622() -> String { +fn default_1628() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1623() -> String { +fn default_1629() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1624() -> String { +fn default_1630() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1625() -> String { +fn default_1631() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1626() -> String { +fn default_1632() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1627() -> String { +fn default_1633() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1628() -> Option { +fn default_1634() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1629() -> Value { +fn default_1635() -> Value { serde_json::from_str("null").expect("schema default") } -fn default_1630() -> Option { +fn default_1636() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1631() -> Option { +fn default_1637() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1632() -> Option { +fn default_1638() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1633() -> Option { +fn default_1639() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1634() -> Option { +fn default_1640() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1635() -> Option { +fn default_1641() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1636() -> bool { +fn default_1642() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1637() -> String { +fn default_1643() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1638() -> String { +fn default_1644() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1639() -> Option { +fn default_1645() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1640() -> String { +fn default_1646() -> String { serde_json::from_str("\"none\"").expect("schema default") } -fn default_1641() -> String { +fn default_1647() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1642() -> String { +fn default_1648() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1643() -> String { +fn default_1649() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1644() -> String { +fn default_1650() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1645() -> String { +fn default_1651() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1646() -> Option { +fn default_1652() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1647() -> String { +fn default_1653() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1648() -> String { +fn default_1654() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1649() -> String { +fn default_1655() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1650() -> Integer { +fn default_1656() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1651() -> Vec { +fn default_1657() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1652() -> Integer { +fn default_1658() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1653() -> Option { +fn default_1659() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1654() -> Vec { +fn default_1660() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1655() -> std::collections::HashMap { +fn default_1661() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1656() -> Integer { +fn default_1662() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1657() -> f64 { +fn default_1663() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_1658() -> Integer { +fn default_1664() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1659() -> Integer { +fn default_1665() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1660() -> Integer { +fn default_1666() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1661() -> Integer { +fn default_1667() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1662() -> Integer { +fn default_1668() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1663() -> MemoryHealthStaleness { +fn default_1669() -> MemoryHealthStaleness { serde_json::from_str("{\"by_age\":{},\"with_validity_end\":0,\"with_validity_end_share\":0.0,\"with_expiry\":0,\"expiring_7d\":0,\"pinned\":0,\"days_since_reinforced_p50\":0,\"days_since_reinforced_p90\":0}").expect("schema default") } -fn default_1664() -> Integer { +fn default_1670() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1665() -> Integer { +fn default_1671() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1666() -> f64 { +fn default_1672() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_1667() -> MemoryHealthFootprint { +fn default_1673() -> MemoryHealthFootprint { serde_json::from_str("{\"value_chars\":0,\"value_tokens_est\":0,\"tokens_per_row_est\":0.0}") .expect("schema default") } -fn default_1668() -> String { +fn default_1674() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1669() -> Value { +fn default_1675() -> Value { serde_json::from_str("null").expect("schema default") } -fn default_1670() -> String { +fn default_1676() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1671() -> bool { +fn default_1677() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1672() -> Option { +fn default_1678() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1673() -> Option { +fn default_1679() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1674() -> Option { +fn default_1680() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1675() -> String { +fn default_1681() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1676() -> String { +fn default_1682() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1677() -> String { +fn default_1683() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1678() -> String { +fn default_1684() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1679() -> String { +fn default_1685() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1680() -> Option { +fn default_1686() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1681() -> String { +fn default_1687() -> String { serde_json::from_str("\"active\"").expect("schema default") } -fn default_1682() -> Vec { +fn default_1688() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1683() -> Vec { +fn default_1689() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1684() -> Option { +fn default_1690() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1685() -> String { +fn default_1691() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1686() -> String { +fn default_1692() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1687() -> String { +fn default_1693() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1688() -> String { +fn default_1694() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1689() -> Option { +fn default_1695() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1690() -> Integer { +fn default_1696() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1691() -> Integer { +fn default_1697() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1692() -> Integer { +fn default_1698() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1693() -> Integer { +fn default_1699() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1694() -> MemoryImportResultReason { +fn default_1700() -> MemoryImportResultReason { serde_json::from_str("\"\"").expect("schema default") } -fn default_1695() -> String { +fn default_1701() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1696() -> MemoryImportResultNote { +fn default_1702() -> MemoryImportResultNote { serde_json::from_str("\"\"").expect("schema default") } -fn default_1697() -> bool { +fn default_1703() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1698() -> String { +fn default_1704() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1699() -> Option { +fn default_1705() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1700() -> Integer { +fn default_1706() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1701() -> Integer { +fn default_1707() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1702() -> Integer { +fn default_1708() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1703() -> String { +fn default_1709() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1704() -> Integer { +fn default_1710() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1705() -> Vec { +fn default_1711() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1706() -> Integer { +fn default_1712() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1707() -> Integer { +fn default_1713() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1708() -> Vec { +fn default_1714() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1709() -> Integer { +fn default_1715() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1710() -> Vec { +fn default_1716() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1711() -> Vec { +fn default_1717() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1712() -> Vec { +fn default_1718() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1713() -> Vec { +fn default_1719() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1714() -> Vec { +fn default_1720() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1715() -> Option { +fn default_1721() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1716() -> Option { +fn default_1722() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1717() -> String { +fn default_1723() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1718() -> Integer { +fn default_1724() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1719() -> String { +fn default_1725() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1720() -> Vec { +fn default_1726() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1721() -> bool { +fn default_1727() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_1722() -> Vec { +fn default_1728() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1723() -> Option { +fn default_1729() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1724() -> Option { +fn default_1730() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1725() -> String { +fn default_1731() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1726() -> Integer { +fn default_1732() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1727() -> String { +fn default_1733() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1728() -> Integer { +fn default_1734() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1729() -> Option { +fn default_1735() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1730() -> String { +fn default_1736() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1731() -> String { +fn default_1737() -> String { serde_json::from_str("\"Each request that extracts memories from messages may send extraction instructions; no user, agent or session setting stores them.\"").expect("schema default") } -fn default_1732() -> Vec { +fn default_1738() -> Vec { serde_json::from_str("[\"memory.set_from_messages\",\"extraction_instructions\"]") .expect("schema default") } -fn default_1733() -> Vec { +fn default_1739() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1734() -> bool { +fn default_1740() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1735() -> String { +fn default_1741() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1736() -> String { +fn default_1742() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1737() -> Option { +fn default_1743() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1738() -> String { +fn default_1744() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1739() -> String { +fn default_1745() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1740() -> String { +fn default_1746() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1741() -> MemoryLineageOutputMechanism { +fn default_1747() -> MemoryLineageOutputMechanism { serde_json::from_str("\"unknown\"").expect("schema default") } -fn default_1742() -> Vec { +fn default_1748() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1743() -> String { +fn default_1749() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1744() -> String { +fn default_1750() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1745() -> Option { +fn default_1751() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1746() -> Vec { +fn default_1752() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1747() -> f64 { +fn default_1753() -> f64 { serde_json::from_str("1.0").expect("schema default") } -fn default_1748() -> bool { +fn default_1754() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1749() -> bool { +fn default_1755() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1750() -> Integer { +fn default_1756() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1751() -> Integer { +fn default_1757() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1752() -> String { +fn default_1758() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1753() -> bool { +fn default_1759() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1754() -> Integer { +fn default_1760() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1755() -> String { +fn default_1761() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1756() -> String { +fn default_1762() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1757() -> String { +fn default_1763() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1758() -> Option { +fn default_1764() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1759() -> String { +fn default_1765() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1760() -> Option { +fn default_1766() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1761() -> String { +fn default_1767() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1762() -> String { +fn default_1768() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1763() -> String { +fn default_1769() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1764() -> Integer { +fn default_1770() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1765() -> String { +fn default_1771() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1766() -> Vec { +fn default_1772() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1767() -> bool { +fn default_1773() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1768() -> String { +fn default_1774() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1769() -> String { +fn default_1775() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1770() -> String { +fn default_1776() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1771() -> bool { +fn default_1777() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1772() -> std::collections::HashMap { +fn default_1778() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1773() -> String { +fn default_1779() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1774() -> String { +fn default_1780() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1775() -> Integer { +fn default_1781() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1776() -> Integer { +fn default_1782() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1777() -> Vec { +fn default_1783() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1778() -> Integer { +fn default_1784() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1779() -> Integer { +fn default_1785() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1780() -> Vec { +fn default_1786() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1781() -> String { +fn default_1787() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1782() -> Integer { +fn default_1788() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1783() -> String { +fn default_1789() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1784() -> Vec { +fn default_1790() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1785() -> Integer { +fn default_1791() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1786() -> Option { +fn default_1792() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1787() -> Vec { +fn default_1793() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1788() -> Integer { +fn default_1794() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1789() -> String { +fn default_1795() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1790() -> String { +fn default_1796() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1791() -> Vec { +fn default_1797() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1792() -> String { +fn default_1798() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1793() -> String { +fn default_1799() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1794() -> String { +fn default_1800() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1795() -> String { +fn default_1801() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1796() -> String { +fn default_1802() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1797() -> Vec { +fn default_1803() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1798() -> String { +fn default_1804() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1799() -> Integer { +fn default_1805() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1800() -> Integer { +fn default_1806() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1801() -> String { +fn default_1807() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1802() -> Integer { +fn default_1808() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1803() -> Integer { +fn default_1809() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1804() -> MemoryProposalReady { +fn default_1810() -> MemoryProposalReady { serde_json::from_str("\"\"").expect("schema default") } -fn default_1805() -> Vec { +fn default_1811() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1806() -> Vec { +fn default_1812() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1807() -> Integer { +fn default_1813() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1808() -> ProposalPolicyMode { +fn default_1814() -> ProposalPolicyMode { serde_json::from_str("\"manual\"").expect("schema default") } -fn default_1809() -> Integer { +fn default_1815() -> Integer { serde_json::from_str("2").expect("schema default") } -fn default_1810() -> Integer { +fn default_1816() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1811() -> Integer { +fn default_1817() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1812() -> ProposalPolicy { +fn default_1818() -> ProposalPolicy { serde_json::from_str( "{\"mode\":\"manual\",\"min_passes\":2,\"max_fails\":0,\"reject_after_fails\":0}", ) .expect("schema default") } -fn default_1813() -> String { +fn default_1819() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1814() -> String { +fn default_1820() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1815() -> String { +fn default_1821() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1816() -> String { +fn default_1822() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1817() -> String { +fn default_1823() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1818() -> String { +fn default_1824() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1819() -> bool { +fn default_1825() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1820() -> String { +fn default_1826() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1821() -> String { +fn default_1827() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1822() -> String { +fn default_1828() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1823() -> String { +fn default_1829() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1824() -> String { +fn default_1830() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1825() -> String { +fn default_1831() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1826() -> String { +fn default_1832() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1827() -> String { +fn default_1833() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1828() -> String { +fn default_1834() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1829() -> Vec { +fn default_1835() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1830() -> f64 { +fn default_1836() -> f64 { serde_json::from_str("1.0").expect("schema default") } -fn default_1831() -> String { +fn default_1837() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1832() -> String { +fn default_1838() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1833() -> Vec { +fn default_1839() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1834() -> String { +fn default_1840() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1835() -> String { +fn default_1841() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1836() -> String { +fn default_1842() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1837() -> String { +fn default_1843() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1838() -> bool { +fn default_1844() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1839() -> Integer { +fn default_1845() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1840() -> Integer { +fn default_1846() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1841() -> Integer { +fn default_1847() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1842() -> bool { +fn default_1848() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1843() -> String { +fn default_1849() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1844() -> Integer { +fn default_1850() -> Integer { serde_json::from_str("-1").expect("schema default") } -fn default_1845() -> MemoryRecallOutputOrder { +fn default_1851() -> MemoryRecallOutputOrder { serde_json::from_str("\"recent\"").expect("schema default") } -fn default_1846() -> Vec { +fn default_1852() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1847() -> Integer { +fn default_1853() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1848() -> Value { +fn default_1854() -> Value { serde_json::from_str("null").expect("schema default") } -fn default_1849() -> Value { +fn default_1855() -> Value { serde_json::from_str("null").expect("schema default") } -fn default_1850() -> String { +fn default_1856() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1851() -> String { +fn default_1857() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1852() -> Option { +fn default_1858() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1853() -> Option { +fn default_1859() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1854() -> bool { +fn default_1860() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1855() -> String { +fn default_1861() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1856() -> String { +fn default_1862() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1857() -> std::collections::HashMap { +fn default_1863() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1858() -> std::collections::HashMap { +fn default_1864() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1859() -> MemoryRecordRowStatus { +fn default_1865() -> MemoryRecordRowStatus { serde_json::from_str("\"active\"").expect("schema default") } -fn default_1860() -> Option { +fn default_1866() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1861() -> Option { +fn default_1867() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1862() -> bool { +fn default_1868() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1863() -> String { +fn default_1869() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1864() -> MemoryRecordWriteOutputKeySource { +fn default_1870() -> MemoryRecordWriteOutputKeySource { serde_json::from_str("\"anonymous\"").expect("schema default") } -fn default_1865() -> std::collections::HashMap { +fn default_1871() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1866() -> String { +fn default_1872() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1867() -> Integer { +fn default_1873() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1868() -> bool { +fn default_1874() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1869() -> Option { +fn default_1875() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1870() -> Integer { +fn default_1876() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1871() -> Integer { +fn default_1877() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1872() -> Option { +fn default_1878() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1873() -> String { +fn default_1879() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1874() -> Integer { +fn default_1880() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1875() -> Integer { +fn default_1881() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1876() -> bool { +fn default_1882() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1877() -> Vec { +fn default_1883() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1878() -> Option { +fn default_1884() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1879() -> Option { +fn default_1885() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1880() -> bool { +fn default_1886() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1881() -> bool { +fn default_1887() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1882() -> String { +fn default_1888() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1883() -> f64 { +fn default_1889() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_1884() -> String { +fn default_1890() -> String { serde_json::from_str("\"fact\"").expect("schema default") } -fn default_1885() -> String { +fn default_1891() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1886() -> std::collections::HashMap { +fn default_1892() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1887() -> bool { +fn default_1893() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1888() -> Integer { +fn default_1894() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1889() -> String { +fn default_1895() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1890() -> Vec { +fn default_1896() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1891() -> Vec { +fn default_1897() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1892() -> Integer { +fn default_1898() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1893() -> Integer { +fn default_1899() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1894() -> String { +fn default_1900() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1895() -> String { +fn default_1901() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1896() -> Integer { +fn default_1902() -> Integer { serde_json::from_str("1").expect("schema default") } -fn default_1897() -> Integer { +fn default_1903() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1898() -> Integer { +fn default_1904() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1899() -> Vec { +fn default_1905() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1900() -> Integer { +fn default_1906() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1901() -> Integer { +fn default_1907() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1902() -> Integer { +fn default_1908() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1903() -> Integer { +fn default_1909() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1904() -> Vec { +fn default_1910() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1905() -> String { +fn default_1911() -> String { serde_json::from_str("\"whole\"").expect("schema default") } -fn default_1906() -> Integer { +fn default_1912() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1907() -> Vec { +fn default_1913() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1908() -> Vec { +fn default_1914() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1909() -> Integer { +fn default_1915() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1910() -> Vec { +fn default_1916() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1911() -> Integer { +fn default_1917() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1912() -> Vec { +fn default_1918() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1913() -> Vec { +fn default_1919() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1914() -> bool { +fn default_1920() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1915() -> String { +fn default_1921() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1916() -> String { +fn default_1922() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1917() -> std::collections::HashMap { +fn default_1923() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1918() -> String { +fn default_1924() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1919() -> bool { +fn default_1925() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1920() -> Vec { +fn default_1926() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1921() -> Integer { +fn default_1927() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1922() -> Integer { +fn default_1928() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1923() -> String { +fn default_1929() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1924() -> String { +fn default_1930() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1925() -> String { +fn default_1931() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1926() -> bool { +fn default_1932() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1927() -> Integer { +fn default_1933() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1928() -> Option { +fn default_1934() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1929() -> String { +fn default_1935() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1930() -> String { +fn default_1936() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1931() -> String { +fn default_1937() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1932() -> Vec { +fn default_1938() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1933() -> Integer { +fn default_1939() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1934() -> Integer { +fn default_1940() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1935() -> Integer { +fn default_1941() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1936() -> Integer { +fn default_1942() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1937() -> Integer { +fn default_1943() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1938() -> Integer { +fn default_1944() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1939() -> bool { +fn default_1945() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1940() -> Vec> { +fn default_1946() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_1941() -> Vec { +fn default_1947() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1942() -> Option { +fn default_1948() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1943() -> String { +fn default_1949() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1944() -> Integer { +fn default_1950() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1945() -> Option { +fn default_1951() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1946() -> Option { +fn default_1952() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1947() -> Option { +fn default_1953() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1948() -> Option { +fn default_1954() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1949() -> Vec { +fn default_1955() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1950() -> Integer { +fn default_1956() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1951() -> String { +fn default_1957() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1952() -> String { +fn default_1958() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1953() -> Option { +fn default_1959() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1954() -> String { +fn default_1960() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1955() -> String { +fn default_1961() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1956() -> String { +fn default_1962() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1957() -> String { +fn default_1963() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1958() -> Option { +fn default_1964() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1959() -> String { +fn default_1965() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1960() -> String { +fn default_1966() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1961() -> Integer { +fn default_1967() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1962() -> String { +fn default_1968() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1963() -> String { +fn default_1969() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1964() -> String { +fn default_1970() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1965() -> String { +fn default_1971() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1966() -> String { +fn default_1972() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1967() -> Integer { +fn default_1973() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1968() -> String { +fn default_1974() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1969() -> Vec { +fn default_1975() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1970() -> String { +fn default_1976() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1971() -> Integer { +fn default_1977() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1972() -> String { +fn default_1978() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1973() -> Integer { +fn default_1979() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1974() -> String { +fn default_1980() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1975() -> String { +fn default_1981() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1976() -> Integer { +fn default_1982() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1977() -> String { +fn default_1983() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1978() -> bool { +fn default_1984() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1979() -> String { +fn default_1985() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1980() -> String { +fn default_1986() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1981() -> String { +fn default_1987() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1982() -> String { +fn default_1988() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1983() -> Option { +fn default_1989() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1984() -> String { +fn default_1990() -> String { serde_json::from_str("\"none\"").expect("schema default") } -fn default_1985() -> Integer { +fn default_1991() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1986() -> String { +fn default_1992() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1987() -> String { +fn default_1993() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1988() -> String { +fn default_1994() -> String { serde_json::from_str("\"active\"").expect("schema default") } -fn default_1989() -> bool { +fn default_1995() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1990() -> Vec { +fn default_1996() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1991() -> std::collections::HashMap { +fn default_1997() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1992() -> String { +fn default_1998() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1993() -> Vec { +fn default_1999() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1994() -> std::collections::HashMap { +fn default_2000() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1995() -> Integer { +fn default_2001() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1996() -> Option { +fn default_2002() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1997() -> String { +fn default_2003() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1998() -> bool { +fn default_2004() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_1999() -> Vec { +fn default_2005() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2000() -> Vec { +fn default_2006() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2001() -> std::collections::HashMap { +fn default_2007() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2002() -> Option { +fn default_2008() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2003() -> Vec { +fn default_2009() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2004() -> Integer { +fn default_2010() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2005() -> Integer { +fn default_2011() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2006() -> Vec { +fn default_2012() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2007() -> Option { +fn default_2013() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2008() -> Vec { +fn default_2014() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2009() -> Option { +fn default_2015() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2010() -> Option { +fn default_2016() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2011() -> Vec { +fn default_2017() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2012() -> bool { +fn default_2018() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2013() -> Vec { +fn default_2019() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2014() -> bool { +fn default_2020() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_2015() -> Integer { +fn default_2021() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2016() -> Integer { +fn default_2022() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2017() -> Integer { +fn default_2023() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2018() -> Integer { +fn default_2024() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2019() -> Integer { +fn default_2025() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2020() -> Integer { +fn default_2026() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2021() -> Integer { +fn default_2027() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2022() -> Integer { +fn default_2028() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2023() -> Integer { +fn default_2029() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2024() -> f64 { +fn default_2030() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_2025() -> Integer { +fn default_2031() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2026() -> Integer { +fn default_2032() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2027() -> Integer { +fn default_2033() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2028() -> Integer { +fn default_2034() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2029() -> Option { +fn default_2035() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2030() -> Option { +fn default_2036() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2031() -> Vec { +fn default_2037() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2032() -> String { +fn default_2038() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2033() -> String { +fn default_2039() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2034() -> Integer { +fn default_2040() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2035() -> Vec> { +fn default_2041() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2036() -> Vec { +fn default_2042() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2037() -> String { +fn default_2043() -> String { serde_json::from_str("\"memory\"").expect("schema default") } -fn default_2038() -> bool { +fn default_2044() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2039() -> String { +fn default_2045() -> String { serde_json::from_str("\"approval\"").expect("schema default") } -fn default_2040() -> String { +fn default_2046() -> String { serde_json::from_str("\"public\"").expect("schema default") } -fn default_2041() -> BrowseEntryMyStatus { +fn default_2047() -> BrowseEntryMyStatus { serde_json::from_str("\"none\"").expect("schema default") } -fn default_2042() -> String { +fn default_2048() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2043() -> String { +fn default_2049() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2044() -> String { +fn default_2050() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2045() -> Integer { +fn default_2051() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2046() -> String { +fn default_2052() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2047() -> Option { +fn default_2053() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2048() -> Option { +fn default_2054() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2049() -> Vec { +fn default_2055() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2050() -> Option { +fn default_2056() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2051() -> Option { +fn default_2057() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2052() -> Option { +fn default_2058() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2053() -> Option> { +fn default_2059() -> Option> { serde_json::from_str("null").expect("schema default") } -fn default_2054() -> Option { +fn default_2060() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2055() -> Option { +fn default_2061() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2056() -> Option { +fn default_2062() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2057() -> Option { +fn default_2063() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2058() -> Option { +fn default_2064() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2059() -> Option { +fn default_2065() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2060() -> Option { +fn default_2066() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2061() -> Option { +fn default_2067() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2062() -> Option { +fn default_2068() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2063() -> Option { +fn default_2069() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2064() -> Option { +fn default_2070() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2065() -> Option { +fn default_2071() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2066() -> Option { +fn default_2072() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2067() -> Option { +fn default_2073() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2068() -> Option { +fn default_2074() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2069() -> Option> { +fn default_2075() -> Option> { serde_json::from_str("null").expect("schema default") } -fn default_2070() -> Option { +fn default_2076() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2071() -> Option { +fn default_2077() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2072() -> Option { +fn default_2078() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2073() -> Option { +fn default_2079() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2074() -> Option { +fn default_2080() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2075() -> Option>> { +fn default_2081() -> Option>> { serde_json::from_str("null").expect("schema default") } -fn default_2076() -> Option { +fn default_2082() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2077() -> Option { +fn default_2083() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2078() -> Option { +fn default_2084() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2079() -> Option { +fn default_2085() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2080() -> Option { +fn default_2086() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2081() -> Integer { +fn default_2087() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2082() -> String { +fn default_2088() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2083() -> String { +fn default_2089() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2084() -> String { +fn default_2090() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2085() -> String { +fn default_2091() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2086() -> Option { +fn default_2092() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2087() -> bool { +fn default_2093() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2088() -> Integer { +fn default_2094() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2089() -> String { +fn default_2095() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2090() -> String { +fn default_2096() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2091() -> String { +fn default_2097() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2092() -> String { +fn default_2098() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2093() -> Option { +fn default_2099() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2094() -> Option { +fn default_2100() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2095() -> String { +fn default_2101() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2096() -> Vec { +fn default_2102() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2097() -> String { +fn default_2103() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2098() -> String { +fn default_2104() -> String { serde_json::from_str("\"active\"").expect("schema default") } -fn default_2099() -> Option { +fn default_2105() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2100() -> Vec { +fn default_2106() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2101() -> Option { +fn default_2107() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2102() -> String { +fn default_2108() -> String { serde_json::from_str("\"memory\"").expect("schema default") } -fn default_2103() -> bool { +fn default_2109() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2104() -> f64 { +fn default_2110() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_2105() -> f64 { +fn default_2111() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_2106() -> String { +fn default_2112() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2107() -> Option { +fn default_2113() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2108() -> Integer { +fn default_2114() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2109() -> Integer { +fn default_2115() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2110() -> NamespaceEntryVisibility { +fn default_2116() -> NamespaceEntryVisibility { serde_json::from_str("\"private\"").expect("schema default") } -fn default_2111() -> String { +fn default_2117() -> String { serde_json::from_str("\"active\"").expect("schema default") } -fn default_2112() -> Option { +fn default_2118() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2113() -> Option { +fn default_2119() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2114() -> Vec { +fn default_2120() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2115() -> MineEntryVisibility { +fn default_2121() -> MineEntryVisibility { serde_json::from_str("\"private\"").expect("schema default") } -fn default_2116() -> String { +fn default_2122() -> String { serde_json::from_str("\"memory\"").expect("schema default") } -fn default_2117() -> String { +fn default_2123() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2118() -> String { +fn default_2124() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2119() -> Option { +fn default_2125() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2120() -> bool { +fn default_2126() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2121() -> bool { +fn default_2127() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2122() -> String { +fn default_2128() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2123() -> NamespaceRegisterOutputVisibility { +fn default_2129() -> NamespaceRegisterOutputVisibility { serde_json::from_str("\"private\"").expect("schema default") } -fn default_2124() -> bool { +fn default_2130() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2125() -> Integer { +fn default_2131() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2126() -> Integer { +fn default_2132() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2127() -> bool { +fn default_2133() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2128() -> Vec> { +fn default_2134() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2129() -> Option { +fn default_2135() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2130() -> Option { +fn default_2136() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2131() -> Vec { +fn default_2137() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2132() -> Integer { +fn default_2138() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2133() -> String { +fn default_2139() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2134() -> String { +fn default_2140() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2135() -> String { +fn default_2141() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2136() -> String { +fn default_2142() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2137() -> String { +fn default_2143() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2138() -> Option { +fn default_2144() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2139() -> String { +fn default_2145() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2140() -> String { +fn default_2146() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2141() -> String { +fn default_2147() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2142() -> Vec { +fn default_2148() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2143() -> Option { +fn default_2149() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2144() -> Option { +fn default_2150() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2145() -> Option { +fn default_2151() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2146() -> Option { +fn default_2152() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2147() -> String { +fn default_2153() -> String { serde_json::from_str("\"{}\"").expect("schema default") } -fn default_2148() -> NamespaceSnapshotOutputSnapshotMemoryRowStatus { +fn default_2154() -> NamespaceSnapshotOutputSnapshotMemoryRowStatus { serde_json::from_str("\"active\"").expect("schema default") } -fn default_2149() -> Option { +fn default_2155() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2150() -> Vec { +fn default_2156() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2151() -> String { +fn default_2157() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2152() -> Integer { +fn default_2158() -> Integer { serde_json::from_str("1").expect("schema default") } -fn default_2153() -> Integer { +fn default_2159() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2154() -> Option { +fn default_2160() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2155() -> String { +fn default_2161() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2156() -> String { +fn default_2162() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2157() -> String { +fn default_2163() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2158() -> String { +fn default_2164() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2159() -> Option { +fn default_2165() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2160() -> f64 { +fn default_2166() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_2161() -> Option { +fn default_2167() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2162() -> Option { +fn default_2168() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2163() -> Integer { +fn default_2169() -> Integer { serde_json::from_str("1").expect("schema default") } -fn default_2164() -> Option { +fn default_2170() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2165() -> Option { +fn default_2171() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2166() -> String { +fn default_2172() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2167() -> Option { +fn default_2173() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2168() -> String { +fn default_2174() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2169() -> String { +fn default_2175() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2170() -> String { +fn default_2176() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2171() -> Option { +fn default_2177() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2172() -> String { +fn default_2178() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2173() -> Option { +fn default_2179() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2174() -> String { +fn default_2180() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2175() -> String { +fn default_2181() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2176() -> Vec { +fn default_2182() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2177() -> Vec { +fn default_2183() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2178() -> Option { +fn default_2184() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2179() -> Integer { +fn default_2185() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2180() -> String { +fn default_2186() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2181() -> Vec { +fn default_2187() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2182() -> Vec { +fn default_2188() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2183() -> String { +fn default_2189() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2184() -> Option { +fn default_2190() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2185() -> Vec { +fn default_2191() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2186() -> Integer { +fn default_2192() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2187() -> Vec { +fn default_2193() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2188() -> Option { +fn default_2194() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2189() -> Vec { +fn default_2195() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2190() -> Vec { +fn default_2196() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2191() -> Option { +fn default_2197() -> Option { serde_json::from_str("0").expect("schema default") } -fn default_2192() -> TuneProposalEffect { +fn default_2198() -> TuneProposalEffect { serde_json::from_str("\"future\"").expect("schema default") } -fn default_2193() -> TuneApplyVia { +fn default_2199() -> TuneApplyVia { serde_json::from_str("\"op\"").expect("schema default") } -fn default_2194() -> bool { +fn default_2200() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_2195() -> Vec { +fn default_2201() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2196() -> Option { +fn default_2202() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2197() -> Option { +fn default_2203() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2198() -> String { +fn default_2204() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2199() -> Vec { +fn default_2205() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2200() -> Vec { +fn default_2206() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2201() -> Option { +fn default_2207() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2202() -> Option { +fn default_2208() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2203() -> Option { +fn default_2209() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2204() -> String { +fn default_2210() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2205() -> Option { +fn default_2211() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2206() -> Option { +fn default_2212() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2207() -> Option { +fn default_2213() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2208() -> Vec { +fn default_2214() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2209() -> bool { +fn default_2215() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2210() -> Option { +fn default_2216() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2211() -> Option { +fn default_2217() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2212() -> Vec { +fn default_2218() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2213() -> String { +fn default_2219() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2214() -> String { +fn default_2220() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2215() -> Vec> { +fn default_2221() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2216() -> std::collections::HashMap { +fn default_2222() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2217() -> Vec { +fn default_2223() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2218() -> Integer { +fn default_2224() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2219() -> Integer { +fn default_2225() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2220() -> String { +fn default_2226() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2221() -> String { +fn default_2227() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2222() -> String { +fn default_2228() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2223() -> Vec { +fn default_2229() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2224() -> Vec { +fn default_2230() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2225() -> String { +fn default_2231() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2226() -> String { +fn default_2232() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2227() -> bool { +fn default_2233() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2228() -> Integer { +fn default_2234() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2229() -> String { +fn default_2235() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2230() -> Option { +fn default_2236() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2231() -> Vec { +fn default_2237() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2232() -> String { +fn default_2238() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2233() -> String { +fn default_2239() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2234() -> String { +fn default_2240() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2235() -> Vec { +fn default_2241() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2236() -> String { +fn default_2242() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2237() -> String { +fn default_2243() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2238() -> std::collections::HashMap { +fn default_2244() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2239() -> String { +fn default_2245() -> String { serde_json::from_str("\"active\"").expect("schema default") } -fn default_2240() -> Option { +fn default_2246() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2241() -> Option { +fn default_2247() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2242() -> bool { +fn default_2248() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2243() -> String { +fn default_2249() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2244() -> String { +fn default_2250() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2245() -> Vec { +fn default_2251() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2246() -> Integer { +fn default_2252() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2247() -> String { +fn default_2253() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2248() -> String { +fn default_2254() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2249() -> Option { +fn default_2255() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2250() -> bool { +fn default_2256() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2251() -> String { +fn default_2257() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2252() -> bool { +fn default_2258() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2253() -> String { +fn default_2259() -> String { serde_json::from_str("\"inherit\"").expect("schema default") } -fn default_2254() -> Option { +fn default_2260() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2255() -> Option { +fn default_2261() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2256() -> bool { +fn default_2262() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2257() -> Vec { +fn default_2263() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2258() -> Integer { +fn default_2264() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2259() -> ProcedureEvolveOutputGate { +fn default_2265() -> ProcedureEvolveOutputGate { serde_json::from_str("\"none\"").expect("schema default") } -fn default_2260() -> String { +fn default_2266() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2261() -> f64 { +fn default_2267() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_2262() -> std::collections::HashMap { +fn default_2268() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2263() -> std::collections::HashMap { +fn default_2269() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2264() -> std::collections::HashMap { +fn default_2270() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2265() -> std::collections::HashMap { +fn default_2271() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2266() -> String { +fn default_2272() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2267() -> Vec { +fn default_2273() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2268() -> Vec { +fn default_2274() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2269() -> Vec { +fn default_2275() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2270() -> std::collections::HashMap { +fn default_2276() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2271() -> Integer { +fn default_2277() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2272() -> bool { +fn default_2278() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2273() -> std::collections::HashMap { +fn default_2279() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2274() -> Vec { +fn default_2280() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2275() -> std::collections::HashMap { +fn default_2281() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2276() -> String { +fn default_2282() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2277() -> ProcedureLocateOutputStatus { +fn default_2283() -> ProcedureLocateOutputStatus { serde_json::from_str("\"authored\"").expect("schema default") } -fn default_2278() -> Option> { +fn default_2284() -> Option> { serde_json::from_str("null").expect("schema default") } -fn default_2279() -> Vec>> { +fn default_2285() -> Vec>> { serde_json::from_str("[]").expect("schema default") } -fn default_2280() -> Vec { +fn default_2286() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2281() -> Vec { +fn default_2287() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2282() -> std::collections::HashMap { +fn default_2288() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2283() -> bool { +fn default_2289() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2284() -> Vec { +fn default_2290() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2285() -> Vec> { +fn default_2291() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2286() -> String { +fn default_2292() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2287() -> std::collections::HashMap { +fn default_2293() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2288() -> std::collections::HashMap { +fn default_2294() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2289() -> Vec { +fn default_2295() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2290() -> std::collections::HashMap { +fn default_2296() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2291() -> Option> { +fn default_2297() -> Option> { serde_json::from_str("null").expect("schema default") } -fn default_2292() -> bool { +fn default_2298() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2293() -> std::collections::HashMap { +fn default_2299() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2294() -> ProcedureMatchStatus { +fn default_2300() -> ProcedureMatchStatus { serde_json::from_str("\"authored\"").expect("schema default") } -fn default_2295() -> Option> { +fn default_2301() -> Option> { serde_json::from_str("null").expect("schema default") } -fn default_2296() -> Vec { +fn default_2302() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2297() -> Integer { +fn default_2303() -> Integer { serde_json::from_str("1").expect("schema default") } -fn default_2298() -> Vec> { +fn default_2304() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2299() -> f64 { +fn default_2305() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_2300() -> f64 { +fn default_2306() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_2301() -> f64 { +fn default_2307() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_2302() -> Option { +fn default_2308() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2303() -> std::collections::HashMap { +fn default_2309() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2304() -> std::collections::HashMap> { +fn default_2310() -> std::collections::HashMap> { serde_json::from_str("{}").expect("schema default") } -fn default_2305() -> String { +fn default_2311() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2306() -> Integer { +fn default_2312() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2307() -> String { +fn default_2313() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2308() -> f64 { +fn default_2314() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_2309() -> Vec { +fn default_2315() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2310() -> ProcedureReviseOutputOutcome { +fn default_2316() -> ProcedureReviseOutputOutcome { serde_json::from_str("\"opened\"").expect("schema default") } -fn default_2311() -> Vec { +fn default_2317() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2312() -> Vec { +fn default_2318() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2313() -> String { +fn default_2319() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2314() -> String { +fn default_2320() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2315() -> String { +fn default_2321() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2316() -> String { +fn default_2322() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2317() -> Option { +fn default_2323() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2318() -> Integer { +fn default_2324() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2319() -> Vec { +fn default_2325() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2320() -> std::collections::HashMap { +fn default_2326() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2321() -> Option { +fn default_2327() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2322() -> String { +fn default_2328() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2323() -> Integer { +fn default_2329() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2324() -> String { +fn default_2330() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2325() -> String { +fn default_2331() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2326() -> std::collections::HashMap { +fn default_2332() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2327() -> String { +fn default_2333() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2328() -> String { +fn default_2334() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2329() -> Option { +fn default_2335() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2330() -> RunBeginOutputStatus { +fn default_2336() -> RunBeginOutputStatus { serde_json::from_str("\"active\"").expect("schema default") } -fn default_2331() -> String { +fn default_2337() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2332() -> Integer { +fn default_2338() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2333() -> Integer { +fn default_2339() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2334() -> Integer { +fn default_2340() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2335() -> Integer { +fn default_2341() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2336() -> Vec { +fn default_2342() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2337() -> Integer { +fn default_2343() -> Integer { serde_json::from_str("-1").expect("schema default") } -fn default_2338() -> Integer { +fn default_2344() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2339() -> Integer { +fn default_2345() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2340() -> String { +fn default_2346() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2341() -> String { +fn default_2347() -> String { serde_json::from_str("\"keep\"").expect("schema default") } -fn default_2342() -> Integer { +fn default_2348() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2343() -> Integer { +fn default_2349() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2344() -> Integer { +fn default_2350() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2345() -> Option { +fn default_2351() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2346() -> Integer { +fn default_2352() -> Integer { serde_json::from_str("-1").expect("schema default") } -fn default_2347() -> Vec { +fn default_2353() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2348() -> Vec { +fn default_2354() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2349() -> Integer { +fn default_2355() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2350() -> Integer { +fn default_2356() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2351() -> Integer { +fn default_2357() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2352() -> f64 { +fn default_2358() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_2353() -> Integer { +fn default_2359() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2354() -> Vec { +fn default_2360() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2355() -> Integer { +fn default_2361() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2356() -> Vec { +fn default_2362() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2357() -> Integer { +fn default_2363() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2358() -> Integer { +fn default_2364() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2359() -> Integer { +fn default_2365() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2360() -> Vec { +fn default_2366() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2361() -> Option { +fn default_2367() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2362() -> String { +fn default_2368() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2363() -> Integer { +fn default_2369() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2364() -> Integer { +fn default_2370() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2365() -> Integer { +fn default_2371() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2366() -> Integer { +fn default_2372() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2367() -> bool { +fn default_2373() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2368() -> bool { +fn default_2374() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2369() -> Option> { +fn default_2375() -> Option> { serde_json::from_str("null").expect("schema default") } -fn default_2370() -> LiveSearchResultsLive { +fn default_2376() -> LiveSearchResultsLive { serde_json::from_str("true").expect("schema default") } -fn default_2371() -> String { +fn default_2377() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2372() -> LiveSearchHitLive { +fn default_2378() -> LiveSearchHitLive { serde_json::from_str("true").expect("schema default") } -fn default_2373() -> Vec { +fn default_2379() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2374() -> Option { +fn default_2380() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2375() -> std::collections::HashMap { +fn default_2381() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2376() -> std::collections::HashMap { +fn default_2382() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2377() -> std::collections::HashMap { +fn default_2383() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2378() -> std::collections::HashMap { +fn default_2384() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2379() -> Option> { +fn default_2385() -> Option> { serde_json::from_str("null").expect("schema default") } -fn default_2380() -> Vec { +fn default_2386() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2381() -> Integer { +fn default_2387() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2382() -> String { +fn default_2388() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2383() -> Integer { +fn default_2389() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2384() -> String { +fn default_2390() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2385() -> String { +fn default_2391() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2386() -> String { +fn default_2392() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2387() -> String { +fn default_2393() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2388() -> String { +fn default_2394() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2389() -> String { +fn default_2395() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2390() -> String { +fn default_2396() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2391() -> String { +fn default_2397() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2392() -> Vec { +fn default_2398() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2393() -> String { +fn default_2399() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2394() -> String { +fn default_2400() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2395() -> Vec { +fn default_2401() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2396() -> String { +fn default_2402() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2397() -> String { +fn default_2403() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2398() -> Vec { +fn default_2404() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2399() -> Vec { +fn default_2405() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2400() -> Vec { +fn default_2406() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2401() -> String { +fn default_2407() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2402() -> String { +fn default_2408() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2403() -> Vec { +fn default_2409() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2404() -> Vec { +fn default_2410() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2405() -> Vec { +fn default_2411() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2406() -> String { +fn default_2412() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2407() -> String { +fn default_2413() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2408() -> Option { +fn default_2414() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2409() -> String { +fn default_2415() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2410() -> String { +fn default_2416() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2411() -> String { +fn default_2417() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2412() -> String { +fn default_2418() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2413() -> String { +fn default_2419() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2414() -> String { +fn default_2420() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2415() -> Vec { +fn default_2421() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2416() -> Option { +fn default_2422() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2417() -> Integer { +fn default_2423() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2418() -> Integer { +fn default_2424() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2419() -> Integer { +fn default_2425() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2420() -> Integer { +fn default_2426() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2421() -> Integer { +fn default_2427() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2422() -> bool { +fn default_2428() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2423() -> String { +fn default_2429() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2424() -> String { +fn default_2430() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2425() -> String { +fn default_2431() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2426() -> String { +fn default_2432() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2427() -> String { +fn default_2433() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2428() -> String { +fn default_2434() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2429() -> String { +fn default_2435() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2430() -> Option { +fn default_2436() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2431() -> Integer { +fn default_2437() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2432() -> Integer { +fn default_2438() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2433() -> Vec { +fn default_2439() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2434() -> String { +fn default_2440() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2435() -> String { +fn default_2441() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2436() -> String { +fn default_2442() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2437() -> String { +fn default_2443() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2438() -> Integer { +fn default_2444() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2439() -> Integer { +fn default_2445() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2440() -> Integer { +fn default_2446() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2441() -> Integer { +fn default_2447() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2442() -> Integer { +fn default_2448() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2443() -> f64 { +fn default_2449() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_2444() -> Integer { +fn default_2450() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2445() -> Integer { +fn default_2451() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2446() -> Integer { +fn default_2452() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2447() -> String { +fn default_2453() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2448() -> SessionBriefStats { +fn default_2454() -> SessionBriefStats { serde_json::from_str("{\"events_in\":0,\"windows\":0,\"events_total\":0,\"source_chars\":0,\"brief_chars\":0,\"compression_ratio\":0.0,\"dropped_ungrounded\":0,\"tokens_in\":0,\"tokens_out\":0,\"llm_model\":\"\"}").expect("schema default") } -fn default_2449() -> String { +fn default_2455() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2450() -> String { +fn default_2456() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2451() -> Option { +fn default_2457() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2452() -> Option { +fn default_2458() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2453() -> Option { +fn default_2459() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2454() -> Integer { +fn default_2460() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2455() -> std::collections::HashMap { +fn default_2461() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2456() -> String { +fn default_2462() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2457() -> String { +fn default_2463() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2458() -> Option { +fn default_2464() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2459() -> String { +fn default_2465() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2460() -> Integer { +fn default_2466() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2461() -> Integer { +fn default_2467() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2462() -> Option { +fn default_2468() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2463() -> std::collections::HashMap { +fn default_2469() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2464() -> String { +fn default_2470() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2465() -> Integer { +fn default_2471() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2466() -> String { +fn default_2472() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2467() -> Option { +fn default_2473() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2468() -> String { +fn default_2474() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2469() -> Option { +fn default_2475() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2470() -> String { +fn default_2476() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2471() -> String { +fn default_2477() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2472() -> String { +fn default_2478() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2473() -> String { +fn default_2479() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2474() -> Integer { +fn default_2480() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2475() -> Integer { +fn default_2481() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2476() -> String { +fn default_2482() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2477() -> std::collections::HashMap { +fn default_2483() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2478() -> String { +fn default_2484() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2479() -> String { +fn default_2485() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2480() -> bool { +fn default_2486() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2481() -> String { +fn default_2487() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2482() -> std::collections::HashMap { +fn default_2488() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2483() -> Vec> { +fn default_2489() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2484() -> Vec { +fn default_2490() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2485() -> Vec { +fn default_2491() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2486() -> bool { +fn default_2492() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2487() -> String { +fn default_2493() -> String { serde_json::from_str("\"unknown\"").expect("schema default") } -fn default_2488() -> String { +fn default_2494() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2489() -> Vec { +fn default_2495() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2490() -> bool { +fn default_2496() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2491() -> String { +fn default_2497() -> String { serde_json::from_str("\"none\"").expect("schema default") } -fn default_2492() -> bool { +fn default_2498() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2493() -> Vec { +fn default_2499() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2494() -> std::collections::HashMap { +fn default_2500() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2495() -> Vec> { +fn default_2501() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2496() -> bool { +fn default_2502() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2497() -> bool { +fn default_2503() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2498() -> Vec> { +fn default_2504() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2499() -> std::collections::HashMap { +fn default_2505() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2500() -> String { +fn default_2506() -> String { serde_json::from_str("\"none\"").expect("schema default") } -fn default_2501() -> Vec> { +fn default_2507() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2502() -> bool { +fn default_2508() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2503() -> String { +fn default_2509() -> String { serde_json::from_str("\"calibrated\"").expect("schema default") } -fn default_2504() -> std::collections::HashMap { +fn default_2510() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2505() -> std::collections::HashMap { +fn default_2511() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2506() -> String { +fn default_2512() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2507() -> std::collections::HashMap { +fn default_2513() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2508() -> std::collections::HashMap { +fn default_2514() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2509() -> std::collections::HashMap { +fn default_2515() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2510() -> String { +fn default_2516() -> String { serde_json::from_str("\"ok\"").expect("schema default") } -fn default_2511() -> String { +fn default_2517() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2512() -> String { +fn default_2518() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2513() -> bool { +fn default_2519() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2514() -> Integer { +fn default_2520() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2515() -> String { +fn default_2521() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2516() -> String { +fn default_2522() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2517() -> Vec { +fn default_2523() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2518() -> bool { +fn default_2524() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2519() -> Vec { +fn default_2525() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2520() -> std::collections::HashMap> { +fn default_2526() -> std::collections::HashMap> { serde_json::from_str("{}").expect("schema default") } -fn default_2521() -> Vec> { +fn default_2527() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2522() -> Vec> { +fn default_2528() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2523() -> String { +fn default_2529() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2524() -> Vec> { +fn default_2530() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2525() -> std::collections::HashMap { +fn default_2531() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2526() -> String { +fn default_2532() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2527() -> Vec> { +fn default_2533() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2528() -> bool { +fn default_2534() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2529() -> Integer { +fn default_2535() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2530() -> Vec> { +fn default_2536() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2531() -> String { +fn default_2537() -> String { serde_json::from_str("\"no_flaky_signal\"").expect("schema default") } -fn default_2532() -> bool { +fn default_2538() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2533() -> Option> { +fn default_2539() -> Option> { serde_json::from_str("null").expect("schema default") } -fn default_2534() -> Vec { +fn default_2540() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2535() -> bool { +fn default_2541() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2536() -> std::collections::HashMap { +fn default_2542() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2537() -> String { +fn default_2543() -> String { serde_json::from_str("\"not_computed\"").expect("schema default") } -fn default_2538() -> Vec> { +fn default_2544() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2539() -> String { +fn default_2545() -> String { serde_json::from_str("\"candidate\"").expect("schema default") } -fn default_2540() -> std::collections::HashMap { +fn default_2546() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2541() -> String { +fn default_2547() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2542() -> bool { +fn default_2548() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2543() -> Integer { +fn default_2549() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2544() -> std::collections::HashMap { +fn default_2550() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2545() -> bool { +fn default_2551() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2546() -> Vec> { +fn default_2552() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2547() -> std::collections::HashMap { +fn default_2553() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2548() -> std::collections::HashMap { +fn default_2554() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2549() -> String { +fn default_2555() -> String { serde_json::from_str("\"lower_bound\"").expect("schema default") } -fn default_2550() -> bool { +fn default_2556() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2551() -> Vec { +fn default_2557() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2552() -> Vec> { +fn default_2558() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2553() -> std::collections::HashMap { +fn default_2559() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2554() -> Vec { +fn default_2560() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2555() -> String { +fn default_2561() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2556() -> bool { +fn default_2562() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2557() -> bool { +fn default_2563() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_2558() -> std::collections::HashMap { +fn default_2564() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2559() -> String { +fn default_2565() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2560() -> bool { +fn default_2566() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_2561() -> std::collections::HashMap { +fn default_2567() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2562() -> std::collections::HashMap { +fn default_2568() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2563() -> Vec> { +fn default_2569() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2564() -> Vec { +fn default_2570() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2565() -> std::collections::HashMap { +fn default_2571() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2566() -> Vec> { +fn default_2572() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2567() -> bool { +fn default_2573() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_2568() -> bool { +fn default_2574() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2569() -> Vec { +fn default_2575() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2570() -> std::collections::HashMap { +fn default_2576() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2571() -> String { +fn default_2577() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2572() -> std::collections::HashMap { +fn default_2578() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2573() -> bool { +fn default_2579() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2574() -> bool { +fn default_2580() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_2575() -> String { +fn default_2581() -> String { serde_json::from_str("\"no_signal\"").expect("schema default") } -fn default_2576() -> Vec { +fn default_2582() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2577() -> f64 { +fn default_2583() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_2578() -> Integer { +fn default_2584() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2579() -> String { +fn default_2585() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2580() -> std::collections::HashMap { +fn default_2586() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2581() -> std::collections::HashMap { +fn default_2587() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2582() -> std::collections::HashMap { +fn default_2588() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2583() -> std::collections::HashMap { +fn default_2589() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2584() -> String { +fn default_2590() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2585() -> std::collections::HashMap { +fn default_2591() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2586() -> bool { +fn default_2592() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2587() -> std::collections::HashMap { +fn default_2593() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2588() -> std::collections::HashMap { +fn default_2594() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2589() -> std::collections::HashMap { +fn default_2595() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2590() -> std::collections::HashMap { +fn default_2596() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2591() -> String { +fn default_2597() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2592() -> Vec> { +fn default_2598() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2593() -> Integer { +fn default_2599() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2594() -> String { +fn default_2600() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2595() -> bool { +fn default_2601() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_2596() -> String { +fn default_2602() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2597() -> Vec { +fn default_2603() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2598() -> bool { +fn default_2604() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2599() -> Vec { +fn default_2605() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2600() -> f64 { +fn default_2606() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_2601() -> String { +fn default_2607() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2602() -> Integer { +fn default_2608() -> Integer { serde_json::from_str("4096").expect("schema default") } -fn default_2603() -> Integer { +fn default_2609() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2604() -> Option { +fn default_2610() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2605() -> f64 { +fn default_2611() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_2606() -> Option { +fn default_2612() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2607() -> Vec { +fn default_2613() -> Vec { serde_json::from_str("[]").expect("schema default") } diff --git a/sdk/rust/tests/registry_contracts.rs b/sdk/rust/tests/registry_contracts.rs index 191f54d96d3..6af0b0faa0e 100644 --- a/sdk/rust/tests/registry_contracts.rs +++ b/sdk/rust/tests/registry_contracts.rs @@ -7083,6 +7083,85 @@ fn grants_unshare_agent() { ); } #[test] +fn grants_invite() { + let value: clickhouse_loom::GrantsInviteInput = serde_json::from_str( + "{\"org\":\"sample\",\"namespace\":\"sample\",\"to\":\"sample\",\"role\":\"viewer\"}", + ) + .unwrap(); + let encoded = serde_json::to_value(value).unwrap(); + assert!(encoded.is_object()); + let value: clickhouse_loom::GrantsInviteOutput = + serde_json::from_str("{\"outcome\":\"granted\",\"role\":\"viewer\"}").unwrap(); + let encoded = serde_json::to_value(value).unwrap(); + assert!(encoded.is_object()); + assert_eq!( + encoded["subject"], + serde_json::from_str::("\"\"").unwrap(), + "grants.invite:subject" + ); + assert_eq!( + encoded["invite_id"], + serde_json::from_str::("\"\"").unwrap(), + "grants.invite:invite_id" + ); + assert_eq!( + encoded["link_path"], + serde_json::from_str::("\"\"").unwrap(), + "grants.invite:link_path" + ); + assert_eq!( + encoded["url"], + serde_json::from_str::("\"\"").unwrap(), + "grants.invite:url" + ); + assert_eq!( + encoded["expires_at"], + serde_json::from_str::("null").unwrap(), + "grants.invite:expires_at" + ); + assert_eq!( + encoded["emailed"], + serde_json::from_str::("false").unwrap(), + "grants.invite:emailed" + ); +} +#[test] +fn grants_list_invites() { + let value: clickhouse_loom::GrantsListInvitesInput = + serde_json::from_str("{\"org\":\"sample\",\"namespace\":\"sample\"}").unwrap(); + let encoded = serde_json::to_value(value).unwrap(); + assert!(encoded.is_object()); + let value: clickhouse_loom::GrantsListInvitesOutput = + serde_json::from_str("{\"rows\":[]}").unwrap(); + let encoded = serde_json::to_value(value).unwrap(); + assert!(encoded.is_object()); +} +#[test] +fn grants_cancel_invite() { + let value: clickhouse_loom::GrantsCancelInviteInput = serde_json::from_str( + "{\"org\":\"sample\",\"namespace\":\"sample\",\"invite_id\":\"sample\"}", + ) + .unwrap(); + let encoded = serde_json::to_value(value).unwrap(); + assert!(encoded.is_object()); + let value: clickhouse_loom::GrantsCancelInviteOutput = + serde_json::from_str("{\"cancelled\":false}").unwrap(); + let encoded = serde_json::to_value(value).unwrap(); + assert!(encoded.is_object()); +} +#[test] +fn grants_accept_invite() { + let value: clickhouse_loom::GrantsAcceptInviteInput = + serde_json::from_str("{\"org\":\"sample\",\"namespace\":\"sample\",\"secret\":\"sample\"}") + .unwrap(); + let encoded = serde_json::to_value(value).unwrap(); + assert!(encoded.is_object()); + let value: clickhouse_loom::GrantsAcceptInviteOutput = + serde_json::from_str("{\"namespace\":\"sample\",\"role\":\"viewer\"}").unwrap(); + let encoded = serde_json::to_value(value).unwrap(); + assert!(encoded.is_object()); +} +#[test] fn collection_budget_set() { let value: clickhouse_loom::CollectionBudgetSetInput = serde_json::from_str("{\"org\":\"sample\",\"namespace\":\"sample\"}").unwrap(); diff --git a/sdk/typescript/src/generated/ops.ts b/sdk/typescript/src/generated/ops.ts index 2a902220d20..90e63ce9f2a 100644 --- a/sdk/typescript/src/generated/ops.ts +++ b/sdk/typescript/src/generated/ops.ts @@ -3286,6 +3286,17 @@ export interface FactsTraverseOutput { hubs?: string[]; } +export interface GrantsAcceptInviteInput { + org: string; + namespace: string; + secret: string; +} + +export interface GrantsAcceptInviteOutput { + namespace: string; + role: "viewer" | "writer" | "admin"; +} + export interface GrantsApproveInput { org: string; namespace: string; @@ -3302,6 +3313,16 @@ export interface GrantsApproveOutput { decided_at: string; // date-time } +export interface GrantsCancelInviteInput { + org: string; + namespace: string; + invite_id: string; +} + +export interface GrantsCancelInviteOutput { + cancelled: boolean; +} + export interface GrantsCreateInput { org: string; namespace: string; @@ -3319,6 +3340,24 @@ export interface GrantsCreateOutput { granted_at: string; // date-time } +export interface GrantsInviteInput { + org: string; + namespace: string; + to: string; + role: "viewer" | "writer" | "admin"; +} + +export interface GrantsInviteOutput { + outcome: "granted" | "invited"; + role: "viewer" | "writer" | "admin"; + subject?: string; + invite_id?: string; + link_path?: string; + url?: string; + expires_at?: string | null; + emailed?: boolean; +} + export interface GrantsListInput { org: string; namespace: string; @@ -3344,6 +3383,24 @@ export interface GrantsListOutput { truncated?: boolean; } +export interface GrantsListInvitesInput { + org: string; + namespace: string; +} + +export interface InviteEntry { + invite_id: string; + email: string; + role: "viewer" | "writer" | "admin"; + created_by: string; + created_at: string; // date-time + expires_at: string; // date-time +} + +export interface GrantsListInvitesOutput { + rows: InviteEntry[]; +} + export interface GrantsPendingForMeInput { org: string; limit?: number; @@ -11160,9 +11217,13 @@ export type OpName = | "facts.path" | "facts.related" | "facts.traverse" + | "grants.accept_invite" | "grants.approve" + | "grants.cancel_invite" | "grants.create" + | "grants.invite" | "grants.list" + | "grants.list_invites" | "grants.pending_for_me" | "grants.revoke" | "grants.share_agent" @@ -11550,9 +11611,13 @@ export interface OpMap { "facts.path": { input: FactsPathInput; output: FactsPathOutput }; "facts.related": { input: FactsRelatedInput; output: FactsRelatedOutput }; "facts.traverse": { input: FactsTraverseInput; output: FactsTraverseOutput }; + "grants.accept_invite": { input: GrantsAcceptInviteInput; output: GrantsAcceptInviteOutput }; "grants.approve": { input: GrantsApproveInput; output: GrantsApproveOutput }; + "grants.cancel_invite": { input: GrantsCancelInviteInput; output: GrantsCancelInviteOutput }; "grants.create": { input: GrantsCreateInput; output: GrantsCreateOutput }; + "grants.invite": { input: GrantsInviteInput; output: GrantsInviteOutput }; "grants.list": { input: GrantsListInput; output: GrantsListOutput }; + "grants.list_invites": { input: GrantsListInvitesInput; output: GrantsListInvitesOutput }; "grants.pending_for_me": { input: GrantsPendingForMeInput; output: GrantsPendingForMeOutput }; "grants.revoke": { input: GrantsRevokeInput; output: GrantsRevokeOutput }; "grants.share_agent": { input: GrantsShareAgentInput; output: GrantsShareAgentOutput }; @@ -11940,9 +12005,13 @@ export const OPS: readonly OpSpec[] = [ { name: "facts.path", group: "facts", method: "path", idempotent: true, role: "viewer", maturity: "experimental", budgetP99Ms: 250, audit: false, readOnly: true }, { name: "facts.related", group: "facts", method: "related", idempotent: true, role: "viewer", maturity: "experimental", budgetP99Ms: 60, audit: false, readOnly: true }, { name: "facts.traverse", group: "facts", method: "traverse", idempotent: true, role: "viewer", maturity: "stable", budgetP99Ms: 200, audit: false, readOnly: true }, + { name: "grants.accept_invite", group: "grants", method: "acceptInvite", idempotent: false, role: "viewer", maturity: "experimental", budgetP99Ms: 150, audit: true, readOnly: false }, { name: "grants.approve", group: "grants", method: "approve", idempotent: true, role: "admin", maturity: "experimental", budgetP99Ms: 80, audit: true, readOnly: false }, + { name: "grants.cancel_invite", group: "grants", method: "cancelInvite", idempotent: true, role: "admin", maturity: "experimental", budgetP99Ms: 80, audit: true, readOnly: false }, { name: "grants.create", group: "grants", method: "create", idempotent: true, role: "admin", maturity: "stable", budgetP99Ms: 50, audit: true, readOnly: false }, + { name: "grants.invite", group: "grants", method: "invite", idempotent: false, role: "admin", maturity: "experimental", budgetP99Ms: 3000, audit: true, readOnly: false }, { name: "grants.list", group: "grants", method: "list", idempotent: true, role: "viewer", maturity: "stable", budgetP99Ms: 80, audit: false, readOnly: true }, + { name: "grants.list_invites", group: "grants", method: "listInvites", idempotent: true, role: "admin", maturity: "experimental", budgetP99Ms: 80, audit: false, readOnly: false }, { name: "grants.pending_for_me", group: "grants", method: "pendingForMe", idempotent: true, role: "viewer", maturity: "experimental", budgetP99Ms: 150, audit: false, readOnly: true }, { name: "grants.revoke", group: "grants", method: "revoke", idempotent: true, role: "admin", maturity: "experimental", budgetP99Ms: 80, audit: true, readOnly: false }, { name: "grants.share_agent", group: "grants", method: "shareAgent", idempotent: true, role: "writer", maturity: "experimental", budgetP99Ms: 80, audit: true, readOnly: false }, @@ -12219,4 +12288,4 @@ export const OP_BY_NAME: Readonly> = Object.fromEntries( OPS.map((o) => [o.name, o]), ) as Readonly>; -export const GENERATED_OP_COUNT = 387; +export const GENERATED_OP_COUNT = 391; diff --git a/server/identity/domain/invites.py b/server/identity/domain/invites.py index 1247de0e653..3af6828232f 100644 --- a/server/identity/domain/invites.py +++ b/server/identity/domain/invites.py @@ -12,7 +12,7 @@ from dataclasses import asdict, dataclass, replace from datetime import datetime from typing import Any, Literal -from urllib.parse import quote +from urllib.parse import urlencode from server.core.datetimes import as_aware_utc @@ -31,9 +31,9 @@ def invite_id(secret: str) -> str: def link_path(org: str, namespace: str, secret: str) -> str: - """The dashboard path that accepts it. The secret is the fragment, which a browser - never sends to a server or puts in a Referer.""" - return f"/invite?org={quote(org, safe='')}&namespace={quote(namespace, safe='')}#{secret}" + """The dashboard page that accepts it, Namespaces in your org. All of it is the + fragment, which a browser never sends to a server or puts in a Referer.""" + return "/spaces#" + urlencode({"invite": secret, "org": org, "namespace": namespace}) @dataclass(frozen=True) diff --git a/server/operations/reach_manifest.py b/server/operations/reach_manifest.py index 450a0060efb..9beb21b4f9a 100644 --- a/server/operations/reach_manifest.py +++ b/server/operations/reach_manifest.py @@ -363,18 +363,34 @@ "sdk_method", "dashboard", ), + "grants.accept_invite": ( + "sdk_method", + "dashboard", + ), "grants.approve": ( "sdk_method", "dashboard", ), + "grants.cancel_invite": ( + "sdk_method", + "dashboard", + ), "grants.create": ( "sdk_method", "dashboard", ), + "grants.invite": ( + "sdk_method", + "dashboard", + ), "grants.list": ( "sdk_method", "dashboard", ), + "grants.list_invites": ( + "sdk_method", + "dashboard", + ), "grants.pending_for_me": ( "sdk_method", "dashboard", diff --git a/tests/integration/test_grants_invite.py b/tests/integration/test_grants_invite.py index e31f0f68242..82638de01b3 100644 --- a/tests/integration/test_grants_invite.py +++ b/tests/integration/test_grants_invite.py @@ -6,7 +6,7 @@ from __future__ import annotations import uuid -from urllib.parse import urlsplit +from urllib.parse import parse_qs, urlsplit import httpx @@ -54,7 +54,7 @@ def test_an_invited_email_is_accepted_once_under_the_accepters_handle( assert r.status_code == 200, r.text made = r.json() assert made["outcome"] == "invited" - secret = urlsplit(made["link_path"]).fragment + secret = parse_qs(urlsplit(made["link_path"]).fragment)["invite"][0] listed = _post(control_plane_url, admin, "grants.list_invites", {"org": org, "namespace": ns}) assert [row["email"] for row in listed.json()["rows"]] == ["michael@example.com"] diff --git a/tests/unit/test_grants_invite.py b/tests/unit/test_grants_invite.py index 965947eff30..6b8c06f6db1 100644 --- a/tests/unit/test_grants_invite.py +++ b/tests/unit/test_grants_invite.py @@ -61,7 +61,9 @@ async def get(org: str, namespace: str, invite_id: str, **_: Any) -> domain.Invi found = w.invites.get(invite_id) return found if found and (found.org, found.namespace) == (org, namespace) else None - async def open_on(org: str, namespace: str, now: int, limit: int, **_: Any) -> list[domain.Invite]: + async def open_on( + org: str, namespace: str, now: int, limit: int, **_: Any + ) -> list[domain.Invite]: return [i for i in w.invites.values() if i.is_open(now)][:limit] async def has_account(org: str, subject: str, **_: Any) -> bool: @@ -124,9 +126,10 @@ async def invite(to: str, role: str = "writer") -> Any: def secret_of(link_path: str) -> str: parts = urlsplit(link_path) - assert parts.path == "/invite" - assert parse_qs(parts.query) == {"org": ["o"], "namespace": ["ns"]} - return parts.fragment + assert (parts.path, parts.query) == ("/spaces", "") + fragment = parse_qs(parts.fragment) + assert (fragment["org"], fragment["namespace"]) == (["o"], ["ns"]) + return fragment["invite"][0] async def accept(secret: str) -> Any: From a795273f3fd86e7225a83fc91c59935ad45d20d6 Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Fri, 4 Dec 2026 21:16:07 +0530 Subject: [PATCH 03/28] dashboard: invitation result and open invitations components Co-Authored-By: Claude Opus 5.5 Signed-off-by: Lareb Zafar --- frontend/src/api/invites.ts | 7 ++ frontend/src/components/Invitations.test.tsx | 73 +++++++++++++++++ frontend/src/components/Invitations.tsx | 82 ++++++++++++++++++++ 3 files changed, 162 insertions(+) create mode 100644 frontend/src/components/Invitations.test.tsx create mode 100644 frontend/src/components/Invitations.tsx diff --git a/frontend/src/api/invites.ts b/frontend/src/api/invites.ts index 55a344a46bd..ee6feef1808 100644 --- a/frontend/src/api/invites.ts +++ b/frontend/src/api/invites.ts @@ -49,3 +49,10 @@ export function acceptInvite(id: Scope, secret: string): Promise<{ namespace: st export function inviteLink(r: Pick): string { return r.url || `${window.location.origin}${r.link_path}`; } + +/** A person's spelling, which `grants.invite` takes; a service account, a grant principal or + * everyone goes to `grants.create`, as the server's `has_aliases` and `is_reserved_subject` say. */ +export function isPersonSpelling(subject: string): boolean { + const last = subject.toLowerCase().split("/").pop() ?? ""; + return subject !== "*" && last !== "everyone" && !/^(sa|user|group|agent):/.test(last); +} diff --git a/frontend/src/components/Invitations.test.tsx b/frontend/src/components/Invitations.test.tsx new file mode 100644 index 00000000000..8f425353283 --- /dev/null +++ b/frontend/src/components/Invitations.test.tsx @@ -0,0 +1,73 @@ +import { cleanup, render, screen, waitFor } from "../test/rtl"; +import userEvent from "@testing-library/user-event"; +import { afterEach, describe, expect, it, vi } from "vitest"; +import { cancelInvite, isPersonSpelling, listInvites } from "../api/invites"; +import { InviteSent, OpenInvitations } from "./Invitations"; + +vi.mock("../api/invites", async (importOriginal) => { + const actual = await importOriginal(); + return { ...actual, listInvites: vi.fn(), cancelInvite: vi.fn(async () => ({ cancelled: true })) }; +}); +afterEach(() => cleanup()); + +const sent = { + outcome: "invited" as const, + role: "writer" as const, + subject: "", + invite_id: "abc", + link_path: "/spaces#invite=s3cret&org=dev&namespace=team", + url: "", + expires_at: "2026-12-11T12:00:00Z", + emailed: false, +}; + +describe("InviteSent", () => { + it("hands over the link on this page's address when the server knows none", () => { + render(); + expect(screen.getByRole("status")).toHaveTextContent("No account signs in as pat@example.com yet."); + expect( + screen.getByText(`${window.location.origin}/spaces#invite=s3cret&org=dev&namespace=team`), + ).toBeInTheDocument(); + }); + + it("says it was emailed, and still shows the server's link", () => { + render( + , + ); + expect(screen.getByRole("status")).toHaveTextContent("Emailed an invitation to pat@example.com."); + expect(screen.getByText("https://loom.example.com/spaces#x")).toBeInTheDocument(); + }); +}); + +describe("OpenInvitations", () => { + it("lists the open invitations and cancels one", async () => { + vi.mocked(listInvites).mockResolvedValue({ + rows: [ + { + invite_id: "abc", + email: "pat@example.com", + role: "writer", + created_by: "ann", + created_at: "2026-12-04T12:00:00Z", + expires_at: "2026-12-11T12:00:00Z", + }, + ], + }); + const user = userEvent.setup(); + render(); + await user.click(await screen.findByRole("button", { name: "Cancel the invitation to pat@example.com" })); + expect(cancelInvite).toHaveBeenCalledWith({ org: "dev", namespace: "team" }, "abc"); + await waitFor(() => expect(screen.queryByRole("region", { name: "Open invitations" })).toBeNull()); + }); +}); + +describe("isPersonSpelling", () => { + it("tells a person from a principal", () => { + for (const s of ["mlex", "pat@example.com", "Pat"]) expect(isPersonSpelling(s)).toBe(true); + for (const s of ["sa:bot", "group:eng", "user:42", "agent:x", "everyone", "Everyone", "*", "acme/user:1"]) + expect(isPersonSpelling(s)).toBe(false); + }); +}); diff --git a/frontend/src/components/Invitations.tsx b/frontend/src/components/Invitations.tsx new file mode 100644 index 00000000000..e97793c82d1 --- /dev/null +++ b/frontend/src/components/Invitations.tsx @@ -0,0 +1,82 @@ +import { useEffect, useState } from "react"; +import { Button } from "@clickhouse/click-ui/Button"; +import { cancelInvite, inviteLink, listInvites, type InviteResult, type OpenInvite } from "../api/invites"; +import { absoluteTime, fmtInt } from "../lib/format"; +import { CopyButton } from "./CopyButton"; +import { toastError } from "./Toast"; + +type Scope = { org: string; namespace: string }; + +/** What an invitation by email did: the link, and whether the server emailed it. */ +export function InviteSent({ email, result }: { email: string; result: InviteResult }) { + const link = inviteLink(result); + return ( +
+

+ {result.emailed + ? `Emailed an invitation to ${email}. You can also send them this link:` + : `No account signs in as ${email} yet. Send them this link:`} +

+
+ {link} + +
+

+ It works once, until {absoluteTime(result.expires_at)}: whoever opens it signed in gets the role, under the + account they sign in with. +

+
+ ); +} + +/** The namespace's open invitations, each with Cancel; nothing while there are none. `version` + * changes to read them again after an invitation is made. */ +export function OpenInvitations({ scope, version }: { scope: Scope; version: number }) { + const [rows, setRows] = useState([]); + const [busy, setBusy] = useState(null); + useEffect(() => { + let live = true; + listInvites(scope) + .then((r) => live && setRows(r.rows)) + .catch(() => live && setRows([])); + return () => { + live = false; + }; + }, [scope.org, scope.namespace, version]); + if (rows.length === 0) return null; + + const cancel = async (row: OpenInvite) => { + setBusy(row.invite_id); + try { + await cancelInvite(scope, row.invite_id); + setRows((all) => all.filter((r) => r.invite_id !== row.invite_id)); + } catch (e) { + toastError("Couldn't cancel the invitation", e); + } finally { + setBusy(null); + } + }; + + return ( +
+
{`Invited (${fmtInt(rows.length)})`}
+
    + {rows.map((r) => ( +
  • + {r.email} + {`${r.role}, until ${absoluteTime(r.expires_at)}`} + +
  • + ))} +
+
+ ); +} From d701590cf077aca5d2d1d63f34bd56c3bab61a3d Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Fri, 4 Dec 2026 21:17:06 +0530 Subject: [PATCH 04/28] docs: list namespace_invites with the identity tables of the Postgres layout Co-Authored-By: Claude Opus 5.5 Signed-off-by: Lareb Zafar --- docs/architecture/storage-layout.md | 110 ++++++++++++++-------------- 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/docs/architecture/storage-layout.md b/docs/architecture/storage-layout.md index b15edd027b6..bd294138118 100644 --- a/docs/architecture/storage-layout.md +++ b/docs/architecture/storage-layout.md @@ -1195,61 +1195,61 @@ a row names a step today's ClickHouse census owns, the `pg:` census row is owned Postgres step the flip splits off it, which joins `PG_ONLY_STEPS` ([restores](#restores)). -| Table | Key | Kind | Erasure | -| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `authority` | [storage authority](storage-authority.md#the-tables); paired with ClickHouse's `storage_authority` | SoR | no content | -| `pg_migrations` | the migration file | SoR | no content | -| `scope_generations` | [storage authority](storage-authority.md#the-tables) | SoR (a namespace's row allocates its revision `seq`) | no content | -| `cache_generations` | `(org, kind)` | Coord | no content | -| `memory_current` | [storage authority](storage-authority.md#the-tables) | SoR | census `pg:loom.memory_current` | -| `memory_revisions` | [storage authority](storage-authority.md#the-tables) | SoR | census `pg:loom.memory_revisions` | -| `memory_refusals` | `(org, scope_kind, scope_value, user_id, kind, units, digest)` | SoR, hash-only consent policy committed beside memory; no TTL | no content; retained across erasure | -| `memory_deliveries` | [storage authority](storage-authority.md#the-tables) | SoR | cascades with its revision | -| `idempotency`, `idempotency_fences` | [storage authority](storage-authority.md#the-tables) | SoR | census `pg:loom.idempotency`; `idempotency_fences` holds no content (the census's bound) | -| `erased_memories`, `erased_documents` | [storage authority](storage-authority.md#the-tables) | SoR | evidence, no content | -| `audit_outbox` | [storage authority](storage-authority.md#the-tables) | SoR | keys and ids, no values | -| `document_catalog`, `document_uploaders` | `(org, namespace, sha256)`, `(org, user_id, namespace, sha256)` | SoR | a `pg:` census row each, owned by the Postgres step the flip splits off the steps that own the census rows of `document_blobs` and `blob_uploads` today, which joins `PG_ONLY_STEPS` (`documents.tombstone`, and the user step through `document_uploaders`) | -| `knowledge_datasets` | [storage authority](storage-authority.md#the-tables) | SoR | census `pg:loom.knowledge_datasets`, step `pg_knowledge.delete` | -| `knowledge_jobs` | [storage authority](storage-authority.md#the-tables) | SoR | census `pg:loom.knowledge_jobs`, step `pg_knowledge.delete` | -| `mcp_worker_enrollment_challenges` | `(org, nonce)` | SoR | one-time account enrollment challenges of a canonical sign-in owner (`subject`; `user_id` is `-`), erased with the collection or by the owner's deletion (`pg_mcp_worker_enrollment.erase_subject`), never by a user erasure; census `pg:loom.mcp_worker_enrollment_challenges`, namespace step `pg_knowledge.delete` | -| `mcp_worker_accounts` | `(org, connection_id)` | SoR | opaque connection bindings and revocation generations of a canonical sign-in owner (`subject`; `user_id` is `-`), one collection per connection, erased with the collection or by the owner's deletion (`pg_mcp_worker_enrollment.erase_subject`), never by a user erasure; census `pg:loom.mcp_worker_accounts`, namespace step `pg_knowledge.delete` | -| `mcp_worker_approvals` | `(org, namespace, worker_id, profile_digest)` | SoR | a collection's allowed modes and approval generations, naming no subject (`user_id` is `-`), erased with the collection; census `pg:loom.mcp_worker_approvals`, namespace step `pg_knowledge.delete` | -| `mcp_worker_source_readers` | `(org, namespace, source_id, subject)` | SoR | explicit team reader bindings of a canonical sign-in reader (`subject`; `user_id` is `-`), erased with the collection or by the reader's deletion (`pg_mcp_worker_enrollment.erase_subject`), never by a user erasure; census `pg:loom.mcp_worker_source_readers`, namespace step `pg_knowledge.delete` | -| `knowledge_heads`, `knowledge_deliveries` | [storage authority](storage-authority.md#the-tables) | SoR | census `pg:loom.knowledge_heads`, `pg:loom.knowledge_deliveries` | -| `jobs`, `job_users`, `job_memories` | `(org, id)`, `(org, user_id, job_id)`, `(org, namespace, memory_id, job_id)` | SoR | a census row, a step by namespace and user, a redaction step | -| `leases`, `write_marks`, `graph_inflight` | `(org, name)`, `(org, namespace, surface)`, `(org, namespace, token)` | Coord | no content | -| `cursors` | `(org, consumer, scope)` | SoR | no content | -| `carry_acks` | `process` | Coord | no content | -| `analysis_secrets` | `id` | SoR | no content | -| `sql_access` | `(org, namespace, user_name)` | SoR | no content | -| `cell_self` | singleton | SoR until attach writes its fingerprint to the directory row, then Derived (rewritten from the directory on a restore, [cells](cells.md)) | no content | -| `tenancy` | `org` | SoR until attach places its org (the first cell's `recording` rows), then Derived (written back from the directory's placements on a restore, never deleted, [cells](cells.md)) | no content; an erasure leaves the org's row | -| `tenancy_mode` | singleton | Derived (the mode raised only upward from the directory's recorded mode on a restore, [cells](cells.md)) | no content | -| `cell_first` | singleton | Derived (written when absent and refused when it differs on a restore; written once, its update, delete and truncate refused by triggers, [cells](cells.md)) | no content | -| `cell_probe` (the probe nonce the `loom cell` commands write, [cells](cells.md)) | `name` | Coord | no content; deleted once the probe has read it | -| `job_parts` | `(org, job_id, seq)` | SoR | cascades with its job; `code_index.purge` reaches it through the job | -| `idempotency_revisions` | `(org, key_hash, namespace, seq)` | SoR | cascades with its record; redaction reaches replay answers through it | -| `revision_relations` | `(org, namespace, seq, ord)` | SoR | census `pg:loom.revision_relations`, step `pg_memory.delete`; cascades with its revision; redaction reaches it through its revision | -| `revision_sources` | `(org, user_id, namespace, seq)` | SoR | cascades with its revision; the user step deletes the user's rows; the user step and the census reach shared revisions through it | -| `table_moves`, `move_acks` | `move`, `(move, process)` | SoR, Coord | no content; `table_moves` also holds the registry of kept tables (each kept table's name and scope predicates) | -| `backfill_steps` | the column, index or check it sets | SoR | no content; the backfill step's completion record, which boots read ([schema rules](#postgres)) | -| `working_memory`, `records`, `operator_edges`, `context_offloads`, `session_briefs`, `session_brief_revisions`, `namespace_guides`, `learning_candidates`, `learning_supporters`, `conflict_allowlist` | led by `(org, namespace, …)`, the ClickHouse sort key today | SoR | a census row and a saga step each | -| `conversation_states` | `(org, namespace, agent, thread_id, msg_id)` | SoR | a census row and the `conversations.tombstone` step, by namespace and by the saver's `user_id` | -| `offload_bytes` | `(org, namespace, offload_id, part)`, its head's id and a part number | SoR | deleted with its head by the `context_offloads` step, and counted by its census row | -| `shared_current` | `(org, namespace, memory_key)` | SoR | a `pg:` census row and the provenance step `shared` has today, through `revision_sources` | -| `tasks`, `agent_runs` | `(org, inbox, task_id)`, `(org, namespace, run_id)` | SoR | a `pg:` census row each, owned by the Postgres step the flip splits off the step that owns its ClickHouse table's census row today, which joins `PG_ONLY_STEPS` (`tasks` in the namespace scope, `agent_runs` in both) | -| `task_inboxes`, `task_poster_policies` | `(org, inbox)`, `(org, inbox, poster, kind)` | SoR | no content | -| `erased_messages` | `(org, erasure_id, namespace, agent, thread_id, msg_id)` | SoR | evidence, no content; the messages a conversation erasure matched by their saver, which its ClickHouse replay reads, swept with its `erasure_ledger` row | -| `erasure_ledger` | [storage authority](storage-authority.md#the-tables) | SoR | evidence, no content; Postgres's erasure record, which `loom reconcile` runs again after a ClickHouse restore, swept after `erasure_ledger_days` | -| `record_schemas`, `namespace_visits`, `extraction_policies`, `namespace_policies`, `namespace_types`, `namespace_ontology`, `profile_schemas`, `user_state`, `webhooks`, `knowledge_sources`, `knowledge_mirrors`, `code_repos`, `qa_sources` | led by `org`, as the ClickHouse key | SoR | no memory content | -| `knowledge_uploads` | led by `org`, as the ClickHouse key | SoR | a `pg:` census row owned by the Postgres step split off `documents.tombstone` ([restores](#restores)) | -| `code_coverage_watches` | led by `org`, as the ClickHouse key | SoR | no memory content; reached by the Postgres part of `code_index.purge` ([restores](#restores)) | -| `revoked_tokens` | `(kind, key)`, kind `subject_or_jti` (the bare key, which holds both today), `cutoff` or `scim` | SoR | no content | -| `signing_keys`, `service_accounts`, `machine_identities`, `scim_users`, `sso_links`, `principal_groups`, `oauth_state`, `oauth_signin_state`, `namespace_grants`, `namespaces`, `collections`, `blacklist`, `org_model_calls` | as the ClickHouse key, `org` first where the table is per org, except the tables of the cell that [keys lead with `org`](#postgres) names | SoR | no memory content; the identity steps (`grants.revoke`, `groups.remove_member`, `personal.retire`, `collections.forget_owner`) rewrite `namespace_grants`, `principal_groups`, `namespaces` and `collections` | -| `auth_attempts` | kind, hashed key and window | Coord | no content | -| `deployment_config`, `runtime_overrides`, `provider_configuration`, `assistant_service` | as the ClickHouse key | SoR | no content | -| `instances` | process | Coord | no content | -| `embedder_calibration`, `namespace_calibration` | as the ClickHouse key, `org` first for `namespace_calibration` | Derived (rebuilt by a recalibration, at embedding cost) | no content | +| Table | Key | Kind | Erasure | +| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `authority` | [storage authority](storage-authority.md#the-tables); paired with ClickHouse's `storage_authority` | SoR | no content | +| `pg_migrations` | the migration file | SoR | no content | +| `scope_generations` | [storage authority](storage-authority.md#the-tables) | SoR (a namespace's row allocates its revision `seq`) | no content | +| `cache_generations` | `(org, kind)` | Coord | no content | +| `memory_current` | [storage authority](storage-authority.md#the-tables) | SoR | census `pg:loom.memory_current` | +| `memory_revisions` | [storage authority](storage-authority.md#the-tables) | SoR | census `pg:loom.memory_revisions` | +| `memory_refusals` | `(org, scope_kind, scope_value, user_id, kind, units, digest)` | SoR, hash-only consent policy committed beside memory; no TTL | no content; retained across erasure | +| `memory_deliveries` | [storage authority](storage-authority.md#the-tables) | SoR | cascades with its revision | +| `idempotency`, `idempotency_fences` | [storage authority](storage-authority.md#the-tables) | SoR | census `pg:loom.idempotency`; `idempotency_fences` holds no content (the census's bound) | +| `erased_memories`, `erased_documents` | [storage authority](storage-authority.md#the-tables) | SoR | evidence, no content | +| `audit_outbox` | [storage authority](storage-authority.md#the-tables) | SoR | keys and ids, no values | +| `document_catalog`, `document_uploaders` | `(org, namespace, sha256)`, `(org, user_id, namespace, sha256)` | SoR | a `pg:` census row each, owned by the Postgres step the flip splits off the steps that own the census rows of `document_blobs` and `blob_uploads` today, which joins `PG_ONLY_STEPS` (`documents.tombstone`, and the user step through `document_uploaders`) | +| `knowledge_datasets` | [storage authority](storage-authority.md#the-tables) | SoR | census `pg:loom.knowledge_datasets`, step `pg_knowledge.delete` | +| `knowledge_jobs` | [storage authority](storage-authority.md#the-tables) | SoR | census `pg:loom.knowledge_jobs`, step `pg_knowledge.delete` | +| `mcp_worker_enrollment_challenges` | `(org, nonce)` | SoR | one-time account enrollment challenges of a canonical sign-in owner (`subject`; `user_id` is `-`), erased with the collection or by the owner's deletion (`pg_mcp_worker_enrollment.erase_subject`), never by a user erasure; census `pg:loom.mcp_worker_enrollment_challenges`, namespace step `pg_knowledge.delete` | +| `mcp_worker_accounts` | `(org, connection_id)` | SoR | opaque connection bindings and revocation generations of a canonical sign-in owner (`subject`; `user_id` is `-`), one collection per connection, erased with the collection or by the owner's deletion (`pg_mcp_worker_enrollment.erase_subject`), never by a user erasure; census `pg:loom.mcp_worker_accounts`, namespace step `pg_knowledge.delete` | +| `mcp_worker_approvals` | `(org, namespace, worker_id, profile_digest)` | SoR | a collection's allowed modes and approval generations, naming no subject (`user_id` is `-`), erased with the collection; census `pg:loom.mcp_worker_approvals`, namespace step `pg_knowledge.delete` | +| `mcp_worker_source_readers` | `(org, namespace, source_id, subject)` | SoR | explicit team reader bindings of a canonical sign-in reader (`subject`; `user_id` is `-`), erased with the collection or by the reader's deletion (`pg_mcp_worker_enrollment.erase_subject`), never by a user erasure; census `pg:loom.mcp_worker_source_readers`, namespace step `pg_knowledge.delete` | +| `knowledge_heads`, `knowledge_deliveries` | [storage authority](storage-authority.md#the-tables) | SoR | census `pg:loom.knowledge_heads`, `pg:loom.knowledge_deliveries` | +| `jobs`, `job_users`, `job_memories` | `(org, id)`, `(org, user_id, job_id)`, `(org, namespace, memory_id, job_id)` | SoR | a census row, a step by namespace and user, a redaction step | +| `leases`, `write_marks`, `graph_inflight` | `(org, name)`, `(org, namespace, surface)`, `(org, namespace, token)` | Coord | no content | +| `cursors` | `(org, consumer, scope)` | SoR | no content | +| `carry_acks` | `process` | Coord | no content | +| `analysis_secrets` | `id` | SoR | no content | +| `sql_access` | `(org, namespace, user_name)` | SoR | no content | +| `cell_self` | singleton | SoR until attach writes its fingerprint to the directory row, then Derived (rewritten from the directory on a restore, [cells](cells.md)) | no content | +| `tenancy` | `org` | SoR until attach places its org (the first cell's `recording` rows), then Derived (written back from the directory's placements on a restore, never deleted, [cells](cells.md)) | no content; an erasure leaves the org's row | +| `tenancy_mode` | singleton | Derived (the mode raised only upward from the directory's recorded mode on a restore, [cells](cells.md)) | no content | +| `cell_first` | singleton | Derived (written when absent and refused when it differs on a restore; written once, its update, delete and truncate refused by triggers, [cells](cells.md)) | no content | +| `cell_probe` (the probe nonce the `loom cell` commands write, [cells](cells.md)) | `name` | Coord | no content; deleted once the probe has read it | +| `job_parts` | `(org, job_id, seq)` | SoR | cascades with its job; `code_index.purge` reaches it through the job | +| `idempotency_revisions` | `(org, key_hash, namespace, seq)` | SoR | cascades with its record; redaction reaches replay answers through it | +| `revision_relations` | `(org, namespace, seq, ord)` | SoR | census `pg:loom.revision_relations`, step `pg_memory.delete`; cascades with its revision; redaction reaches it through its revision | +| `revision_sources` | `(org, user_id, namespace, seq)` | SoR | cascades with its revision; the user step deletes the user's rows; the user step and the census reach shared revisions through it | +| `table_moves`, `move_acks` | `move`, `(move, process)` | SoR, Coord | no content; `table_moves` also holds the registry of kept tables (each kept table's name and scope predicates) | +| `backfill_steps` | the column, index or check it sets | SoR | no content; the backfill step's completion record, which boots read ([schema rules](#postgres)) | +| `working_memory`, `records`, `operator_edges`, `context_offloads`, `session_briefs`, `session_brief_revisions`, `namespace_guides`, `learning_candidates`, `learning_supporters`, `conflict_allowlist` | led by `(org, namespace, …)`, the ClickHouse sort key today | SoR | a census row and a saga step each | +| `conversation_states` | `(org, namespace, agent, thread_id, msg_id)` | SoR | a census row and the `conversations.tombstone` step, by namespace and by the saver's `user_id` | +| `offload_bytes` | `(org, namespace, offload_id, part)`, its head's id and a part number | SoR | deleted with its head by the `context_offloads` step, and counted by its census row | +| `shared_current` | `(org, namespace, memory_key)` | SoR | a `pg:` census row and the provenance step `shared` has today, through `revision_sources` | +| `tasks`, `agent_runs` | `(org, inbox, task_id)`, `(org, namespace, run_id)` | SoR | a `pg:` census row each, owned by the Postgres step the flip splits off the step that owns its ClickHouse table's census row today, which joins `PG_ONLY_STEPS` (`tasks` in the namespace scope, `agent_runs` in both) | +| `task_inboxes`, `task_poster_policies` | `(org, inbox)`, `(org, inbox, poster, kind)` | SoR | no content | +| `erased_messages` | `(org, erasure_id, namespace, agent, thread_id, msg_id)` | SoR | evidence, no content; the messages a conversation erasure matched by their saver, which its ClickHouse replay reads, swept with its `erasure_ledger` row | +| `erasure_ledger` | [storage authority](storage-authority.md#the-tables) | SoR | evidence, no content; Postgres's erasure record, which `loom reconcile` runs again after a ClickHouse restore, swept after `erasure_ledger_days` | +| `record_schemas`, `namespace_visits`, `extraction_policies`, `namespace_policies`, `namespace_types`, `namespace_ontology`, `profile_schemas`, `user_state`, `webhooks`, `knowledge_sources`, `knowledge_mirrors`, `code_repos`, `qa_sources` | led by `org`, as the ClickHouse key | SoR | no memory content | +| `knowledge_uploads` | led by `org`, as the ClickHouse key | SoR | a `pg:` census row owned by the Postgres step split off `documents.tombstone` ([restores](#restores)) | +| `code_coverage_watches` | led by `org`, as the ClickHouse key | SoR | no memory content; reached by the Postgres part of `code_index.purge` ([restores](#restores)) | +| `revoked_tokens` | `(kind, key)`, kind `subject_or_jti` (the bare key, which holds both today), `cutoff` or `scim` | SoR | no content | +| `signing_keys`, `service_accounts`, `machine_identities`, `scim_users`, `sso_links`, `principal_groups`, `oauth_state`, `oauth_signin_state`, `namespace_grants`, `namespace_invites`, `namespaces`, `collections`, `blacklist`, `org_model_calls` | as the ClickHouse key, `org` first where the table is per org, except the tables of the cell that [keys lead with `org`](#postgres) names | SoR | no memory content; the identity steps (`grants.revoke`, `groups.remove_member`, `personal.retire`, `collections.forget_owner`) rewrite `namespace_grants`, `principal_groups`, `namespaces` and `collections` | +| `auth_attempts` | kind, hashed key and window | Coord | no content | +| `deployment_config`, `runtime_overrides`, `provider_configuration`, `assistant_service` | as the ClickHouse key | SoR | no content | +| `instances` | process | Coord | no content | +| `embedder_calibration`, `namespace_calibration` | as the ClickHouse key, `org` first for `namespace_calibration` | Derived (rebuilt by a recalibration, at embedding cost) | no content | A sweep deletes a `revoked_tokens` row ten days past its stored `expires_at`, as the ClickHouse TTL does today; a token without `exp`, an operator cutoff and every SCIM From a81aa67b78bdab9279db4bfd881795dbb7926c34 Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Fri, 4 Dec 2026 21:19:07 +0530 Subject: [PATCH 05/28] grants: limit invitation emails per inviter and per address Co-Authored-By: Claude Opus 5.5 Signed-off-by: Lareb Zafar --- docs/architecture/sharing.md | 5 +++++ server/identity/app/invites.py | 18 ++++++++++++++- tests/unit/test_grants_invite.py | 38 ++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) diff --git a/docs/architecture/sharing.md b/docs/architecture/sharing.md index 5231bc7fbac..3984c8c72e9 100644 --- a/docs/architecture/sharing.md +++ b/docs/architecture/sharing.md @@ -206,6 +206,11 @@ the link works once, for seven days. The server emails it when `smtp_url`, `mail for the admin to pass on. A handle no account holds is refused with 404, so a typo is never kept as a grant for whoever signs up under that handle later. +The server's mail is no relay for a namespace admin, whom any sign-up can make: it emails +at most 20 invitations an hour per inviter and 3 a day per address, counted in +`loom.auth_attempts` across the deployment (`server.auth.attempts`). Past either limit +the invitation is still made, and its link is the inviter's to pass on. + `grants.accept_invite` gives the invitation's role to the signed-in caller, under the handle they sign in with, stamped `granted_by` the invitation's maker. Only a person's token accepts: a service account, a grant principal or a token of another org is refused. diff --git a/server/identity/app/invites.py b/server/identity/app/invites.py index 0daa15317a5..a290b471bc0 100644 --- a/server/identity/app/invites.py +++ b/server/identity/app/invites.py @@ -17,6 +17,7 @@ import time from datetime import UTC, datetime +from server.auth.attempts import Attempts from server.auth.grant_claims import invite_change from server.core.errors import GrantWouldDowngradeError, NotFoundError, ValidationError from server.core.principals import SERVICE_ACCOUNT, has_aliases, is_reserved_subject @@ -46,6 +47,11 @@ # The open invitations a namespace lists. _LISTED = 200 +# Invitation emails, so that the server's mail is no relay for a namespace admin (whom any +# sign-up can make): per inviter, and per address invited. Past either the invitation is +# still made, and its link is the inviter's to pass on. +_mail_by_inviter = Attempts("invite.mail.inviter", 20, 3600) +_mail_by_address = Attempts("invite.mail.address", 3, 86400) _EMAIL = re.compile(r"[^@\s]+@[^@\s]+\.[^@\s]+") _GONE = "this invitation link is used, cancelled or expired: ask for a new one" @@ -123,7 +129,9 @@ async def _invite(input: GrantsInviteInput, email: str) -> GrantsInviteOutput: path = domain.link_path(input.org, input.namespace, secret) base = settings.public_base_url.strip().rstrip("/") url = f"{base}{path}" if base else "" - emailed = await invite_mail.send_invite( + emailed = await _may_mail( + input.org, invite.created_by, email + ) and await invite_mail.send_invite( email, inviter=invite.created_by, namespace=input.namespace, @@ -142,6 +150,14 @@ async def _invite(input: GrantsInviteInput, email: str) -> GrantsInviteOutput: ) +async def _may_mail(org: str, inviter: str, email: str) -> bool: + """Whether this invitation may be emailed: the server sends mail, and neither the + inviter nor the address is past its limit.""" + if not invite_mail.can_send(): + return False + return await _mail_by_inviter.allow(f"{org}/{inviter}") and await _mail_by_address.allow(email) + + async def handle_grants_list_invites(input: GrantsListInvitesInput) -> GrantsListInvitesOutput: rows = await invites_repo.open_on(input.org, input.namespace, int(time.time()), _LISTED) return GrantsListInvitesOutput( diff --git a/tests/unit/test_grants_invite.py b/tests/unit/test_grants_invite.py index 6b8c06f6db1..59b94e3874b 100644 --- a/tests/unit/test_grants_invite.py +++ b/tests/unit/test_grants_invite.py @@ -47,6 +47,7 @@ def __init__(self) -> None: self.grants: list[tuple[GrantsCreateInput, str | None]] = [] self.grant_error: BaseException | None = None self.mail: list[dict[str, Any]] = [] + self.may_mail = True @pytest.fixture @@ -101,6 +102,11 @@ async def send(to: str, **kw: Any) -> bool: monkeypatch.setattr(mod, "_enforce_code_ceiling", no_ceiling) monkeypatch.setattr(mod, "invite_change", claimed) monkeypatch.setattr(mod.invite_mail, "send_invite", send) + + async def may_mail(*_a: Any) -> bool: + return w.may_mail + + monkeypatch.setattr(mod, "_may_mail", may_mail) signed_in("admin-ann") yield w set_current_auth(None) @@ -187,6 +193,38 @@ async def test_an_email_no_account_holds_gets_a_link_kept_only_as_its_hash(world assert [r.email for r in listed.rows] == ["michael@example.com"] +@pytest.mark.asyncio +async def test_past_the_mail_limits_the_link_is_still_made_and_not_emailed(world: World) -> None: + world.may_mail = False + out = await invite("michael@example.com") + assert (out.outcome, out.emailed, world.mail) == ("invited", False, []) + assert out.invite_id in world.invites + + +@pytest.mark.asyncio +async def test_mail_waits_for_the_settings_then_counts_inviter_and_address( + monkeypatch: pytest.MonkeyPatch, +) -> None: + asked: list[tuple[str, str]] = [] + + class Gate: + def __init__(self, name: str, answer: bool) -> None: + self.name, self.answer = name, answer + + async def allow(self, key: str) -> bool: + asked.append((self.name, key)) + return self.answer + + monkeypatch.setattr(mod, "_mail_by_inviter", Gate("inviter", True)) + monkeypatch.setattr(mod, "_mail_by_address", Gate("address", False)) + monkeypatch.setattr(invite_mail, "can_send", lambda: False) + assert await mod._may_mail("o", "ann", "m@example.com") is False + assert asked == [] + monkeypatch.setattr(invite_mail, "can_send", lambda: True) + assert await mod._may_mail("o", "ann", "m@example.com") is False + assert asked == [("inviter", "o/ann"), ("address", "m@example.com")] + + @pytest.mark.asyncio async def test_the_link_lets_one_person_in_once_as_granted_by_its_maker(world: World) -> None: secret = secret_of((await invite("michael@example.com")).link_path) From 4bfde3d34b2962bd0b5161549e9e321b62c8620f Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Fri, 4 Dec 2026 21:30:18 +0530 Subject: [PATCH 06/28] settings: an invitation link's lifetime and the mail server timeout Co-Authored-By: Claude Opus 5.5 Signed-off-by: Lareb Zafar --- docs/architecture/sharing.md | 2 +- docs/features/namespaces-and-sharing.md | 2 +- docs/reference/configuration.md | 2 ++ loom.example.yaml | 8 ++++++++ schemas/loom-settings.schema.json | 14 ++++++++++++++ server/identity/app/invite_mail.py | 8 ++++---- server/identity/app/invites.py | 2 +- server/identity/domain/invites.py | 3 --- server/settings/catalog.py | 5 +++++ tests/unit/test_grants_invite.py | 2 +- 10 files changed, 37 insertions(+), 11 deletions(-) diff --git a/docs/architecture/sharing.md b/docs/architecture/sharing.md index 3984c8c72e9..041a09b0bbb 100644 --- a/docs/architecture/sharing.md +++ b/docs/architecture/sharing.md @@ -201,7 +201,7 @@ account signs in under, or an email verified for one (an SSO account or an `sso_ row), is granted at once through `grants.create`. Any other email gets an invitation: a `loom.namespace_invites` row and the link `/spaces#invite=&org=…&namespace=…`. The link is the credential. Only the secret's SHA-256 is stored, as the row's `invite_id`, and -the link works once, for seven days. The server emails it when `smtp_url`, `mail_from` and +the link works once, for seven days by default (`invite_ttl_seconds`). The server emails it when `smtp_url`, `mail_from` and `public_base_url` are set; otherwise, or when the send fails, the answer carries the link for the admin to pass on. A handle no account holds is refused with 404, so a typo is never kept as a grant for whoever signs up under that handle later. diff --git a/docs/features/namespaces-and-sharing.md b/docs/features/namespaces-and-sharing.md index 523fec50eb0..4936f290de0 100644 --- a/docs/features/namespaces-and-sharing.md +++ b/docs/features/namespaces-and-sharing.md @@ -89,7 +89,7 @@ namespaces it may reach; the grant table decides the role. A password account's email is never verified, so a grant by email reaches such an account only through an invitation. The link is `/spaces#invite=…` on the dashboard, works -once within seven days, and gives its role to whoever opens it signed in, under their own +once, within seven days by default (`LOOM_INVITE_TTL_SECONDS`), and gives its role to whoever opens it signed in, under their own login handle, as granted by the admin who made it. To have the server email it, set `LOOM_SMTP_URL` (`smtps://user:password@host:465`, or `smtp://…:587` with STARTTLS), `LOOM_MAIL_FROM` and `LOOM_PUBLIC_BASE_URL`; without them, or when a send fails, the diff --git a/docs/reference/configuration.md b/docs/reference/configuration.md index 7b6b611e85f..b932d379785 100644 --- a/docs/reference/configuration.md +++ b/docs/reference/configuration.md @@ -138,6 +138,8 @@ Authentication, tokens and identity providers. | `LOOM_SELF_SIGNUP_ORG` | `str` | `'dev'` | | Default org for self-signed tokens. | | `LOOM_SMTP_URL` | `str` | *(unset)* | | The mail server an invitation is emailed through: `smtps://user:password@host:465` (TLS from the start) or `smtp://user:password@host:587` (STARTTLS, which a login requires). Empty: no email is sent, and whoever makes an invitation sends its link. | | `LOOM_MAIL_FROM` | `str` | `''` | | The From address of an invitation email, e.g. `Loom `. Empty sends none, as does an empty smtp_url or public_base_url (the link needs it). | +| `LOOM_SMTP_TIMEOUT_SECONDS` | `float` | `10.0` | | Seconds to wait on the mail server for one invitation email; past it the email is reported not sent, and the link is shown to pass on. | +| `LOOM_INVITE_TTL_SECONDS` | `int` | `604800` | | Seconds an invitation link stays valid, at most 30 days: it admits whoever opens it. | | `LOOM_IDENTITY_PROVIDER` | `'' \| 'single-user' \| 'trust-network' \| 'gateway'` | `''` | | How callers authenticate: "single-user" (no auth, one anonymous identity), "trust-network" (self-signup, first claim wins) or "gateway" (an upstream proxy mints short-lived Loom JWTs with the shared HS256 secret; Loom only validates). Empty = inferred from auth_required and self_signup at boot. | | `LOOM_DASHBOARD_REDIRECT_URL` | `str` | `''` | | When set, a dashboard page load redirects (302) here instead of serving the SPA (Loom behind an aggregator). Deployment-specific; never hardcode. | | `LOOM_TRUSTED_CALLERS` | `str` | `''` | | Comma-separated subjects allowed to send `X-Loom-On-Behalf-Of` (a trusted aggregator passing each end-user's identity under one service token). Empty disables the header. | diff --git a/loom.example.yaml b/loom.example.yaml index 3e4e7cc3338..a66457bc76c 100644 --- a/loom.example.yaml +++ b/loom.example.yaml @@ -887,6 +887,14 @@ settings: # none, as does an empty smtp_url or public_base_url (the link needs it). [restart] # mail_from: "" + # Seconds to wait on the mail server for one invitation email; past it the email is + # reported not sent, and the link is shown to pass on. [restart] + # smtp_timeout_seconds: 10.0 + + # Seconds an invitation link stays valid, at most 30 days: it admits whoever opens it. + # [restart] + # invite_ttl_seconds: 604800 + # How callers authenticate: "single-user" (no auth, one anonymous identity), # "trust-network" (self-signup, first claim wins) or "gateway" (an upstream proxy # mints short-lived Loom JWTs with the shared HS256 secret; Loom only validates). diff --git a/schemas/loom-settings.schema.json b/schemas/loom-settings.schema.json index d4b67baf3a7..4bea3561c3c 100644 --- a/schemas/loom-settings.schema.json +++ b/schemas/loom-settings.schema.json @@ -3291,6 +3291,13 @@ "type": "number", "description": "Seconds between this process's loom.instances heartbeats, each of which also compares it with the deployment's published configuration. A row not renewed for three intervals is not live." }, + "invite_ttl_seconds": { + "default": 604800, + "maximum": 2592000, + "minimum": 3600, + "type": "integer", + "description": "Seconds an invitation link stays valid, at most 30 days: it admits whoever opens it." + }, "jwt_audience": { "default": "loom-platform", "type": "string", @@ -6881,6 +6888,13 @@ "type": "number", "description": "Seconds a process keeps serving after SIGTERM while /v1/health/ready answers 503, so the load balancer stops routing to it before its port closes. Size it to the LB's probe interval × failure threshold. 0 = stop at once." }, + "smtp_timeout_seconds": { + "default": 10.0, + "exclusiveMinimum": 0, + "maximum": 60, + "type": "number", + "description": "Seconds to wait on the mail server for one invitation email; past it the email is reported not sent, and the link is shown to pass on." + }, "storage_authority": { "default": "clickhouse", "enum": [ diff --git a/server/identity/app/invite_mail.py b/server/identity/app/invite_mail.py index 1265843c9d4..97468ddcb42 100644 --- a/server/identity/app/invite_mail.py +++ b/server/identity/app/invite_mail.py @@ -17,8 +17,6 @@ log = logging.getLogger(__name__) -_TIMEOUT_S = 10 - def can_send() -> bool: return bool(settings.smtp_url and settings.mail_from and settings.public_base_url) @@ -46,9 +44,11 @@ def _send(msg: EmailMessage) -> None: tls = ssl.create_default_context() client: smtplib.SMTP if u.scheme == "smtps": - client = smtplib.SMTP_SSL(host, u.port or 465, context=tls, timeout=_TIMEOUT_S) + client = smtplib.SMTP_SSL( + host, u.port or 465, context=tls, timeout=settings.smtp_timeout_seconds + ) elif u.scheme == "smtp": - client = smtplib.SMTP(host, u.port or 587, timeout=_TIMEOUT_S) + client = smtplib.SMTP(host, u.port or 587, timeout=settings.smtp_timeout_seconds) else: raise ValueError("smtp_url must start with smtp:// or smtps://") with client: diff --git a/server/identity/app/invites.py b/server/identity/app/invites.py index a290b471bc0..dcf270f6a89 100644 --- a/server/identity/app/invites.py +++ b/server/identity/app/invites.py @@ -123,7 +123,7 @@ async def _invite(input: GrantsInviteInput, email: str) -> GrantsInviteOutput: role=input.role, created_by=_caller(), created_at=now, - expires_at=int(now.timestamp()) + domain.TTL_S, + expires_at=int(now.timestamp()) + settings.invite_ttl_seconds, ) await invites_repo.put(invite) path = domain.link_path(input.org, input.namespace, secret) diff --git a/server/identity/domain/invites.py b/server/identity/domain/invites.py index 3af6828232f..eae74c5eb52 100644 --- a/server/identity/domain/invites.py +++ b/server/identity/domain/invites.py @@ -18,9 +18,6 @@ InviteState = Literal["open", "accepted", "cancelled"] -# How long a link stays open. -TTL_S = 7 * 86400 - def new_secret() -> str: return secrets.token_urlsafe(32) diff --git a/server/settings/catalog.py b/server/settings/catalog.py index b8d382a89d0..327e411ba5b 100644 --- a/server/settings/catalog.py +++ b/server/settings/catalog.py @@ -467,6 +467,11 @@ def trusted_issuers(self) -> set[str]: # The From address of an invitation email, e.g. `Loom `. Empty # sends none, as does an empty smtp_url or public_base_url (the link needs it). mail_from: str = "" + # Seconds to wait on the mail server for one invitation email; past it the email is + # reported not sent, and the link is shown to pass on. + smtp_timeout_seconds: float = Field(default=10.0, gt=0, le=60) + # Seconds an invitation link stays valid, at most 30 days: it admits whoever opens it. + invite_ttl_seconds: int = Field(default=7 * 86400, ge=3600, le=30 * 86400) # How callers authenticate: "single-user" (no auth, one anonymous identity), # "trust-network" (self-signup, first claim wins) or "gateway" (an upstream proxy diff --git a/tests/unit/test_grants_invite.py b/tests/unit/test_grants_invite.py index 59b94e3874b..11a7d24dd34 100644 --- a/tests/unit/test_grants_invite.py +++ b/tests/unit/test_grants_invite.py @@ -187,7 +187,7 @@ async def test_an_email_no_account_holds_gets_a_link_kept_only_as_its_hash(world "admin-ann", "open", ) - assert stored.expires_at - time.time() == pytest.approx(domain.TTL_S, abs=5) + assert stored.expires_at - time.time() == pytest.approx(settings.invite_ttl_seconds, abs=5) assert world.mail[0]["to"] == "michael@example.com" listed = await mod.handle_grants_list_invites(GrantsListInvitesInput(org="o", namespace="ns")) assert [r.email for r in listed.rows] == ["michael@example.com"] From 08cc874e7d3defb5665c6ea47f79ed42dbff109b Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Fri, 4 Dec 2026 21:35:55 +0530 Subject: [PATCH 07/28] docs: invitations in the tokens and grants guide Co-Authored-By: Claude Opus 5.5 Signed-off-by: Lareb Zafar --- docs/guides/tokens-and-grants.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/docs/guides/tokens-and-grants.md b/docs/guides/tokens-and-grants.md index 74aa988bfa1..43e2af2bd60 100644 --- a/docs/guides/tokens-and-grants.md +++ b/docs/guides/tokens-and-grants.md @@ -225,13 +225,15 @@ answer to the user (the entity graph, conversation reads, exports, admin ops) is namespace above what the token carries. Grants add; where the subject holds one, a token's claim goes no further than it. -| Op | Role | Does | -| ----------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------ | -| `grants.create` | admin | Give `subject` a `role`. Below the subject's current role it answers 409 `GRANT_WOULD_DOWNGRADE` unless `replace: true`. | -| `grants.revoke` | admin | Remove it; on a restricted namespace the grants of tokens the subject minted there go too. | -| `grants.list` | viewer | The namespace's grants. | -| `grants.approve` | admin | Activate a pending join request. Below the subject's current grant it answers 409: an approval never asks to lower one. | -| `grants.pending_for_me` | viewer | Requests waiting on the caller's approval. | +| Op | Role | Does | +| ----------------------- | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `grants.create` | admin | Give `subject` a `role`. Below the subject's current role it answers 409 `GRANT_WOULD_DOWNGRADE` unless `replace: true`. | +| `grants.invite` | admin | Give a person a `role` by login handle or email: an account's handle or verified email is granted at once, any other email gets a single-use invitation link. A handle no account holds is refused (404). | +| `grants.accept_invite` | a signed-in person | Accept an invitation link; its role goes to the account the caller signs in as. | +| `grants.revoke` | admin | Remove it; on a restricted namespace the grants of tokens the subject minted there go too. | +| `grants.list` | viewer | The namespace's grants. | +| `grants.approve` | admin | Activate a pending join request. Below the subject's current grant it answers 409: an approval never asks to lower one. | +| `grants.pending_for_me` | viewer | Requests waiting on the caller's approval. | ```bash curl -s "$LOOM_BASE_URL/v1/grants.create" -H "Authorization: Bearer $ADMIN_TOKEN" \ @@ -253,7 +255,7 @@ curl -s "$LOOM_BASE_URL/v1/grants.create" -H "Authorization: Bearer $ADMIN_TOKEN owner proving the password from an SSO sign-in). A self-signup email is not: whoever typed the address first does not hold the grants written under it, which still cap that account's claims. Grant a self-signup account under its login handle, the namespace - it signed up with. A `grants.revoke` of an address no verified account holds, and that + it signed up with, or invite its email with `grants.invite`, whose link the person accepts signed in ([invitations](../features/namespaces-and-sharing.md#membership-and-grants)). A `grants.revoke` of an address no verified account holds, and that never held a row of its own on the namespace, takes the rows stored under each unverified account naming it, and the grants there of the tokens those accounts made. When the address held a row of its own there, its revoke also takes the grants of the From 2cd6ce7eb2eb6ac6bf5d983c0a23e968605bea48 Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Fri, 4 Dec 2026 22:07:22 +0530 Subject: [PATCH 08/28] dashboard: route a person's handle or email through grants.invite The members dialog and a repository's Access tab invite a person and show the invitation link; the sign-in gate keeps an invitation link through a single sign-on. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Lareb Zafar --- frontend/src/App.tsx | 2 - .../src/flows/MembersDialog.fanout.test.tsx | 19 +++- .../src/flows/MembersDialog.invite.test.tsx | 91 +++++++++++++++++++ frontend/src/flows/MembersDialog.tsx | 30 +++++- frontend/src/flows/TokenGate.tsx | 3 + frontend/src/flows/fieldErrors.test.tsx | 7 ++ frontend/src/lib/boot.ts | 25 ----- frontend/src/lib/inviteLink.ts | 27 ++++++ frontend/src/views/Code.tsx | 25 ++++- frontend/src/views/CollectionSharing.test.tsx | 21 ++++- frontend/src/views/InvitationCard.test.tsx | 11 ++- frontend/src/views/InvitationCard.tsx | 6 +- 12 files changed, 228 insertions(+), 39 deletions(-) create mode 100644 frontend/src/flows/MembersDialog.invite.test.tsx create mode 100644 frontend/src/lib/inviteLink.ts diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 709ec2912c5..52c2b393172 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -34,7 +34,6 @@ import { provisionalNamespace, rememberKinds, sameAccount, - takeInviteLink, takeLinkToken, takeSignInStarted, takeSsoAsk, @@ -311,7 +310,6 @@ export default function App() { // and scrubbed before anything can fail. The return to the page its sign-in started on // is a chunk of its own, and boot goes on without it. link = takeLinkToken(); - takeInviteLink(); const started = takeSignInStarted(link?.nonce ?? null); if (takeSsoAsk()) setSsoAsked(true); if (link) { diff --git a/frontend/src/flows/MembersDialog.fanout.test.tsx b/frontend/src/flows/MembersDialog.fanout.test.tsx index ddee88f32b5..c31172f0e93 100644 --- a/frontend/src/flows/MembersDialog.fanout.test.tsx +++ b/frontend/src/flows/MembersDialog.fanout.test.tsx @@ -6,9 +6,23 @@ import { render, screen, fireEvent, waitFor } from "../test/rtl"; import { MembersDialog } from "./MembersDialog"; import { useStore } from "../lib/state"; import * as api from "../api"; +import * as invites from "../api/invites"; import { ApiError } from "../lib/errors"; import { ToastViewport } from "../components/Toast"; +vi.mock("../api/invites", async (importOriginal) => ({ + ...(await importOriginal()), + invite: vi.fn(async (_id: unknown, subject: string, role: string) => ({ + outcome: "granted" as const, + role, + subject, + invite_id: "", + link_path: "", + url: "", + expires_at: null, + emailed: false, + })), +})); vi.mock("../api", async (importOriginal) => { const actual = await importOriginal(); return { @@ -41,6 +55,7 @@ const elsewhere = { beforeEach(() => { vi.mocked(api.approveGrant).mockClear(); vi.mocked(api.createGrant).mockClear(); + vi.mocked(invites.invite).mockClear(); useStore.setState({ whoami: { authenticated: true, subject: "alice", org: "clickhouse", roles: ["ADMIN"] }, }); @@ -113,9 +128,9 @@ describe("MembersDialog approves a requester on every waiting branch at once", ( expect(screen.getByRole("button", { name: "Role for the new reader" })).toHaveTextContent("Reader"); fireEvent.change(screen.getByRole("textbox", { name: /reader to add/ }), { target: { value: subject } }); fireEvent.click(screen.getByRole("button", { name: /^Add$/ })); - await waitFor(() => expect(api.createGrant).toHaveBeenCalledTimes(n)); + await waitFor(() => expect(invites.invite).toHaveBeenCalledTimes(n)); } - expect(vi.mocked(api.createGrant).mock.calls.map((c) => [c[1], c[2]])).toEqual([ + expect(vi.mocked(invites.invite).mock.calls.map((c) => [c[1], c[2]])).toEqual([ ["reader-a", "viewer"], ["reader-b", "viewer"], ]); diff --git a/frontend/src/flows/MembersDialog.invite.test.tsx b/frontend/src/flows/MembersDialog.invite.test.tsx new file mode 100644 index 00000000000..eec11011731 --- /dev/null +++ b/frontend/src/flows/MembersDialog.invite.test.tsx @@ -0,0 +1,91 @@ +import { cleanup, render, screen, waitFor, within } from "../test/rtl"; +import userEvent from "@testing-library/user-event"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import * as api from "../api"; +import * as invites from "../api/invites"; +import { useStore } from "../lib/state"; +import { MembersDialog } from "./MembersDialog"; + +// A person is added through grants.invite: an account is granted at once; any other email +// gets a link the dialog shows to copy and lists as open. A service account goes through +// grants.create as typed. + +vi.mock("../api", async (importOriginal) => ({ + ...(await importOriginal()), + listGrants: vi.fn(async () => ({ rows: [] })), + createGrant: vi.fn(async () => ({})), +})); +vi.mock("../api/invites", async (importOriginal) => ({ + ...(await importOriginal()), + invite: vi.fn(), + listInvites: vi.fn(async () => ({ rows: [] })), +})); + +const invited = { + outcome: "invited" as const, + role: "writer" as const, + subject: "", + invite_id: "abc", + link_path: "/spaces#invite=s3cret&org=dev&namespace=team", + url: "https://loom.example.com/spaces#invite=s3cret&org=dev&namespace=team", + expires_at: "2026-12-11T12:00:00Z", + emailed: true, +}; + +beforeEach(() => { + vi.mocked(api.createGrant).mockClear(); + vi.mocked(invites.invite).mockReset(); + useStore.setState({ whoami: { authenticated: true, subject: "ann", org: "dev", roles: ["ADMIN"] } }); +}); +afterEach(() => cleanup()); + +async function add(subject: string) { + const user = userEvent.setup(); + render( {}} org="dev" namespace="team" kind="memory" />); + await user.click((await screen.findAllByRole("button", { name: /Add member/ }))[0]); + await user.type(await screen.findByRole("textbox", { name: /member to add/ }), `${subject}{Enter}`); +} + +describe("MembersDialog invites a person", () => { + it("shows an email's invitation link and lists it as open", async () => { + vi.mocked(invites.invite).mockResolvedValue(invited); + vi.mocked(invites.listInvites) + .mockResolvedValueOnce({ rows: [] }) + .mockResolvedValue({ + rows: [ + { + invite_id: "abc", + email: "pat@example.com", + role: "writer", + created_by: "ann", + created_at: "2026-12-04T12:00:00Z", + expires_at: "2026-12-11T12:00:00Z", + }, + ], + }); + await add("pat@example.com"); + expect(invites.invite).toHaveBeenCalledWith({ org: "dev", namespace: "team" }, "pat@example.com", "writer"); + const status = await screen.findByRole("status"); + expect(status).toHaveTextContent("Emailed an invitation to pat@example.com."); + expect(within(status).getByText(invited.url)).toBeInTheDocument(); + const open = await screen.findByRole("region", { name: "Open invitations" }); + expect(open).toHaveTextContent("pat@example.com"); + expect(api.createGrant).not.toHaveBeenCalled(); + }); + + it("grants an account's handle at once, under the subject the server names", async () => { + vi.mocked(invites.invite).mockResolvedValue({ ...invited, outcome: "granted", subject: "mlex", invite_id: "" }); + await add("MLex"); + await waitFor(() => expect(invites.invite).toHaveBeenCalledTimes(1)); + expect(screen.queryByRole("status")).toBeNull(); + expect(screen.queryByRole("textbox", { name: /member to add/ })).toBeNull(); + }); + + it("grants a service account through grants.create, as typed", async () => { + await add("sa:triage"); + await waitFor(() => + expect(api.createGrant).toHaveBeenCalledWith({ org: "dev", namespace: "team" }, "sa:triage", "writer"), + ); + expect(invites.invite).not.toHaveBeenCalled(); + }); +}); diff --git a/frontend/src/flows/MembersDialog.tsx b/frontend/src/flows/MembersDialog.tsx index fd12ac60954..d144c2888c9 100644 --- a/frontend/src/flows/MembersDialog.tsx +++ b/frontend/src/flows/MembersDialog.tsx @@ -33,6 +33,8 @@ import { andList, fmtInt } from "../lib/format"; import { MORE_SHOWN, type ShowMoreRows, useShowMore } from "../lib/useShowMore"; import { grantSpellings, mySpellings, namesMe, subjectLabel } from "../lib/grantSubject"; import { PlaceLink } from "../components/ui/PlaceLink"; +import { invite, isPersonSpelling, type InviteResult } from "../api/invites"; +import { InviteSent, OpenInvitations } from "../components/Invitations"; /** What Remove's confirm says: who still gets in once the grant here goes. Sign-in off serves * every request, so it says only that the grant is revoked. */ @@ -236,6 +238,10 @@ export function MembersDialog({ const [cut, setCut] = useState(false); const [adding, setAdding] = useState(startAdding); const [newSubject, setNewSubject] = useState(""); + // The invitation an add just made, with its link to copy; and how many it has made, which + // reads the open invitations again. + const [sent, setSent] = useState<{ email: string; result: InviteResult } | null>(null); + const [invited, setInvited] = useState(0); // A code index has no writer role, so its default must be one the select offers. const defaultRole: GrantRole = isCode ? "viewer" : "writer"; const [newRole, setNewRole] = useState(defaultRole); @@ -316,8 +322,23 @@ export function MembersDialog({ setBusy("__add__"); setErr(null); try { - await createGrant({ org, namespace }, subj, newRole); - toast(`Added ${subjectLabel(subj, org)} as ${newRole}`, "ok"); + // A person by handle or email is invited: an account is granted at once, any other + // email gets a link. A service account, a group or everyone is granted as typed. + if (isPersonSpelling(subj)) { + const out = await invite({ org, namespace }, subj, newRole); + if (out.outcome === "invited") { + // The link stays on screen to copy, and the add field open for the next person. + setSent({ email: subj, result: out }); + setInvited((n) => n + 1); + setNewSubject(""); + return; + } + toast(`Added ${subjectLabel(out.subject, org)} as ${newRole}`, "ok"); + } else { + await createGrant({ org, namespace }, subj, newRole); + toast(`Added ${subjectLabel(subj, org)} as ${newRole}`, "ok"); + } + setSent(null); setNewSubject(""); setNewRole(defaultRole); setAdding(false); @@ -454,6 +475,7 @@ export function MembersDialog({ // The next open, if the caller keeps the dialog mounted, starts where this one did. setAdding(startAdding); setErr(null); + setSent(null); } onOpenChange(v); }} @@ -492,6 +514,7 @@ export function MembersDialog({ {cut && (

{`Only the first ${fmtInt(GRANTS_READ)} grants were read.`}

)} + {canManage && } {pendingRows.length > 0 && (
{`Pending requests (${fmtInt(pendingRows.length)})`}
@@ -701,9 +724,8 @@ export function MembersDialog({

{roles.find((r) => r.value === newRole)?.desc}

- {/* An email no verified account holds is stored as typed and reaches nobody: say so - before the add, not after. */} + {sent && } )} diff --git a/frontend/src/flows/TokenGate.tsx b/frontend/src/flows/TokenGate.tsx index c53fa039d71..9383dc81023 100644 --- a/frontend/src/flows/TokenGate.tsx +++ b/frontend/src/flows/TokenGate.tsx @@ -9,6 +9,7 @@ import { Panel } from "../components/ui/Panel"; import { TabTrigger } from "../components/ui/TabTrigger"; import { selfSignup, setToken, loginWithPassword } from "../api"; import { SIGN_IN_FROM, markSignInStarted, type TokenClaims } from "../lib/boot"; +import { takeInviteLink } from "../lib/inviteLink"; import { goToSso } from "../lib/navigation"; import { errorRequestId } from "../lib/format"; import { humanizeError } from "../lib/errorWords"; @@ -50,6 +51,8 @@ export function TokenGate({ onLogin, reason = null, ssoAsked = false }: TokenGat * landing (`/me`, where a restart begins) the page saved by the first start stays. */ function rememberSignInStart(): string { const nonce = markSignInStarted(); + // The identity provider's round trip drops the fragment, and an invitation link with it. + takeInviteLink(); const path = window.location.pathname + window.location.search; try { // A restart from the landing keeps the page the sign-in started on. diff --git a/frontend/src/flows/fieldErrors.test.tsx b/frontend/src/flows/fieldErrors.test.tsx index 9aa6f8850e8..eeeda238f33 100644 --- a/frontend/src/flows/fieldErrors.test.tsx +++ b/frontend/src/flows/fieldErrors.test.tsx @@ -23,6 +23,13 @@ vi.mock("../api", async (importOriginal) => { }), }; }); +// A person's handle or email is added through grants.invite, which refuses an unknown one. +vi.mock("../api/invites", async (importOriginal) => ({ + ...(await importOriginal()), + invite: vi.fn(async () => { + throw new Error("No such subject"); + }), +})); vi.mock("../api/tasks", async (importOriginal) => { const actual = await importOriginal(); return { diff --git a/frontend/src/lib/boot.ts b/frontend/src/lib/boot.ts index 0a917cd2f49..86cfb1b192d 100644 --- a/frontend/src/lib/boot.ts +++ b/frontend/src/lib/boot.ts @@ -145,31 +145,6 @@ export function takeLinkToken(): { token: string | null; atRoot: boolean; nonce: return { token, atRoot: fromHash && !qs && (pathname === "/" || pathname === "/me"), nonce }; } -/** The session key for an invitation link's `{ secret, org, namespace }`: boot moves it out - * of the address (`/spaces#invite=&org=…&namespace=…`) before the sign-in gate, so a - * single sign-on's round trip keeps it, and Namespaces in your org offers to accept it. */ -export const INVITE_LINK = "loom_invite_v1"; - -export interface InviteLink { - secret: string; - org: string; - namespace: string; -} - -/** Take an invitation link out of the address into this tab's session. */ -export function takeInviteLink(): void { - const { hash, pathname, search } = window.location; - if (!hash.startsWith("#invite=")) return; - history.replaceState(history.state, "", pathname + search); - const p = new URLSearchParams(hash.slice(1)); - const link = { secret: p.get("invite"), org: p.get("org"), namespace: p.get("namespace") }; - try { - if (link.secret && link.org && link.namespace) sessionStorage.setItem(INVITE_LINK, JSON.stringify(link)); - } catch { - /* no session storage: the link is opened again once signed in */ - } -} - /** Namespace kinds from the last membership answer this browser saw, so a * deep link can tell a memory namespace from a code or QA one before * list_mine answers again (a memory view never mounts on a code or tracker namespace; diff --git a/frontend/src/lib/inviteLink.ts b/frontend/src/lib/inviteLink.ts new file mode 100644 index 00000000000..cce53e0b387 --- /dev/null +++ b/frontend/src/lib/inviteLink.ts @@ -0,0 +1,27 @@ +// An invitation link (`/spaces#invite=&org=…&namespace=…`), taken out of the address +// into this tab's session: by the sign-in gate as a single sign-on starts (the identity +// provider's round trip drops the fragment), else by Namespaces in your org, which offers to +// accept it. A password sign-in reloads the page, fragment and all. + +/** The session key for an invitation link's `{ secret, org, namespace }`. */ +export const INVITE_LINK = "loom_invite_v1"; + +export interface InviteLink { + secret: string; + org: string; + namespace: string; +} + +/** Take an invitation link out of the address into this tab's session. */ +export function takeInviteLink(): void { + const { hash, pathname, search } = window.location; + if (!hash.startsWith("#invite=")) return; + history.replaceState(history.state, "", pathname + search); + const p = new URLSearchParams(hash.slice(1)); + const link = { secret: p.get("invite"), org: p.get("org"), namespace: p.get("namespace") }; + try { + if (link.secret && link.org && link.namespace) sessionStorage.setItem(INVITE_LINK, JSON.stringify(link)); + } catch { + /* no session storage: the link is opened again once signed in */ + } +} diff --git a/frontend/src/views/Code.tsx b/frontend/src/views/Code.tsx index cce4caec31b..294fe46f72a 100644 --- a/frontend/src/views/Code.tsx +++ b/frontend/src/views/Code.tsx @@ -33,6 +33,8 @@ import { useAbortableEffect, useVisiblePoll } from "../lib/hooks"; import { EmptyState } from "../components/EmptyState"; import { ScopeBadge } from "../components/ScopeBadge"; import { SubjectHelp } from "../components/SubjectHelp"; +import { invite, isPersonSpelling, type InviteResult } from "../api/invites"; +import { InviteSent, OpenInvitations } from "../components/Invitations"; import { IconButton } from "../components/IconButton"; import { ChoiceGroup } from "../components/ui/ChoiceGroup"; import { Modal, ModalFooter } from "../components/ui/Modal"; @@ -3042,6 +3044,10 @@ export function AccessTab({ // grants.list refused the caller (a viewer read): not a reader, so not a maintainer. const [refused, setRefused] = useState(false); const [subject, setSubject] = useState(""); + // The invitation an add just made, with its link to copy; and how many, which reads the + // open invitations again. + const [sent, setSent] = useState<{ email: string; result: InviteResult } | null>(null); + const [invited, setInvited] = useState(0); const [role, setRole] = useState("viewer"); const [busy, setBusy] = useState(null); const [settingsOpen, setSettingsOpen] = useState(false); @@ -3187,8 +3193,19 @@ export function AccessTab({ if (!s || !canManage) return; setBusy("add"); try { - await createGrant(id, s, role); + // A person by handle or email is invited: an account is granted at once, any other + // email gets a link to copy. A service account or a group is granted as typed. + if (isPersonSpelling(s)) { + const out = await invite(id, s, role); + if (out.outcome === "invited") { + setSent({ email: s, result: out }); + setInvited((n) => n + 1); + setSubject(""); + return; + } + } else await createGrant(id, s, role); toast(`${s} is now a ${roleWord(role)}`, "ok"); + setSent(null); setSubject(""); load(); } catch (err) { @@ -3591,8 +3608,14 @@ export function AccessTab({ Adding someone by name works under every rule. Agents read with a token that names this repository.

+ {sent && ( +
+ +
+ )} )} + {canManage && } )} diff --git a/frontend/src/views/CollectionSharing.test.tsx b/frontend/src/views/CollectionSharing.test.tsx index ed5ec173e86..f8e6eaec703 100644 --- a/frontend/src/views/CollectionSharing.test.tsx +++ b/frontend/src/views/CollectionSharing.test.tsx @@ -22,6 +22,23 @@ const api = vi.hoisted(() => ({ isAuthDisabled: vi.fn(() => false), })); vi.mock("../api", async (importOriginal) => ({ ...(await importOriginal()), ...api })); +// A person is added through grants.invite; a principal through grants.create. +const invites = vi.hoisted(() => ({ + invite: vi.fn(async (_id: unknown, subject: string, role: string) => ({ + outcome: "granted" as const, + role, + subject, + invite_id: "", + link_path: "", + url: "", + expires_at: null, + emailed: false, + })), +})); +vi.mock("../api/invites", async (importOriginal) => ({ + ...(await importOriginal()), + ...invites, +})); vi.mock("../components/ConfirmDialog", async (importOriginal) => ({ ...(await importOriginal()), confirmAction: async () => true, @@ -629,7 +646,7 @@ describe("the collection header", () => { fireEvent.click(within(dialog).getByRole("button", { name: "Add member" })); fireEvent.change(within(dialog).getByRole("textbox"), { target: { value: "bob" } }); fireEvent.click(within(dialog).getByRole("button", { name: "Add" })); - await waitFor(() => expect(api.createGrant).toHaveBeenCalled()); + await waitFor(() => expect(invites.invite).toHaveBeenCalled()); let answer: (v: unknown) => void = () => {}; api.listGrants.mockReturnValue(new Promise((r) => (answer = r))); fireEvent.click(within(dialog).getByRole("button", { name: "Close" })); @@ -712,7 +729,7 @@ describe("the collection header", () => { fireEvent.click(await within(dialog).findByRole("button", { name: "Add member" })); fireEvent.change(within(dialog).getByRole("textbox"), { target: { value: "bob" } }); fireEvent.click(within(dialog).getByRole("button", { name: "Add" })); - await waitFor(() => expect(api.createGrant).toHaveBeenCalled()); + await waitFor(() => expect(invites.invite).toHaveBeenCalled()); const through = await within(dialog).findByRole("region", { name: "Also can see it, through Engineering" }); fireEvent.click(within(through).getByRole("link", { name: "Engineering" })); await waitFor(() => expect(screen.queryByRole("dialog")).not.toBeInTheDocument()); diff --git a/frontend/src/views/InvitationCard.test.tsx b/frontend/src/views/InvitationCard.test.tsx index 40b02bf1aef..431178a1e24 100644 --- a/frontend/src/views/InvitationCard.test.tsx +++ b/frontend/src/views/InvitationCard.test.tsx @@ -2,7 +2,7 @@ import { cleanup, render, screen } from "../test/rtl"; import userEvent from "@testing-library/user-event"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { acceptInvite } from "../api/invites"; -import { INVITE_LINK, takeInviteLink } from "../lib/boot"; +import { INVITE_LINK, takeInviteLink } from "../lib/inviteLink"; import { ApiError } from "../lib/errors"; import { useStore } from "../lib/state"; import { InvitationCard } from "./InvitationCard"; @@ -79,3 +79,12 @@ describe("InvitationCard", () => { expect(screen.queryByRole("region", { name: "Invitation" })).toBeNull(); }); }); + +describe("InvitationCard on an address that still carries the link", () => { + it("takes the link from the address itself", () => { + history.replaceState(null, "", "/spaces#invite=s3cret&org=dev&namespace=alerts"); + render(); + expect(screen.getByRole("region", { name: "Invitation" })).toHaveTextContent("You're invited to alerts."); + expect(window.location.hash).toBe(""); + }); +}); diff --git a/frontend/src/views/InvitationCard.tsx b/frontend/src/views/InvitationCard.tsx index 0a9a37dc663..75a207f4d96 100644 --- a/frontend/src/views/InvitationCard.tsx +++ b/frontend/src/views/InvitationCard.tsx @@ -4,13 +4,15 @@ import { setSavedNamespace } from "../api"; import { acceptInvite } from "../api/invites"; import { Alert } from "../components/ui"; import { toast } from "../components/Toast"; -import { INVITE_LINK, type InviteLink } from "../lib/boot"; +import { INVITE_LINK, type InviteLink, takeInviteLink } from "../lib/inviteLink"; import { humanizeError } from "../lib/errorWords"; import { ApiError } from "../lib/errors"; import { invalidateShared } from "../lib/sharedReads"; import { useStore } from "../lib/state"; function stashed(): InviteLink | null { + // An address opened signed in, or after a password sign-in, still carries it. + takeInviteLink(); try { const v = JSON.parse(sessionStorage.getItem(INVITE_LINK) ?? "null") as Partial | null; if (v && typeof v.secret === "string" && typeof v.org === "string" && typeof v.namespace === "string") { @@ -30,7 +32,7 @@ function drop(): void { } } -/** The invitation link this tab opened (`lib/boot.ts` keeps it through the sign-in), for the +/** The invitation link this tab opened (`lib/inviteLink.ts` keeps it through a single sign-on), for the * signed-in person to accept. */ export function InvitationCard() { const [link, setLink] = useState(stashed); From 4e9efe30fbfedda7ae67c53446943dfe25c2342c Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Fri, 4 Dec 2026 22:13:17 +0530 Subject: [PATCH 09/28] dashboard: an accepted collection invitation opens the collection in the Library Co-Authored-By: Claude Opus 5.5 Signed-off-by: Lareb Zafar --- frontend/src/views/InvitationCard.test.tsx | 13 +++++++++++++ frontend/src/views/InvitationCard.tsx | 6 +++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/frontend/src/views/InvitationCard.test.tsx b/frontend/src/views/InvitationCard.test.tsx index 431178a1e24..17e5f94735a 100644 --- a/frontend/src/views/InvitationCard.test.tsx +++ b/frontend/src/views/InvitationCard.test.tsx @@ -57,6 +57,19 @@ describe("InvitationCard", () => { expect(screen.queryByRole("region", { name: "Invitation" })).toBeNull(); }); + it("opens an accepted collection in the Library, keeping the namespace in use", async () => { + vi.mocked(acceptInvite).mockResolvedValue({ namespace: "col-runbooks", role: "viewer" }); + const real = useStore.getState().navigate; + const navigate = vi.fn(); + useStore.setState({ navigate }); + const user = userEvent.setup(); + opened(); + await user.click(screen.getByRole("button", { name: "Accept invitation" })); + expect(navigate).toHaveBeenCalledWith("knowledge", { query: { collection: "col-runbooks" } }); + expect(useStore.getState().identity?.namespace).toBe("home"); + useStore.setState({ navigate: real }); + }); + it("says why a spent link is refused and offers only Close", async () => { vi.mocked(acceptInvite).mockRejectedValue( new ApiError({ diff --git a/frontend/src/views/InvitationCard.tsx b/frontend/src/views/InvitationCard.tsx index 75a207f4d96..e0397ae90e2 100644 --- a/frontend/src/views/InvitationCard.tsx +++ b/frontend/src/views/InvitationCard.tsx @@ -7,6 +7,7 @@ import { toast } from "../components/Toast"; import { INVITE_LINK, type InviteLink, takeInviteLink } from "../lib/inviteLink"; import { humanizeError } from "../lib/errorWords"; import { ApiError } from "../lib/errors"; +import { isCollectionName } from "../lib/namespace"; import { invalidateShared } from "../lib/sharedReads"; import { useStore } from "../lib/state"; @@ -42,6 +43,7 @@ export function InvitationCard() { const [refused, setRefused] = useState(false); const identity = useStore((s) => s.identity); const setIdentity = useStore((s) => s.setIdentity); + const navigate = useStore((s) => s.navigate); if (!link) return null; const close = () => { @@ -56,7 +58,9 @@ export function InvitationCard() { close(); toast(`You're a ${out.role} on ${out.namespace}`, "ok"); invalidateShared("mine:"); - if (identity && identity.org === link.org) { + // A collection opens in the Library; a namespace becomes the one in use. + if (isCollectionName(out.namespace)) navigate("knowledge", { query: { collection: out.namespace } }); + else if (identity && identity.org === link.org) { setIdentity({ ...identity, namespace: out.namespace }); setSavedNamespace(out.namespace); } From f453aa8da28cee4513c120243e1ab24d6a08bd30 Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Fri, 4 Dec 2026 22:29:38 +0530 Subject: [PATCH 10/28] settings: pin the invitation and mail defaults Co-Authored-By: Claude Opus 5.5 Signed-off-by: Lareb Zafar --- tests/unit/snapshots/settings_defaults.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/unit/snapshots/settings_defaults.json b/tests/unit/snapshots/settings_defaults.json index 3584d7bf411..385a12bd0be 100644 --- a/tests/unit/snapshots/settings_defaults.json +++ b/tests/unit/snapshots/settings_defaults.json @@ -586,6 +586,7 @@ "inference_workload_token_mode": "exchange", "insights_agents_connected_ttl_s": 60.0, "instance_heartbeat_seconds": 10.0, + "invite_ttl_seconds": 604800, "jwt_audience": "loom-platform", "jwt_end_user_issuers_json": "", "jwt_end_user_jwks_refresh_seconds": 300.0, @@ -715,6 +716,7 @@ "local_llm_base_url": "http://localhost:11434/v1", "log_format": "text", "log_level": "info", + "mail_from": "", "max_request_bytes": 33554432, "mcp_always_load_tools": "code.search,code.symbol", "mcp_auth_mode": "required", @@ -1207,6 +1209,7 @@ "session_brief_max_windows": 4, "session_brief_window_chars": 24000, "shutdown_ready_delay_s": 15.0, + "smtp_timeout_seconds": 10.0, "storage_authority": "clickhouse", "storage_frontend_assets_retry_max_s": 60.0, "storage_frontend_assets_retry_s": 2.0, From 55c4b6a3e7699f681fbde4e0c87ecde66f7a1420 Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Sat, 5 Dec 2026 00:19:30 +0530 Subject: [PATCH 11/28] test(dashboard): an accepted invitation reads list_mine again at once Co-Authored-By: Claude Opus 5.5 Signed-off-by: Lareb Zafar --- frontend/src/views/InvitationCard.test.tsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/frontend/src/views/InvitationCard.test.tsx b/frontend/src/views/InvitationCard.test.tsx index 17e5f94735a..e6493bfc3e8 100644 --- a/frontend/src/views/InvitationCard.test.tsx +++ b/frontend/src/views/InvitationCard.test.tsx @@ -1,9 +1,11 @@ import { cleanup, render, screen } from "../test/rtl"; import userEvent from "@testing-library/user-event"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import { listMine } from "../api"; import { acceptInvite } from "../api/invites"; import { INVITE_LINK, takeInviteLink } from "../lib/inviteLink"; import { ApiError } from "../lib/errors"; +import { invalidateShared, sharedMine } from "../lib/sharedReads"; import { useStore } from "../lib/state"; import { InvitationCard } from "./InvitationCard"; @@ -11,10 +13,16 @@ import { InvitationCard } from "./InvitationCard"; // a sign-in keeps it, and the card accepts it as the signed-in person. vi.mock("../api/invites", () => ({ acceptInvite: vi.fn() })); +vi.mock("../api", async (importOriginal) => ({ + ...(await importOriginal()), + listMine: vi.fn(async () => []), +})); beforeEach(() => { sessionStorage.clear(); vi.mocked(acceptInvite).mockReset(); + vi.mocked(listMine).mockClear(); + invalidateShared(); useStore.setState({ identity: { org: "dev", namespace: "home", agent: "loom-ui" } }); }); afterEach(() => cleanup()); @@ -47,6 +55,7 @@ function opened(): void { describe("InvitationCard", () => { it("accepts as the signed-in person and switches to the namespace", async () => { vi.mocked(acceptInvite).mockResolvedValue({ namespace: "alerts", role: "writer" }); + await sharedMine("dev"); const user = userEvent.setup(); opened(); expect(screen.getByRole("region", { name: "Invitation" })).toHaveTextContent("You're invited to alerts."); @@ -55,6 +64,9 @@ describe("InvitationCard", () => { expect(useStore.getState().identity?.namespace).toBe("alerts"); expect(sessionStorage.getItem(INVITE_LINK)).toBeNull(); expect(screen.queryByRole("region", { name: "Invitation" })).toBeNull(); + // The new grant is read at once, not after the shared list_mine read's 30 s. + await sharedMine("dev"); + expect(listMine).toHaveBeenCalledTimes(2); }); it("opens an accepted collection in the Library, keeping the namespace in use", async () => { From 60de11d332c8f22ab83c489f5c98a7f8d5d62976 Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Sat, 5 Dec 2026 03:12:50 +0530 Subject: [PATCH 12/28] dashboard: the add field's help and the docs say what an invitation by email does An email no account holds now gets an invitation, not a grant kept as typed; the refused add in the members dialog test is grants.invite's. The schema dump counts the namespace_invites table. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Lareb Zafar --- docs/features/dashboard.md | 9 ++++++--- docs/getting-started/connect-a-coding-agent.md | 5 +++-- frontend/src/components/SubjectHelp.tsx | 9 ++++----- frontend/src/flows/MembersDialog.loading.test.tsx | 13 ++++++++++--- schemas/schema.sql | 4 ++-- 5 files changed, 25 insertions(+), 15 deletions(-) diff --git a/docs/features/dashboard.md b/docs/features/dashboard.md index 4fd76e6f87b..2ecf0973dd1 100644 --- a/docs/features/dashboard.md +++ b/docs/features/dashboard.md @@ -122,9 +122,12 @@ repository's or collection's name points to Repositories or the Library instead. on a namespace you manage opens its members on the add field. The field takes a person's login handle, which their account menu shows under **Signed in as** and which may be an email, or a service account `sa:`. A collection's **Share** also takes a group -`group:`, an agent `agent:` or `everyone`. An email that is not a login handle reaches its owner only -once they sign in with it through single sign-on, or an operator links it to their account. -Until then the grant is kept as typed and reaches nobody. With sign-in on, **Settings** › +`group:`, an agent `agent:` or `everyone`. A login handle no account holds is refused. +Any other email gets an [invitation](namespaces-and-sharing.md#membership-and-grants). The add +shows its link to copy, and the server emails it when it sends mail. The members list it under +**Open invitations**, with **Cancel**, until it is accepted. Whoever opens the link signed in +accepts it on Namespaces in your org, which then switches to the namespace; a collection opens +in the Library. With sign-in on, **Settings** › **Tokens** links to Namespaces in your org for giving a person access: a token is for a tool, agent or script. diff --git a/docs/getting-started/connect-a-coding-agent.md b/docs/getting-started/connect-a-coding-agent.md index fe3312e5439..95d304b5923 100644 --- a/docs/getting-started/connect-a-coding-agent.md +++ b/docs/getting-started/connect-a-coding-agent.md @@ -9,8 +9,9 @@ Loom gives Claude Code, Codex and Cursor shared long-term memory through plugins tools connected to the same self-hosted server. Invite each teammate to the team's namespace: **Invite people to this namespace** in the namespace picker, with that namespace picked, or **Invite** on Namespaces in your org. Each teammate makes their own token, and -their agents find the facts others save. A teammate without a dashboard account gets a token -from an operator (`loom mint-token`). Install the plugin or MCP entry below; the next +their agents find the facts others save. A teammate without an account is invited by email +and accepts once signed up. Where nobody can sign up, an operator makes their token +(`loom mint-token`). Install the plugin or MCP entry below; the next session can recall what an agent saved. What the Claude Code and Codex plugins send to Loom is in [data handling](../features/integrations/claude-code.md#data-handling). Conversation recording is off by default; the namespace owner turns it on with the **Record conversations** diff --git a/frontend/src/components/SubjectHelp.tsx b/frontend/src/components/SubjectHelp.tsx index ba0e03d98ad..8459b76b954 100644 --- a/frontend/src/components/SubjectHelp.tsx +++ b/frontend/src/components/SubjectHelp.tsx @@ -1,12 +1,11 @@ -/** What a spelling in an add field reaches: a namespace's members and a repository's readers - * take the same subjects through `grants.create`, and a collection also takes a group, an agent - * and everyone. */ +/** What a spelling in an add field reaches: a person through `grants.invite`, the others + * through `grants.create`; a collection also takes a group, an agent and everyone. */ export function SubjectHelp({ id, collection = false }: { id: string; collection?: boolean }) { return (

A login handle is the name a person signs in with, shown in their account menu under Signed in as; it may be an - email. Any other email reaches them only once they sign in with it through single sign-on, or an operator links it - to their account. A service account is sa:<name> + email. Any other email gets an invitation link, emailed too when this server sends mail; whoever opens it signed + in joins. A service account is sa:<name> {collection ? ( <> , a group group:<id>, an agent{" "} diff --git a/frontend/src/flows/MembersDialog.loading.test.tsx b/frontend/src/flows/MembersDialog.loading.test.tsx index 2d910b0245d..1f306f1df5d 100644 --- a/frontend/src/flows/MembersDialog.loading.test.tsx +++ b/frontend/src/flows/MembersDialog.loading.test.tsx @@ -6,11 +6,16 @@ import { act, render, screen, fireEvent, waitFor } from "../test/rtl"; import { MembersDialog } from "./MembersDialog"; import { useStore } from "../lib/state"; import * as api from "../api"; +import { invite } from "../api/invites"; vi.mock("../api", async (importOriginal) => { const actual = await importOriginal(); - return { ...actual, listGrants: vi.fn(), approveGrant: vi.fn(async () => ({})), createGrant: vi.fn() }; + return { ...actual, listGrants: vi.fn(), approveGrant: vi.fn(async () => ({})) }; }); +vi.mock("../api/invites", async (importOriginal) => ({ + ...(await importOriginal()), + invite: vi.fn(), +})); const PENDING = { subject: "reporter-private", @@ -91,13 +96,15 @@ describe("MembersDialog opened on the add field", () => { it("describes the field by a refused add's error, then the help", async () => { vi.mocked(api.listGrants).mockResolvedValue({ rows: [] } as never); - vi.mocked(api.createGrant).mockRejectedValueOnce(new Error("That subject is not allowed here")); + vi.mocked(invite).mockRejectedValueOnce(new Error("No account in clickhouse signs in as pat")); render( {}} org="clickhouse" namespace="team" startAdding />); const field = await screen.findByRole("textbox", { name: /member to add/ }); fireEvent.change(field, { target: { value: "pat" } }); fireEvent.keyDown(field, { key: "Enter" }); await waitFor(() => - expect(field).toHaveAccessibleDescription(/^That subject is not allowed here.*A login handle is the name/), + expect(field).toHaveAccessibleDescription( + /^No account in clickhouse signs in as pat.*A login handle is the name/, + ), ); }); diff --git a/schemas/schema.sql b/schemas/schema.sql index 865cd96f7e7..2dc61cfc079 100644 --- a/schemas/schema.sql +++ b/schemas/schema.sql @@ -16,13 +16,13 @@ -- Do NOT hand-edit. Edit schemas/migrations/*.sql and re-dump. -- CI verifies this file matches what migrations would produce. -- --- Counts: 198 tables + 5 views + 19 materialized views. +-- Counts: 199 tables + 5 views + 19 materialized views. CREATE DATABASE IF NOT EXISTS `loom`; CREATE DATABASE IF NOT EXISTS `loom_telemetry`; -- ====================================================================== --- Tables (198) +-- Tables (199) -- ====================================================================== -- loom.acl_versions From ee00959e4667cb4e6d5a30c8dd4fc9dbd218597a Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Sat, 5 Dec 2026 03:32:24 +0530 Subject: [PATCH 13/28] grants: keep the downgrade refusal's role as a field; SDK surface snapshot The accept path read the held role from the refusal's structured field, through str(), which the exception-text ratchet refuses; the SDK surface snapshot gains the four invitation methods. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Lareb Zafar --- server/identity/app/invites.py | 2 +- tests/unit/snapshots/sdk_public_api.json | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/server/identity/app/invites.py b/server/identity/app/invites.py index dcf270f6a89..f42f89c481e 100644 --- a/server/identity/app/invites.py +++ b/server/identity/app/invites.py @@ -234,5 +234,5 @@ async def _grant(invite: domain.Invite, subject: str) -> GrantRoleStr: issuer=invite.created_by, ) except GrantWouldDowngradeError as e: - return _role(str(e.extra["current_role"])) + return _role(e.extra["current_role"]) return role diff --git a/tests/unit/snapshots/sdk_public_api.json b/tests/unit/snapshots/sdk_public_api.json index 23492cbfac7..559ba100c0e 100644 --- a/tests/unit/snapshots/sdk_public_api.json +++ b/tests/unit/snapshots/sdk_public_api.json @@ -783,18 +783,34 @@ "grants": { "class": "GrantsOps", "methods": { + "accept_invite": [ + "body", + "options" + ], "approve": [ "body", "options" ], + "cancel_invite": [ + "body", + "options" + ], "create": [ "body", "options" ], + "invite": [ + "body", + "options" + ], "list": [ "body", "options" ], + "list_invites": [ + "body", + "options" + ], "pending_for_me": [ "body", "options" From 8fc527dd9b002ada2ce630f7cd44f5eb38ded1a5 Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Sat, 5 Dec 2026 03:32:24 +0530 Subject: [PATCH 14/28] grants: an open invitation keeps its name in use Accepting an invitation grants its role on whatever the name then holds, so an open, unexpired one counts in the in-use check as a live grant does: a name retired with one outstanding is not registered as new by someone else. The cell scan judges the table as one whose org the writing request checked. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Lareb Zafar --- docs/architecture/security.md | 4 ++-- server/identity/store/namespace_census.py | 11 +++++++---- tests/analyzer/shapes.txt | 4 ++-- tests/unit/test_cell_scan_tables.py | 1 + tests/unit/test_signup_name_in_use.py | 12 ++++++++++++ 5 files changed, 24 insertions(+), 8 deletions(-) diff --git a/docs/architecture/security.md b/docs/architecture/security.md index 2299dadb8b5..9082e76eb17 100644 --- a/docs/architecture/security.md +++ b/docs/architecture/security.md @@ -906,8 +906,8 @@ made while another change to that account runs answers 409 `SIGNUP_IN_PROGRESS`, says only that a change is running. In use means a `loom.namespaces` row, a configured code-plane repository or tracker namespace, any row in a table the erasure census counts by namespace (`census.namespace_tables`), tombstoned or not, a live row in a table whose -rows a later owner would inherit (`namespace_census.STATE_TABLES`: grants, webhooks, task -inboxes, sources and the like), or, on the Postgres authority, a memory there +rows a later owner would inherit (`namespace_census.STATE_TABLES`: grants, open invitations, +webhooks, task inboxes, sources and the like), or, on the Postgres authority, a memory there (`steps_pg.pg_holds_namespace`). Every other table keyed by namespace is exempt with a reason (`tests/unit/test_in_use_coverage.py`), which a new table cannot skip. A namespace can hold such rows without a registry row when auto-registration failed or was off, for diff --git a/server/identity/store/namespace_census.py b/server/identity/store/namespace_census.py index bdf5e7bf4b0..f759257f500 100644 --- a/server/identity/store/namespace_census.py +++ b/server/identity/store/namespace_census.py @@ -74,12 +74,15 @@ async def unregistered_live( _AT = "org = {org:String} AND namespace = {ns:String}" # Tables outside the erasure census whose live rows a later owner of the name would -# inherit (a grant, an outside target, a source, a mirror, a tree node, an identity -# link, an open erasure), each with the condition that makes its row live. Every other -# table keyed by namespace is counted by the census or exempt with a reason -# (tests/unit/test_in_use_coverage.py). +# inherit (a grant, an open invitation, an outside target, a source, a mirror, a tree +# node, an identity link, an open erasure), each with the condition that makes its row +# live. Every other table keyed by namespace is counted by the census or exempt with a +# reason (tests/unit/test_in_use_coverage.py). STATE_TABLES: dict[str, str] = { "loom.namespace_grants": f"FINAL WHERE {_AT} AND {LIVE_GRANT}", + # Accepting one grants its role on whatever the name then holds. + "loom.namespace_invites": f"FINAL WHERE {_AT} AND state = 'open'" + " AND expires_at > toUInt32(now())", "loom.memory_webhooks": f"FINAL WHERE {_AT} AND is_deleted = 0", "loom.task_inboxes": "FINAL WHERE org = {org:String} AND owner_namespace = {ns:String}" " AND is_deleted = 0", diff --git a/tests/analyzer/shapes.txt b/tests/analyzer/shapes.txt index 2b17f29e6b7..4a2a6c82241 100644 --- a/tests/analyzer/shapes.txt +++ b/tests/analyzer/shapes.txt @@ -121,7 +121,6 @@ 0c999f060efc SELECT proposal_policy FROM loom.namespaces FINAL WHERE org = {org:String} AND namespace = {ns:String} LIMIT ? 0cfc88297bf0 SELECT count() AS n FROM loom.knowledge_ingestions WHERE org = {org:String} AND namespace = {ns:String} 0d0074d068cf SELECT queue_id, agent, user_id, session_id, status, attempts, message_count, content_chars, written, last_error, enqueued_at, updated_at FROM loom.memory_extraction_queue FINAL PREWHERE org = {org:St -0d61f55e9bf0 -- schemas/schema.sql -- -- Reference dump of `loom.*` and `loom_telemetry.*`: what replaying schemas/migrations/*.sql -- produces, auto-generated by scripts/ops/dump_schema.py from a live -- ClickHou 0db9931937d8 SELECT count() AS n FROM loom.memory WHERE org = {org:String} AND has(tags, ?) AND hasAny(tags, {src:Array(String)}) AND hasAny(arrayMap(t -> (namespace, t), tags), {pairs:Array(Tuple(String, String)) 0df388be7e18 SELECT count() AS n FROM loom.memory_projection_failures WHERE org = {org:String} AND (JSONExtractString(payload, ?) = {uid:String} OR arrayExists(e -> JSONExtractString(e, ?) = {uid:String}, JSONExtr 0df8d59119a4 SELECT org, namespace, policy_id, effect, description, actions, condition, enabled, mode, created_by, created_at, updated_at, tombstoned_at FROM loom.namespace_policies FINAL WHERE org = {org:String} @@ -411,6 +410,7 @@ 2f87519d6c67 SELECT count() AS n FROM loom.memory_records FINAL WHERE org = {org:String} AND namespace IN {ns:Array(String)} AND tombstoned_at IS NULL 2fa5c1f4e23c SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, -- The content hash, for the read receipt of a hit this 2fab97e447f4 SELECT count() AS n FROM loom.entity_vectors FINAL WHERE org = {org:String} AND namespace IN {ns:Array(String)} AND tombstoned_at IS NULL +2fb19a9fc0de -- schemas/schema.sql -- -- Reference dump of `loom.*` and `loom_telemetry.*`: what replaying schemas/migrations/*.sql -- produces, auto-generated by scripts/ops/dump_schema.py from a live -- ClickHou 2fc0cc735773 SELECT toString(evidence_id) AS eid, session_id, role, actor, toString(observed_at) AS observed, content, matched FROM ( SELECT evidence_id, session_id, role, actor, observed_at, content, tombstoned_a 2fd8ca033214 DELETE FROM loom.memory_chunks WHERE org = {org:String} AND namespace = {ns:String} AND agent = {a:String} AND user_id = {u:String} AND parent_memory_key = {k:String} AND if(session_id = {ss:String}, 303a1827c22d SELECT DISTINCT msg_id FROM loom.conversations WHERE org = {org:String} AND namespace = {ns:String} AND thread_id = {tid:String} AND msg_id IN {mids:Array(String)} AND is_saved AND tombstoned_at IS NU @@ -546,7 +546,6 @@ 3e00482285b2 SELECT count() AS n FROM loom.entity_vectors WHERE org = {org:String} AND namespace = {ns:String} 3e18758b5b32 ALTER TABLE loom.session_outcomes_by_user DELETE WHERE (org = {org:String} AND namespace IN {ns:Array(String)}) AND ({erasure_mutation_tag:String} = {erasure_mutation_tag:String}) SETTINGS mutations_s 3e2075d7a93f SELECT count() AS n FROM loom.memory_record_fields FINAL WHERE org = {org:String} AND namespace = {ns:String} AND tombstoned_at IS NULL -3e2b5291eea1 SELECT ? AS in_use FROM ((SELECT ? FROM loom.namespace_grants FINAL WHERE org = {org:String} AND namespace = {ns:String} AND revoked_at IS NULL AND status = ? LIMIT ?) UNION ALL (SELECT ? FROM loom.me 3e750c517754 SELECT count() AS n FROM loom.memory_chunk_sources FINAL WHERE org = {org:String} AND namespace = {ns:String} AND tombstoned_at IS NULL 3ea44fb37980 ALTER TABLE loom.session_briefs DELETE WHERE (org = {org:String} AND namespace IN {ns:Array(String)}) AND ({erasure_mutation_tag:String} = {erasure_mutation_tag:String}) SETTINGS mutations_sync = ? 3eb6ce41ac13 SELECT agent, user_id, session_id, memory_key, memory_type, content_excerpt, toString(created_at) AS created_at, toString(valid_at) AS valid_at, version FROM loom.memory_embeddings FINAL WHERE org = { @@ -1344,6 +1343,7 @@ 93b6309f14f7 SELECT agent, count() AS rows, count() OVER () AS total, sum(count()) OVER () AS total_rows FROM loom.memory FINAL WHERE org = {org:String} AND namespace = {ns:String} AND tombstoned_at IS NULL AND st 93ec8d6c0770 SELECT run_id, toString(memory_id) AS mid, event_type, credited_at, actor, agent, consumer, sum(event_count) AS net, count() AS n FROM loom.memory_usage_events WHERE org = {org:String} AND namespace = 93fb8239f3f5 SELECT count() AS n FROM loom.memory_record_fields FINAL WHERE org = {org:String} AND tombstoned_at IS NULL AND namespace IN {ns:Array(String)} +9454d42e8f4e SELECT ? AS in_use FROM ((SELECT ? FROM loom.namespace_grants FINAL WHERE org = {org:String} AND namespace = {ns:String} AND revoked_at IS NULL AND status = ? LIMIT ?) UNION ALL (SELECT ? FROM loom.na 945db02b838d SELECT count() AS n FROM loom.session_brief_revisions WHERE org = {org:String} AND namespace IN {ns:Array(String)} AND ? 946786a56b8c SELECT agent, user_id, session_id, memory_key FROM loom.memory FINAL WHERE org = {org:String} AND namespace = {ns:String} AND tombstoned_at IS NULL AND startsWith(source_trace, {trace:String}) AND (ag 9476186d6a8c SELECT c.category_id AS category_id, count() AS rows FROM (SELECT memory_key, category_id FROM loom.memory_categories FINAL WHERE org = {org:String} AND namespace = {ns:String} AND tombstoned_at IS NU diff --git a/tests/unit/test_cell_scan_tables.py b/tests/unit/test_cell_scan_tables.py index e4cb5cee0e7..b59e031c78f 100644 --- a/tests/unit/test_cell_scan_tables.py +++ b/tests/unit/test_cell_scan_tables.py @@ -137,6 +137,7 @@ "loom.memory_webhooks", "loom.namespace_calibration_result", "loom.namespace_grants", + "loom.namespace_invites", "loom.namespace_guides", "loom.namespace_ontology", "loom.namespace_policies", diff --git a/tests/unit/test_signup_name_in_use.py b/tests/unit/test_signup_name_in_use.py index 58c35b7ab67..700137ead43 100644 --- a/tests/unit/test_signup_name_in_use.py +++ b/tests/unit/test_signup_name_in_use.py @@ -481,6 +481,18 @@ def _held(*rows: str) -> bool: " VALUES ('dev', 'team', 'kim', {flag}, 1)", ("false", "true"), ), + ( + "INSERT INTO loom.namespace_invites (org, namespace, invite_id, role, created_by," + " created_at, expires_at, state, changed_at) VALUES ('dev', 'team', 'i', 'writer'," + " 'kim', now64(3), toUInt32(now()) + 3600, {flag}, now64(3))", + ("'open'", "'cancelled'"), + ), + ( + "INSERT INTO loom.namespace_invites (org, namespace, invite_id, role, created_by," + " created_at, expires_at, changed_at) VALUES ('dev', 'team', 'i', 'writer'," + " 'kim', now64(3), toUInt32(now()) {flag}, now64(3))", + ("+ 3600", "- 1"), + ), ( "INSERT INTO loom.sso_links (email, org, namespace, linked, version)" " VALUES ('kim@x.test', 'dev', 'team', {flag}, 1)", From 503539f0f38505e10a08e7de9a0a5b1924c607dd Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Sat, 5 Dec 2026 03:51:58 +0530 Subject: [PATCH 15/28] grants: audit an acceptance without its secret; test the SMTP transport and the row columns grants.accept_invite records the invitation by the hash it is stored under, never the link's secret. A test drives the SMTP client through both schemes, its timeout and the refused login without STARTTLS; another holds every invitation write to the table's columns, which classifies loom.namespace_invites as a builder table. The journal test lists migration 123. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Lareb Zafar --- server/identity/api/ops_grants.py | 2 + server/identity/app/invites.py | 14 +++ tests/unit/test_audit_subject_credentials.py | 15 +++ tests/unit/test_grants_invite.py | 103 ++++++++++++++++++- tests/unit/test_rmt_write_paths.py | 1 + tests/unit/test_schema_baseline.py | 1 + 6 files changed, 135 insertions(+), 1 deletion(-) diff --git a/server/identity/api/ops_grants.py b/server/identity/api/ops_grants.py index aac8bd60fb6..c51a627311c 100644 --- a/server/identity/api/ops_grants.py +++ b/server/identity/api/ops_grants.py @@ -38,6 +38,7 @@ handle_grants_revoke, ) from server.identity.app.invites import ( + accept_audit_subject, handle_grants_accept_invite, handle_grants_cancel_invite, handle_grants_invite, @@ -177,6 +178,7 @@ idempotent=False, required_role=Role.VIEWER, audit=True, + audit_subject=accept_audit_subject, skip_namespace_authz=True, ) diff --git a/server/identity/app/invites.py b/server/identity/app/invites.py index f42f89c481e..9b962fcb967 100644 --- a/server/identity/app/invites.py +++ b/server/identity/app/invites.py @@ -16,6 +16,7 @@ import re import time from datetime import UTC, datetime +from typing import Any from server.auth.attempts import Attempts from server.auth.grant_claims import invite_change @@ -222,6 +223,19 @@ async def handle_grants_accept_invite(input: GrantsAcceptInviteInput) -> GrantsA return GrantsAcceptInviteOutput(namespace=input.namespace, role=role) +def accept_audit_subject( + input: GrantsAcceptInviteInput, response: dict[str, Any] +) -> dict[str, Any]: + """What an acceptance's audit row records, never the link's secret: the invitation + spent, by the hash it is stored under, and the role the caller holds now.""" + return { + "org": input.org, + "namespace": input.namespace, + "invite_id": domain.invite_id(input.secret), + "role": response["role"], + } + + async def _grant(invite: domain.Invite, subject: str) -> GrantRoleStr: """The invitation's role for `subject`, stamped as granted by its maker; a higher role they hold already stands.""" diff --git a/tests/unit/test_audit_subject_credentials.py b/tests/unit/test_audit_subject_credentials.py index 9d3bc2d607d..9fa6bb788e2 100644 --- a/tests/unit/test_audit_subject_credentials.py +++ b/tests/unit/test_audit_subject_credentials.py @@ -131,6 +131,21 @@ def test_code_repo_add_audits_what_was_registered_not_what_was_asked() -> None: assert subject["authenticated"] is False +def test_grants_accept_invite_audits_the_invitation_by_its_hash() -> None: + from server.identity.api.models_grants import GrantsAcceptInviteInput + from server.identity.domain.invites import invite_id + + accept = GrantsAcceptInviteInput(org="acme", namespace="team", secret=SECRET) + subject = _subject("grants.accept_invite", accept, {"namespace": "team", "role": "writer"}) + _assert_no_credential(subject) + assert subject == { + "org": "acme", + "namespace": "team", + "invite_id": invite_id(SECRET), + "role": "writer", + } + + def test_the_matcher_tells_credentials_from_lookalikes() -> None: for name in ( "password", diff --git a/tests/unit/test_grants_invite.py b/tests/unit/test_grants_invite.py index 11a7d24dd34..d6376c5f103 100644 --- a/tests/unit/test_grants_invite.py +++ b/tests/unit/test_grants_invite.py @@ -6,10 +6,12 @@ from __future__ import annotations import contextlib +import smtplib import time from collections.abc import AsyncIterator, Iterator from dataclasses import replace -from typing import Any +from datetime import UTC, datetime +from typing import Any, ClassVar from urllib.parse import parse_qs, urlsplit import pytest @@ -32,8 +34,10 @@ from server.identity.app import invite_mail from server.identity.app import invites as mod from server.identity.domain import invites as domain +from server.identity.store import invites as invites_repo from server.operations.base import Role from server.settings import settings +from tests.unit.schema_ddl import column_names class World: @@ -318,3 +322,100 @@ async def test_no_mail_settings_send_nothing(monkeypatch: pytest.MonkeyPatch) -> assert "https://x/l#s" in sent[0].get_content() # A header with a line break is refused by the email library: reported as not sent. assert await invite_mail.send_invite("m@example.com\nBcc: x@y.z", **args) is False + + +class _SMTP: + """smtplib's client as `_send` drives it, recording what it was asked.""" + + opened: ClassVar[list[tuple[str, int, float]]] = [] + last: ClassVar[_SMTP] + starttls_offered = True + + def __init__(self, host: str, port: int, *, timeout: float, context: Any = None) -> None: + self.calls: list[Any] = [] + type(self).opened.append((host, port, timeout)) + type(self).last = self + + def __enter__(self) -> _SMTP: + return self + + def __exit__(self, *_: object) -> None: + return None + + def ehlo(self) -> None: + self.calls.append("ehlo") + + def has_extn(self, name: str) -> bool: + return self.starttls_offered and name == "starttls" + + def starttls(self, *, context: Any) -> None: + self.calls.append("starttls") + + def login(self, user: str, password: str) -> None: + self.calls.append(("login", user, password)) + + def send_message(self, msg: Any) -> None: + self.calls.append("send") + + +def test_smtp_is_reached_within_the_timeout_and_logs_in_only_over_tls( + monkeypatch: pytest.MonkeyPatch, +) -> None: + monkeypatch.setattr(_SMTP, "opened", []) + monkeypatch.setattr(smtplib, "SMTP", _SMTP) + monkeypatch.setattr(smtplib, "SMTP_SSL", _SMTP) + monkeypatch.setattr(settings, "smtp_timeout_seconds", 3.0) + msg = invite_mail._message( + "m@example.com", inviter="ann", namespace="ns", role="writer", url="u", expires_at=0 + ) + + monkeypatch.setattr(settings, "smtp_url", "smtps://loom%40example.com:p%40ss@mail.example.com") + invite_mail._send(msg) + assert _SMTP.last.calls == [("login", "loom@example.com", "p@ss"), "send"] + + monkeypatch.setattr(settings, "smtp_url", "smtp://loom:pw@mail.example.com") + invite_mail._send(msg) + assert _SMTP.last.calls == ["ehlo", "starttls", "ehlo", ("login", "loom", "pw"), "send"] + assert _SMTP.opened == [("mail.example.com", 465, 3.0), ("mail.example.com", 587, 3.0)] + + # A server without STARTTLS never sees the password. + monkeypatch.setattr(_SMTP, "starttls_offered", False) + with pytest.raises(smtplib.SMTPNotSupportedError): + invite_mail._send(msg) + assert _SMTP.last.calls == ["ehlo"] + + +class _Rows: + def __init__(self) -> None: + self.rows: list[dict[str, Any]] = [] + + async def query_one(self, sql: str, params: dict[str, Any]) -> dict[str, Any]: + return {"v": len(self.rows) + 1} # `next_version`'s read + + async def insert(self, table: str, rows: list[dict[str, Any]], **_: Any) -> None: + assert table == "loom.namespace_invites" + self.rows.extend(rows) + + +@pytest.mark.asyncio +async def test_every_write_of_an_invitation_carries_every_column() -> None: + """Under FINAL a column a rewrite left out would fall back to its default.""" + ch = _Rows() + made = datetime(2026, 1, 1, tzinfo=UTC) + invite = domain.Invite( + org="acme", + namespace="team", + invite_id="h", + email="m@example.com", + role="writer", + created_by="ann", + created_at=made, + expires_at=1, + ) + await invites_repo.put(invite, ch=ch) # type: ignore[arg-type] + await invites_repo.put(invite.settled("accepted", "lee", made), ch=ch) # type: ignore[arg-type] + assert [sorted(r) for r in ch.rows] == [sorted(column_names("namespace_invites"))] * 2 + assert [(r["state"], r["accepted_by"], r["version"]) for r in ch.rows] == [ + ("open", "", 1), + ("accepted", "lee", 2), + ] diff --git a/tests/unit/test_rmt_write_paths.py b/tests/unit/test_rmt_write_paths.py index b902df8309a..ab1caba4e7c 100644 --- a/tests/unit/test_rmt_write_paths.py +++ b/tests/unit/test_rmt_write_paths.py @@ -154,6 +154,7 @@ "memory_versions": ("view", "memory_versions_mv"), "namespace_calibration_result": ("gap", "memory"), "namespace_grants": ("gap", "platform"), + "namespace_invites": ("builder", "test_grants_invite.py"), "namespace_ontology": ("gap", "platform"), "namespace_policies": ("builder", "test_repository_column_sets_match_schema.py"), "namespace_types": ("gap", "platform"), diff --git a/tests/unit/test_schema_baseline.py b/tests/unit/test_schema_baseline.py index 64a7fa1090e..a82f85ad835 100644 --- a/tests/unit/test_schema_baseline.py +++ b/tests/unit/test_schema_baseline.py @@ -178,6 +178,7 @@ def test_the_journal_files() -> None: "120_usage_label_provenance.sql", "121_code_repo_base_namespace.sql", "122_read_receipts.sql", + "123_namespace_invites.sql", ] From ddc88166d1016f71649731dea2e04b96b02a1c3f Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Sat, 5 Dec 2026 04:18:05 +0530 Subject: [PATCH 16/28] grants: an invitation never outlasts its maker's admin, nor admits a second person Accepting spends the link under its lease and grants after leaving it, so the grant's claims and an admin grant's fan-out never nest under the invitation's; after a failed grant the link opens again only when no grant at or above its role stands. When the maker's admin came from their own grant (recheck_maker, a new column of migration 123), accepting reads that grant again and refuses unless it still reaches admin, failing closed. Where sign-in is single sign-on only, an email no account holds is granted as typed, as an add by email did before. An invitation is made only on an active namespace. grants.invite's audit row names who got the role or the invitation, never the address. The four ops carry descriptions; an unknown state reads as closed; a cancel records no accepter; the SMTP timeout is per step. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Lareb Zafar --- docs/reference/configuration.md | 2 +- docs/reference/operations.md | 8 +- docs/reference/operations/grants.md | 18 ++- loom.example.yaml | 5 +- schemas/loom-settings.schema.json | 2 +- schemas/migrations/123_namespace_invites.sql | 5 +- schemas/schema.sql | 1 + sdk/go/wire/models.gen.go | 2 +- sdk/python/loom/ops.py | 16 ++ sdk/ruby/lib/clickhouse/loom/generated/ops.rb | 4 + server/auth/grant_claims.py | 6 +- server/identity/api/models_grants.py | 23 ++- server/identity/api/ops_grants.py | 2 + server/identity/app/invites.py | 120 ++++++++++++--- server/identity/domain/invites.py | 35 ++--- server/identity/store/invites.py | 4 +- server/settings/catalog.py | 5 +- server/transport/mcp_descriptions.py | 29 +++- tests/analyzer/shapes.txt | 2 +- tests/integration/test_grants_invite.py | 48 ++++++ tests/unit/test_audit_subject_credentials.py | 17 +++ tests/unit/test_grants_invite.py | 140 +++++++++++++++++- 22 files changed, 415 insertions(+), 79 deletions(-) diff --git a/docs/reference/configuration.md b/docs/reference/configuration.md index b932d379785..ba2cea9996a 100644 --- a/docs/reference/configuration.md +++ b/docs/reference/configuration.md @@ -138,7 +138,7 @@ Authentication, tokens and identity providers. | `LOOM_SELF_SIGNUP_ORG` | `str` | `'dev'` | | Default org for self-signed tokens. | | `LOOM_SMTP_URL` | `str` | *(unset)* | | The mail server an invitation is emailed through: `smtps://user:password@host:465` (TLS from the start) or `smtp://user:password@host:587` (STARTTLS, which a login requires). Empty: no email is sent, and whoever makes an invitation sends its link. | | `LOOM_MAIL_FROM` | `str` | `''` | | The From address of an invitation email, e.g. `Loom `. Empty sends none, as does an empty smtp_url or public_base_url (the link needs it). | -| `LOOM_SMTP_TIMEOUT_SECONDS` | `float` | `10.0` | | Seconds to wait on the mail server for one invitation email; past it the email is reported not sent, and the link is shown to pass on. | +| `LOOM_SMTP_TIMEOUT_SECONDS` | `float` | `10.0` | | Seconds each step of sending an invitation email (connecting, TLS, the login, each command) may wait on the mail server; past it the email is reported not sent, and the link is shown to pass on. grants.invite answers after the send. | | `LOOM_INVITE_TTL_SECONDS` | `int` | `604800` | | Seconds an invitation link stays valid, at most 30 days: it admits whoever opens it. | | `LOOM_IDENTITY_PROVIDER` | `'' \| 'single-user' \| 'trust-network' \| 'gateway'` | `''` | | How callers authenticate: "single-user" (no auth, one anonymous identity), "trust-network" (self-signup, first claim wins) or "gateway" (an upstream proxy mints short-lived Loom JWTs with the shared HS256 secret; Loom only validates). Empty = inferred from auth_required and self_signup at boot. | | `LOOM_DASHBOARD_REDIRECT_URL` | `str` | `''` | | When set, a dashboard page load redirects (302) here instead of serving the SPA (Loom behind an aggregator). Deployment-specific; never hardcode. | diff --git a/docs/reference/operations.md b/docs/reference/operations.md index 60e5267e87c..296800be50b 100644 --- a/docs/reference/operations.md +++ b/docs/reference/operations.md @@ -376,13 +376,13 @@ Fields for every `grants` op: [operations/grants.md](operations/grants.md). | Operation | Summary | Role | Kind | Listed under `all` | Audit | | --- | --- | --- | --- | --- | --- | -| [`grants.accept_invite`](operations/grants.md#grantsaccept_invite) | | viewer | write | no | yes | +| [`grants.accept_invite`](operations/grants.md#grantsaccept_invite) | Accept an invitation link as the signed-in person. | viewer | write | no | yes | | [`grants.approve`](operations/grants.md#grantsapprove) | Approve (or reject) a pending grant request. | admin | idempotent | no | yes | -| [`grants.cancel_invite`](operations/grants.md#grantscancel_invite) | | admin | idempotent | no | yes | +| [`grants.cancel_invite`](operations/grants.md#grantscancel_invite) | Cancel an open invitation, so its link admits nobody. | admin | idempotent | no | yes | | [`grants.create`](operations/grants.md#grantscreate) | Grant another subject (user or service-account) viewer / writer / admin role on a namespace. | admin | idempotent | yes | yes | -| [`grants.invite`](operations/grants.md#grantsinvite) | | admin | write | no | yes | +| [`grants.invite`](operations/grants.md#grantsinvite) | Give a person a role on a namespace by login handle or email. | admin | write | no | yes | | [`grants.list`](operations/grants.md#grantslist) | List active grants on a namespace — who has access, at which role. | viewer | read | yes | | -| [`grants.list_invites`](operations/grants.md#grantslist_invites) | | admin | idempotent | no | | +| [`grants.list_invites`](operations/grants.md#grantslist_invites) | List a namespace's open invitations. | admin | idempotent | no | | | [`grants.pending_for_me`](operations/grants.md#grantspending_for_me) | Every pending request in the namespaces the caller administers, in one statement. | viewer | read | no | | | [`grants.revoke`](operations/grants.md#grantsrevoke) | Remove a subject's grant on a namespace. | admin | idempotent | no | yes | | [`grants.share_agent`](operations/grants.md#grantsshare_agent) | Let another agent of the caller's trust read, or write, the caller's own namespace. | writer | idempotent | no | yes | diff --git a/docs/reference/operations/grants.md b/docs/reference/operations/grants.md index 7b3c91c31dd..e1dc564f083 100644 --- a/docs/reference/operations/grants.md +++ b/docs/reference/operations/grants.md @@ -10,6 +10,8 @@ Every op is `POST /v1/` over HTTP and the MCP tool `loom_`. The identity ## `grants.accept_invite` +Accept an invitation link as the signed-in person. + `POST /v1/grants.accept_invite` · MCP `loom_grants_accept_invite` · role `viewer` · write · audited · not listed under the MCP `all` toolset | Input field | Type | Default | Meaning | @@ -47,13 +49,15 @@ Approve (or reject) a pending grant request. ## `grants.cancel_invite` +Cancel an open invitation, so its link admits nobody. + `POST /v1/grants.cancel_invite` · MCP `loom_grants_cancel_invite` · role `admin` · idempotent · audited · not listed under the MCP `all` toolset | Input field | Type | Default | Meaning | | --- | --- | --- | --- | | `org` | `str` | required | The tenant (first element of the identity tuple). | | `namespace` | `str` | required | The namespace the op reads or writes. | -| `invite_id` | `str` | required | | +| `invite_id` | `str` | required | The invitation, as grants.invite and grants.list_invites return it. | | Output field | Type | Meaning | | --- | --- | --- | @@ -84,6 +88,8 @@ Grant another subject (user or service-account) viewer / writer / admin role on ## `grants.invite` +Give a person a role on a namespace by login handle or email. + `POST /v1/grants.invite` · MCP `loom_grants_invite` · role `admin` · write · audited · not listed under the MCP `all` toolset | Input field | Type | Default | Meaning | @@ -95,13 +101,13 @@ Grant another subject (user or service-account) viewer / writer / admin role on | Output field | Type | Meaning | | --- | --- | --- | -| `outcome` | `Literal['granted', 'invited']` | "granted": an account holds `to` and now has the role; "invited": no account holds the email, and `link_path` opens the invitation. | -| `role` | `Literal['viewer', 'writer', 'admin']` | | -| `subject` | `str` | On "granted", the login handle the grant is written under. | +| `outcome` | `Literal['granted', 'invited']` | "granted": the grant is written under `subject`; "invited": no account holds the email, and `link_path` opens the invitation. | +| `role` | `Literal['viewer', 'writer', 'admin']` | The role given, as asked. | +| `subject` | `str` | On "granted", the subject the grant is written under: the account's login handle, or, where sign-in is single sign-on only, the email as typed. | | `invite_id` | `str` | On "invited": the invitation, for grants.cancel_invite. | | `link_path` | `str` | On "invited": the dashboard path that accepts it, its secret in the fragment. | | `url` | `str` | `link_path` on the server's public_base_url; "" when that is unset. | -| `expires_at` | `datetime \| None` | On "invited": when the link stops working (UTC), seven days on. | +| `expires_at` | `datetime \| None` | On "invited": when the link stops working (UTC), `invite_ttl_seconds` after it was made. | | `emailed` | `bool` | On "invited": the link was emailed to `to` (the server has mail settings). | ## `grants.list` @@ -126,6 +132,8 @@ List active grants on a namespace — who has access, at which role. ## `grants.list_invites` +List a namespace's open invitations. + `POST /v1/grants.list_invites` · MCP `loom_grants_list_invites` · role `admin` · idempotent · not listed under the MCP `all` toolset | Input field | Type | Default | Meaning | diff --git a/loom.example.yaml b/loom.example.yaml index a66457bc76c..349fe19c7f0 100644 --- a/loom.example.yaml +++ b/loom.example.yaml @@ -887,8 +887,9 @@ settings: # none, as does an empty smtp_url or public_base_url (the link needs it). [restart] # mail_from: "" - # Seconds to wait on the mail server for one invitation email; past it the email is - # reported not sent, and the link is shown to pass on. [restart] + # Seconds each step of sending an invitation email (connecting, TLS, the login, each + # command) may wait on the mail server; past it the email is reported not sent, and + # the link is shown to pass on. grants.invite answers after the send. [restart] # smtp_timeout_seconds: 10.0 # Seconds an invitation link stays valid, at most 30 days: it admits whoever opens it. diff --git a/schemas/loom-settings.schema.json b/schemas/loom-settings.schema.json index 4bea3561c3c..d6a20e62e40 100644 --- a/schemas/loom-settings.schema.json +++ b/schemas/loom-settings.schema.json @@ -6893,7 +6893,7 @@ "exclusiveMinimum": 0, "maximum": 60, "type": "number", - "description": "Seconds to wait on the mail server for one invitation email; past it the email is reported not sent, and the link is shown to pass on." + "description": "Seconds each step of sending an invitation email (connecting, TLS, the login, each command) may wait on the mail server; past it the email is reported not sent, and the link is shown to pass on. grants.invite answers after the send." }, "storage_authority": { "default": "clickhouse", diff --git a/schemas/migrations/123_namespace_invites.sql b/schemas/migrations/123_namespace_invites.sql index d613be78470..33539c875f9 100644 --- a/schemas/migrations/123_namespace_invites.sql +++ b/schemas/migrations/123_namespace_invites.sql @@ -1,7 +1,9 @@ -- Invitations to a namespace, for a person no account signs in as yet. -- -- grants.invite writes one row per invitation: the role it gives, the email it was made --- for and who made it. The link it hands out carries a random secret; the row is keyed +-- for and who made it. `recheck_maker` says the maker was admin there through their own +-- grant, which grants.accept_invite reads again: an invitation never outlasts its maker's +-- admin. The link it hands out carries a random secret; the row is keyed -- by the secret's SHA-256 (`invite_id`), so a row read out of storage admits nobody. -- grants.accept_invite writes the row again with `state = 'accepted'` and who accepted -- it, grants.cancel_invite with `state = 'cancelled'`. An invitation lives for @@ -15,6 +17,7 @@ CREATE TABLE IF NOT EXISTS loom.namespace_invites email String DEFAULT '', role LowCardinality(String), created_by String, + recheck_maker Bool DEFAULT true, created_at DateTime64(3, 'UTC'), expires_at UInt32, state LowCardinality(String) DEFAULT 'open', diff --git a/schemas/schema.sql b/schemas/schema.sql index 2dc61cfc079..b293d6173d8 100644 --- a/schemas/schema.sql +++ b/schemas/schema.sql @@ -3402,6 +3402,7 @@ CREATE TABLE IF NOT EXISTS loom.namespace_invites `email` String DEFAULT '', `role` LowCardinality(String), `created_by` String, + `recheck_maker` Bool DEFAULT true, `created_at` DateTime64(3, 'UTC'), `expires_at` UInt32, `state` LowCardinality(String) DEFAULT 'open', diff --git a/sdk/go/wire/models.gen.go b/sdk/go/wire/models.gen.go index 9e054402ac6..63f859c4ed0 100644 --- a/sdk/go/wire/models.gen.go +++ b/sdk/go/wire/models.gen.go @@ -1,5 +1,5 @@ // Code generated by scripts/codegen/sdk_go_gen.py; DO NOT EDIT. -// Registry model schema SHA-256: b84d43a094a462f8b3b155e0b91a44e9001ce452ef110174b3bcf3e5dd5651b4 +// Registry model schema SHA-256: 238a22c33c0671b3041fa284bc4df8daa47a93d8a8a2670b6458e707dc81bec3 // Package wire contains the Go requests and responses for Loom operations. package wire diff --git a/sdk/python/loom/ops.py b/sdk/python/loom/ops.py index 7fd801691eb..d58386ba363 100644 --- a/sdk/python/loom/ops.py +++ b/sdk/python/loom/ops.py @@ -10431,12 +10431,16 @@ class TraversalNode(TypedDict, total=False): class GrantsAcceptInviteInput(TypedDict, total=False): + "Accept an invitation link as the signed-in person." + org: Required[str] namespace: Required[str] secret: Required[str] class GrantsAcceptInviteBody(TypedDict, total=False): + "Accept an invitation link as the signed-in person." + org: NotRequired[str] namespace: NotRequired[str] secret: Required[str] @@ -10476,12 +10480,16 @@ class GrantsApproveOutput(TypedDict, total=False): class GrantsCancelInviteInput(TypedDict, total=False): + "Cancel an open invitation, so its link admits nobody." + org: Required[str] namespace: Required[str] invite_id: Required[str] class GrantsCancelInviteBody(TypedDict, total=False): + "Cancel an open invitation, so its link admits nobody." + org: NotRequired[str] namespace: NotRequired[str] invite_id: Required[str] @@ -10518,6 +10526,8 @@ class GrantsCreateOutput(TypedDict, total=False): class GrantsInviteInput(TypedDict, total=False): + "Give a person a role on a namespace by login handle or email." + org: Required[str] namespace: Required[str] to: Required[str] @@ -10525,6 +10535,8 @@ class GrantsInviteInput(TypedDict, total=False): class GrantsInviteBody(TypedDict, total=False): + "Give a person a role on a namespace by login handle or email." + org: NotRequired[str] namespace: NotRequired[str] to: Required[str] @@ -10576,11 +10588,15 @@ class GrantEntry(TypedDict, total=False): class GrantsListInvitesInput(TypedDict, total=False): + "List a namespace's open invitations." + org: Required[str] namespace: Required[str] class GrantsListInvitesBody(TypedDict, total=False): + "List a namespace's open invitations." + org: NotRequired[str] namespace: NotRequired[str] diff --git a/sdk/ruby/lib/clickhouse/loom/generated/ops.rb b/sdk/ruby/lib/clickhouse/loom/generated/ops.rb index 207725a916e..7c223416b27 100644 --- a/sdk/ruby/lib/clickhouse/loom/generated/ops.rb +++ b/sdk/ruby/lib/clickhouse/loom/generated/ops.rb @@ -1175,6 +1175,7 @@ def traverse(body = nil, request_options: nil, **fields) # The `grants.*` operations. class GrantsOps < OpGroup # `grants.accept_invite` (viewer, writes, experimental). + # Accept an invitation link as the signed-in person. # Required: org, namespace, secret. def accept_invite(body = nil, request_options: nil, **fields) call_op("grants.accept_invite", body, fields, request_options) @@ -1188,6 +1189,7 @@ def approve(body = nil, request_options: nil, **fields) end # `grants.cancel_invite` (admin, writes, Idempotency-Key, experimental). + # Cancel an open invitation, so its link admits nobody. # Required: org, namespace, invite_id. def cancel_invite(body = nil, request_options: nil, **fields) call_op("grants.cancel_invite", body, fields, request_options) @@ -1200,6 +1202,7 @@ def create(body = nil, request_options: nil, **fields) end # `grants.invite` (admin, writes, experimental). + # Give a person a role on a namespace by login handle or email. # Required: org, namespace, to, role. def invite(body = nil, request_options: nil, **fields) call_op("grants.invite", body, fields, request_options) @@ -1212,6 +1215,7 @@ def list(body = nil, request_options: nil, **fields) end # `grants.list_invites` (admin, writes, Idempotency-Key, experimental). + # List a namespace's open invitations. # Required: org, namespace. def list_invites(body = nil, request_options: nil, **fields) call_op("grants.list_invites", body, fields, request_options) diff --git a/server/auth/grant_claims.py b/server/auth/grant_claims.py index fb2a22aa5a9..e48b2405f1f 100644 --- a/server/auth/grant_claims.py +++ b/server/auth/grant_claims.py @@ -17,10 +17,10 @@ `hand_down_lineage`); then an address's sign-up claim (`self_signup.email_claim`); then an org's collection tree or a SCIM group; then a subject's repository claim (`maintainers.repo_change`), the repository's admins and the namespaces' -admins, or the trusts; then an invitation (`invite_change`); then a bot or a grant -(several sorted by namespace). +admins, or the trusts; then a bot or a grant (several sorted by namespace). Taken the other way round, two changes wait each other out and both answer -503. +503. An invitation's claim (`invite_change`) is held alone: accepting spends the +link under it and grants after leaving it. """ from __future__ import annotations diff --git a/server/identity/api/models_grants.py b/server/identity/api/models_grants.py index d64bd1d9e8a..78982e0d2cd 100644 --- a/server/identity/api/models_grants.py +++ b/server/identity/api/models_grants.py @@ -213,22 +213,28 @@ class GrantsUnshareAgentOutput(BaseModel): class GrantsInviteInput(BaseModel): + """Give a person a role on a namespace by login handle or email.""" + org: str namespace: str # The person to give `role`: a login handle or an email. An account that signs in # under it (by its handle or a verified email) is granted the role at once; an email - # no account holds gets an invitation link; a handle no account holds is refused. + # no account holds gets an invitation link, or, where sign-in is single sign-on only, + # a grant that reaches that person at their first sign-in; a handle no account holds + # is refused. to: str = Field(min_length=1, max_length=320) # `viewer`, `writer` or `admin`; a code namespace takes only `viewer` and `admin`. role: GrantRoleStr class GrantsInviteOutput(BaseModel): - # "granted": an account holds `to` and now has the role; "invited": no account - # holds the email, and `link_path` opens the invitation. + # "granted": the grant is written under `subject`; "invited": no account holds the + # email, and `link_path` opens the invitation. outcome: Literal["granted", "invited"] + # The role given, as asked. role: GrantRoleStr - # On "granted", the login handle the grant is written under. + # On "granted", the subject the grant is written under: the account's login handle, + # or, where sign-in is single sign-on only, the email as typed. subject: str = "" # On "invited": the invitation, for grants.cancel_invite. invite_id: str = "" @@ -237,13 +243,15 @@ class GrantsInviteOutput(BaseModel): link_path: str = "" # `link_path` on the server's public_base_url; "" when that is unset. url: str = "" - # On "invited": when the link stops working (UTC), seven days on. + # On "invited": when the link stops working (UTC), `invite_ttl_seconds` after it was made. expires_at: datetime | None = None # On "invited": the link was emailed to `to` (the server has mail settings). emailed: bool = False class GrantsListInvitesInput(BaseModel): + """List a namespace's open invitations.""" + org: str namespace: str @@ -265,8 +273,11 @@ class GrantsListInvitesOutput(BaseModel): class GrantsCancelInviteInput(BaseModel): + """Cancel an open invitation, so its link admits nobody.""" + org: str namespace: str + # The invitation, as grants.invite and grants.list_invites return it. invite_id: str = Field(min_length=1, max_length=64) @@ -276,6 +287,8 @@ class GrantsCancelInviteOutput(BaseModel): class GrantsAcceptInviteInput(BaseModel): + """Accept an invitation link as the signed-in person.""" + org: str # The namespace the link names. namespace: str diff --git a/server/identity/api/ops_grants.py b/server/identity/api/ops_grants.py index c51a627311c..ab7658dad03 100644 --- a/server/identity/api/ops_grants.py +++ b/server/identity/api/ops_grants.py @@ -43,6 +43,7 @@ handle_grants_cancel_invite, handle_grants_invite, handle_grants_list_invites, + invite_audit_subject, ) from server.operations.base import Operation, Role @@ -141,6 +142,7 @@ idempotent=False, required_role=Role.ADMIN, audit=True, + audit_subject=invite_audit_subject, ) grants_list_invites = Operation( diff --git a/server/identity/app/invites.py b/server/identity/app/invites.py index 9b962fcb967..0d2ac27a445 100644 --- a/server/identity/app/invites.py +++ b/server/identity/app/invites.py @@ -6,8 +6,14 @@ emailed when the server has mail settings, which gives whoever opens it, once, the role, under the account they sign in with. A password account's email is never verified, so this is how a person is reached by email on a server without single -sign-on. A handle no account holds is refused, so a typo is never kept as a grant -for whoever signs up under it later. +sign-on. Where sign-in is single sign-on only (`oauth_login_provider = "oidc"`), every +account's email is verified by the identity provider, so the email is granted as typed +and reaches that person at their first sign-in, with no link to pass on. A handle no +account holds is refused, so a typo is never kept as a grant for whoever signs up +under it later. + +An invitation never outlasts its maker's admin: when that came from their own grant on +the namespace, accepting reads the grant again. """ from __future__ import annotations @@ -19,9 +25,11 @@ from typing import Any from server.auth.attempts import Attempts +from server.auth.authz import grant_role_for +from server.auth.fail_closed import unreadable from server.auth.grant_claims import invite_change from server.core.errors import GrantWouldDowngradeError, NotFoundError, ValidationError -from server.core.principals import SERVICE_ACCOUNT, has_aliases, is_reserved_subject +from server.core.principals import has_aliases, is_reserved_subject from server.identity.api.models_grants import ( GrantsAcceptInviteInput, GrantsAcceptInviteOutput, @@ -41,9 +49,10 @@ create_grant, ) from server.identity.domain import invites as domain +from server.identity.store import grants as grants_repo from server.identity.store import invites as invites_repo from server.identity.store import namespaces as namespaces_repo -from server.operations.base import GRANT_ROLES, GrantRoleStr +from server.operations.base import GRANT_ROLES, GrantRoleStr, Role, grant_rank from server.settings import settings # The open invitations a namespace lists. @@ -54,7 +63,10 @@ _mail_by_inviter = Attempts("invite.mail.inviter", 20, 3600) _mail_by_address = Attempts("invite.mail.address", 3, 86400) _EMAIL = re.compile(r"[^@\s]+@[^@\s]+\.[^@\s]+") -_GONE = "this invitation link is used, cancelled or expired: ask for a new one" +_GONE = ( + "this invitation link is used, cancelled or expired, or whoever made it no longer " + "administers the namespace: ask for a new one" +) def _role(value: str) -> GrantRoleStr: @@ -72,7 +84,7 @@ def _caller() -> str: def _person(to: str) -> str: """`to` as a person's spelling, or a refusal that names the op for the others.""" person = to.strip() - if not has_aliases(person) or is_reserved_subject(person) or person.startswith(SERVICE_ACCOUNT): + if not has_aliases(person) or is_reserved_subject(person): raise ValidationError( "invite a person by login handle or email; grants.create grants a service account, " "a group or everyone" @@ -96,12 +108,7 @@ async def handle_grants_invite(input: GrantsInviteInput) -> GrantsInviteOutput: _enforce_principal_target(input.namespace, person) subject = await _held(input.org, person) if subject is not None: - await create_grant( - GrantsCreateInput( - org=input.org, namespace=input.namespace, subject=person, role=input.role - ) - ) - return GrantsInviteOutput(outcome="granted", role=input.role, subject=subject) + return await _granted(input, person, subject) if "@" not in person: raise NotFoundError( f"no account in {input.org} signs in as {person!r}: check the login handle, " @@ -109,20 +116,45 @@ async def handle_grants_invite(input: GrantsInviteInput) -> GrantsInviteOutput: ) if not _EMAIL.fullmatch(person): raise ValidationError(f"{person!r} is not an email address") + if settings.oauth_login_provider == "oidc": + return await _granted(input, person, person) await _enforce_code_ceiling(input.org, input.namespace, input.role) + if not await namespaces_repo.is_active(input.org, input.namespace): + raise NotFoundError( + f"{input.org}/{input.namespace} is not an active namespace: register or restore it " + "before inviting anyone" + ) return await _invite(input, person.lower()) +async def _granted(input: GrantsInviteInput, person: str, subject: str) -> GrantsInviteOutput: + await create_grant( + GrantsCreateInput(org=input.org, namespace=input.namespace, subject=person, role=input.role) + ) + return GrantsInviteOutput(outcome="granted", role=input.role, subject=subject) + + +async def _recheck_maker(org: str, namespace: str, maker: str) -> bool: + """Whether accepting reads the maker's grant again: their admin here came from it, or + the read failed and cannot say. A maker their token made admin (a platform admin, an + operator's token) holds no such grant, which a later read could not tell from one + revoked.""" + role = await grant_role_for(org, namespace, maker) + return unreadable() or (role is not None and role.value >= Role.ADMIN.value) + + async def _invite(input: GrantsInviteInput, email: str) -> GrantsInviteOutput: secret = domain.new_secret() now = datetime.now(UTC) + maker = _caller() invite = domain.Invite( org=input.org, namespace=input.namespace, invite_id=domain.invite_id(secret), email=email, role=input.role, - created_by=_caller(), + created_by=maker, + recheck_maker=await _recheck_maker(input.org, input.namespace, maker), created_at=now, expires_at=int(now.timestamp()) + settings.invite_ttl_seconds, ) @@ -181,7 +213,7 @@ async def handle_grants_cancel_invite(input: GrantsCancelInviteInput) -> GrantsC invite = await invites_repo.get(input.org, input.namespace, input.invite_id) if invite is None or not invite.is_open(int(time.time())): return GrantsCancelInviteOutput(cancelled=False) - await invites_repo.put(invite.settled("cancelled", _caller(), datetime.now(UTC))) + await invites_repo.put(invite.cancelled(datetime.now(UTC))) return GrantsCancelInviteOutput(cancelled=True) @@ -210,19 +242,59 @@ async def handle_grants_accept_invite(input: GrantsAcceptInviteInput) -> GrantsA raise NotFoundError(_GONE) if not await namespaces_repo.is_active(input.org, input.namespace): raise NotFoundError(_GONE) - # Spent before the grant, under the claim: a link never lets two people in. - await invites_repo.put(invite.settled("accepted", subject, datetime.now(UTC))) - try: - role = await _grant(invite, subject) - except BaseException: - # Still under the claim, so no one took it since: a failed grant leaves the - # link open for another try. A failed put-back leaves it used, never open twice. - with contextlib.suppress(Exception): - await invites_repo.put(invite) - raise + if not await _maker_still_admin(invite): + raise NotFoundError(_GONE) + # Spent under the claim, before the grant: a link never lets two people in. The + # grant takes its own claims after this one, as `grant_claims` orders them. + await invites_repo.put(invite.accepted(subject, datetime.now(UTC))) + try: + role = await _grant(invite, subject) + except BaseException: + # A failed put-back leaves the link used, never open twice. + with contextlib.suppress(Exception): + await _reopen_unless_granted(invite, subject) + raise return GrantsAcceptInviteOutput(namespace=input.namespace, role=role) +async def _maker_still_admin(invite: domain.Invite) -> bool: + """The maker still holds admin through a grant, when their admin came from one; a + failed read refuses.""" + if not invite.recheck_maker: + return True + role = await grant_role_for(invite.org, invite.namespace, invite.created_by) + return role is not None and role.value >= Role.ADMIN.value + + +async def _reopen_unless_granted(invite: domain.Invite, subject: str) -> None: + """Open the link again after a failed grant, unless the grant landed before the + failure (a lost reply, a step after the write): then it stays used. A read that + fails raises, and the link stays used.""" + async with invite_change(invite.org, invite.namespace, invite.invite_id): + held = await grants_repo.find_active_grant(invite.org, invite.namespace, subject) + if held is not None and grant_rank(held.role) >= grant_rank(invite.role): + return + current = await invites_repo.get(invite.org, invite.namespace, invite.invite_id) + if current is not None and (current.state, current.accepted_by) == ("accepted", subject): + await invites_repo.put(invite) + + +def invite_audit_subject(input: GrantsInviteInput, response: dict[str, Any]) -> dict[str, Any]: + """What an invitation's audit row records: who got the role, or the invitation by the + hash it is stored under, never the address it was made for.""" + out = { + "org": input.org, + "namespace": input.namespace, + "role": response["role"], + "outcome": response["outcome"], + } + if response["outcome"] == "granted": + out["subject"] = response["subject"] + else: + out["invite_id"] = response["invite_id"] + return out + + def accept_audit_subject( input: GrantsAcceptInviteInput, response: dict[str, Any] ) -> dict[str, Any]: diff --git a/server/identity/domain/invites.py b/server/identity/domain/invites.py index eae74c5eb52..07790fd695b 100644 --- a/server/identity/domain/invites.py +++ b/server/identity/domain/invites.py @@ -2,7 +2,7 @@ The link carries a random secret; Loom keeps only its SHA-256 (`invite_id`), so a row read out of storage is not a working link. An invitation is open until it is -accepted, cancelled or `expires_at` passes. +accepted, cancelled or `expires_at` passes; a state this build does not know is closed. """ from __future__ import annotations @@ -11,13 +11,11 @@ import secrets from dataclasses import asdict, dataclass, replace from datetime import datetime -from typing import Any, Literal +from typing import Any from urllib.parse import urlencode from server.core.datetimes import as_aware_utc -InviteState = Literal["open", "accepted", "cancelled"] - def new_secret() -> str: return secrets.token_urlsafe(32) @@ -43,17 +41,20 @@ class Invite: created_by: str created_at: datetime expires_at: int - state: InviteState = "open" + # The maker's admin came from their own grant there, so accepting reads it again. + recheck_maker: bool = True + state: str = "open" accepted_by: str = "" changed_at: datetime | None = None def is_open(self, now: int) -> bool: return self.state == "open" and now < self.expires_at - def settled(self, state: InviteState, by: str, at: datetime) -> Invite: - return replace( - self, state=state, accepted_by=by if state == "accepted" else "", changed_at=at - ) + def accepted(self, by: str, at: datetime) -> Invite: + return replace(self, state="accepted", accepted_by=by, changed_at=at) + + def cancelled(self, at: datetime) -> Invite: + return replace(self, state="cancelled", changed_at=at) def row(self) -> dict[str, Any]: out = asdict(self) @@ -62,21 +63,17 @@ def row(self) -> dict[str, Any]: @classmethod def from_row(cls, r: dict[str, Any]) -> Invite: - state = str(r.get("state") or "open") return cls( org=str(r["org"]), namespace=str(r["namespace"]), invite_id=str(r["invite_id"]), - email=str(r.get("email") or ""), + email=str(r["email"]), role=str(r["role"]), - created_by=str(r.get("created_by") or ""), + created_by=str(r["created_by"]), + recheck_maker=bool(r["recheck_maker"]), created_at=as_aware_utc(r["created_at"]), expires_at=int(r["expires_at"]), - state="accepted" - if state == "accepted" - else "cancelled" - if state == "cancelled" - else "open", - accepted_by=str(r.get("accepted_by") or ""), - changed_at=as_aware_utc(r.get("changed_at")), + state=str(r["state"]), + accepted_by=str(r["accepted_by"]), + changed_at=as_aware_utc(r["changed_at"]), ) diff --git a/server/identity/store/invites.py b/server/identity/store/invites.py index 8f46143a2cb..33e243b1a5a 100644 --- a/server/identity/store/invites.py +++ b/server/identity/store/invites.py @@ -18,8 +18,8 @@ TABLE = "loom.namespace_invites" _COLUMNS = ( - "org, namespace, invite_id, email, role, created_by, created_at, expires_at, state, " - "accepted_by, changed_at" + "org, namespace, invite_id, email, role, created_by, recheck_maker, created_at, " + "expires_at, state, accepted_by, changed_at" ) diff --git a/server/settings/catalog.py b/server/settings/catalog.py index 327e411ba5b..ca04c2b9d69 100644 --- a/server/settings/catalog.py +++ b/server/settings/catalog.py @@ -467,8 +467,9 @@ def trusted_issuers(self) -> set[str]: # The From address of an invitation email, e.g. `Loom `. Empty # sends none, as does an empty smtp_url or public_base_url (the link needs it). mail_from: str = "" - # Seconds to wait on the mail server for one invitation email; past it the email is - # reported not sent, and the link is shown to pass on. + # Seconds each step of sending an invitation email (connecting, TLS, the login, each + # command) may wait on the mail server; past it the email is reported not sent, and + # the link is shown to pass on. grants.invite answers after the send. smtp_timeout_seconds: float = Field(default=10.0, gt=0, le=60) # Seconds an invitation link stays valid, at most 30 days: it admits whoever opens it. invite_ttl_seconds: int = Field(default=7 * 86400, ge=3600, le=30 * 86400) diff --git a/server/transport/mcp_descriptions.py b/server/transport/mcp_descriptions.py index aa39ac5db50..916cdffb0c1 100644 --- a/server/transport/mcp_descriptions.py +++ b/server/transport/mcp_descriptions.py @@ -463,11 +463,30 @@ def revision_policy(update: str) -> str: # ---- Grants (per-namespace access control) ---- "grants.create": ( "Grant another subject (user or service-account) viewer / writer " - "/ admin role on a namespace. Call when an admin wants to invite " - 'someone or change their role — "add Bob as writer on X", ' - '"give Carol admin on Y". The caller must already be admin on ' - "the target namespace. Lowering someone's current role is refused " - "(409 GRANT_WOULD_DOWNGRADE) unless replace=true is passed." + "/ admin role on a namespace. Call to grant a service account, a group " + 'or everyone, or to change a role — "give Carol admin on Y"; to add a ' + "person by login handle or email, call grants.invite. The caller must " + "already be admin on the target namespace. Lowering someone's current " + "role is refused (409 GRANT_WOULD_DOWNGRADE) unless replace=true is passed." + ), + "grants.invite": ( + "Give a person a role on a namespace by login handle or email. Call when " + 'an admin wants to add someone — "add bob@example.com as writer on X". ' + "An account that signs in under it is granted at once; any other email gets " + "a single-use invitation link (emailed when the server sends mail) to pass " + "on; a handle no account holds is refused." + ), + "grants.list_invites": ( + "List a namespace's open invitations: the address, role, maker and expiry " + "of each link not yet accepted, cancelled or expired. Caller must be admin." + ), + "grants.cancel_invite": ( + "Cancel an open invitation by its invite_id, so its link admits nobody. " + "Caller must be admin on the namespace." + ), + "grants.accept_invite": ( + "Accept an invitation link as the signed-in person: it grants its role on " + "the namespace it names. Call with the secret from the link's fragment." ), "grants.list": ( "List active grants on a namespace — who has access, at which " diff --git a/tests/analyzer/shapes.txt b/tests/analyzer/shapes.txt index 4a2a6c82241..b1e0a369557 100644 --- a/tests/analyzer/shapes.txt +++ b/tests/analyzer/shapes.txt @@ -410,7 +410,6 @@ 2f87519d6c67 SELECT count() AS n FROM loom.memory_records FINAL WHERE org = {org:String} AND namespace IN {ns:Array(String)} AND tombstoned_at IS NULL 2fa5c1f4e23c SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, -- The content hash, for the read receipt of a hit this 2fab97e447f4 SELECT count() AS n FROM loom.entity_vectors FINAL WHERE org = {org:String} AND namespace IN {ns:Array(String)} AND tombstoned_at IS NULL -2fb19a9fc0de -- schemas/schema.sql -- -- Reference dump of `loom.*` and `loom_telemetry.*`: what replaying schemas/migrations/*.sql -- produces, auto-generated by scripts/ops/dump_schema.py from a live -- ClickHou 2fc0cc735773 SELECT toString(evidence_id) AS eid, session_id, role, actor, toString(observed_at) AS observed, content, matched FROM ( SELECT evidence_id, session_id, role, actor, observed_at, content, tombstoned_a 2fd8ca033214 DELETE FROM loom.memory_chunks WHERE org = {org:String} AND namespace = {ns:String} AND agent = {a:String} AND user_id = {u:String} AND parent_memory_key = {k:String} AND if(session_id = {ss:String}, 303a1827c22d SELECT DISTINCT msg_id FROM loom.conversations WHERE org = {org:String} AND namespace = {ns:String} AND thread_id = {tid:String} AND msg_id IN {mids:Array(String)} AND is_saved AND tombstoned_at IS NU @@ -709,6 +708,7 @@ 511151c6fd23 ALTER TABLE loom.memory UPDATE tombstoned_at = {now:DateTime} WHERE (org = {org:String} AND tombstoned_at IS NULL AND has(tags, ?) AND hasAny(tags, {src:Array(String)}) AND hasAny(arrayMap(t -> (names 5163c1fd8d3c SELECT count() AS n FROM loom.memory_record_versions WHERE org = {org:String} AND namespace = {ns:String} 516db52eddcc SELECT count() AS n FROM loom.session_brief_revisions WHERE org = {org:String} AND namespace = {ns:String} AND ? +518a0f213ad6 -- schemas/schema.sql -- -- Reference dump of `loom.*` and `loom_telemetry.*`: what replaying schemas/migrations/*.sql -- produces, auto-generated by scripts/ops/dump_schema.py from a live -- ClickHou 51af520b7286 SELECT DISTINCT tier, qualified_name, symbol_id FROM loom.code_symbol_names WHERE org = {org:String} AND namespace = {ns:String} AND name IN {names:Array(String)} AND (qualified_name = {full:String} O 51bac3caaf99 SELECT count() AS n FROM loom.read_receipts WHERE org = {org:String} AND namespace = {ns:String} AND ? 51f1b6e27428 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, -- The content hash, for the read receipt of a hit this diff --git a/tests/integration/test_grants_invite.py b/tests/integration/test_grants_invite.py index 82638de01b3..21af27fae4e 100644 --- a/tests/integration/test_grants_invite.py +++ b/tests/integration/test_grants_invite.py @@ -109,3 +109,51 @@ def test_a_handle_an_account_signs_in_as_is_granted_at_once(control_plane_url: s ) assert r.status_code == 200, r.text assert (r.json()["outcome"], r.json()["link_path"]) == ("granted", "") + + +def _invite(base: str, token: str, org: str, ns: str, to: str) -> tuple[str, str]: + r = _post( + base, token, "grants.invite", {"org": org, "namespace": ns, "to": to, "role": "writer"} + ) + assert r.status_code == 200, r.text + made = r.json() + return made["invite_id"], parse_qs(urlsplit(made["link_path"]).fragment)["invite"][0] + + +def test_a_cancelled_link_is_unlisted_and_admits_nobody(control_plane_url: str) -> None: + org = unique_org("invite") + ns = f"ns-{uuid.uuid4().hex[:8]}" + admin = _person_token(org=org, subject="ann-admin", namespaces=[ns], roles=["admin"]) + _register(control_plane_url, admin, org, ns, "ann-admin") + invite_id, secret = _invite(control_plane_url, admin, org, ns, "michael@example.com") + + body = {"org": org, "namespace": ns, "invite_id": invite_id} + r = _post(control_plane_url, admin, "grants.cancel_invite", body) + assert (r.status_code, r.json()) == (200, {"cancelled": True}), r.text + listed = _post(control_plane_url, admin, "grants.list_invites", {"org": org, "namespace": ns}) + assert listed.json()["rows"] == [] + person = _person_token(org=org, subject="mlex", namespaces=[f"home-{ns}"], roles=["viewer"]) + accept = {"org": org, "namespace": ns, "secret": secret} + assert _post(control_plane_url, person, "grants.accept_invite", accept).status_code == 404 + + +def test_a_link_stops_when_its_maker_loses_admin(control_plane_url: str) -> None: + org = unique_org("invite") + ns = f"ns-{uuid.uuid4().hex[:8]}" + ann = _person_token(org=org, subject="ann-admin", namespaces=[ns], roles=["admin"]) + _register(control_plane_url, ann, org, ns, "ann-admin") # ann's admin is her own grant + _, secret = _invite(control_plane_url, ann, org, ns, "michael@example.com") + + # Another admin stays, so ann's grant can go. + grant = {"org": org, "namespace": ns, "subject": "bea-admin", "role": "admin"} + assert _post(control_plane_url, ann, "grants.create", grant).status_code == 200 + bea = _person_token(org=org, subject="bea-admin", namespaces=[ns], roles=["admin"]) + revoke = {"org": org, "namespace": ns, "subject": "ann-admin"} + r = _post(control_plane_url, bea, "grants.revoke", revoke) + assert r.status_code == 200 and r.json()["revoked"] is True, r.text + + person = _person_token(org=org, subject="mlex", namespaces=[f"home-{ns}"], roles=["viewer"]) + accept = {"org": org, "namespace": ns, "secret": secret} + r = _post(control_plane_url, person, "grants.accept_invite", accept) + assert r.status_code == 404, r.text + assert "no longer administers" in r.text diff --git a/tests/unit/test_audit_subject_credentials.py b/tests/unit/test_audit_subject_credentials.py index 9fa6bb788e2..e1376f31b72 100644 --- a/tests/unit/test_audit_subject_credentials.py +++ b/tests/unit/test_audit_subject_credentials.py @@ -146,6 +146,23 @@ def test_grants_accept_invite_audits_the_invitation_by_its_hash() -> None: } +def test_grants_invite_audits_who_got_the_role_never_the_address() -> None: + from server.identity.api.models_grants import GrantsInviteInput + + asked = GrantsInviteInput(org="acme", namespace="team", to="m@example.com", role="writer") + granted = {"outcome": "granted", "role": "writer", "subject": "mlex"} + assert _subject("grants.invite", asked, granted) == { + "org": "acme", + "namespace": "team", + "role": "writer", + "outcome": "granted", + "subject": "mlex", + } + invited = {"outcome": "invited", "role": "writer", "subject": "", "invite_id": "h"} + subject = _subject("grants.invite", asked, invited) + assert subject["invite_id"] == "h" and "m@example.com" not in json.dumps(subject) + + def test_the_matcher_tells_credentials_from_lookalikes() -> None: for name in ( "password", diff --git a/tests/unit/test_grants_invite.py b/tests/unit/test_grants_invite.py index d6376c5f103..7302d439ed1 100644 --- a/tests/unit/test_grants_invite.py +++ b/tests/unit/test_grants_invite.py @@ -16,6 +16,7 @@ import pytest +from server.auth import fail_closed from server.auth.context import set_current_auth from server.auth.jwt import AuthInfo from server.core.errors import ( @@ -34,6 +35,7 @@ from server.identity.app import invite_mail from server.identity.app import invites as mod from server.identity.domain import invites as domain +from server.identity.domain.grants import GrantState from server.identity.store import invites as invites_repo from server.operations.base import Role from server.settings import settings @@ -50,6 +52,11 @@ def __init__(self) -> None: self.verified = {"sso@example.com": "sso-handle"} self.grants: list[tuple[GrantsCreateInput, str | None]] = [] self.grant_error: BaseException | None = None + # The grant row lands before `grant_error` is raised (a lost reply). + self.grant_lands = False + # What each maker's own grant on the namespace reads as. + self.maker_roles: dict[str, Role | None] = {"admin-ann": Role.ADMIN} + self.active = True self.mail: list[dict[str, Any]] = [] self.may_mail = True @@ -75,15 +82,35 @@ async def has_account(org: str, subject: str, **_: Any) -> bool: return subject.lower() in w.accounts async def is_active(org: str, namespace: str, **_: Any) -> bool: - return True + return w.active async def canonical(org: str, subject: str, **_: Any) -> str: return w.verified.get(subject.lower(), subject) async def create_grant(input: GrantsCreateInput, *_a: Any, issuer: str | None = None) -> None: + if w.grant_lands: + w.grants.append((input, issuer)) if w.grant_error is not None: raise w.grant_error - w.grants.append((input, issuer)) + if not w.grant_lands: + w.grants.append((input, issuer)) + + async def grant_role_for(org: str, namespace: str, subject: str) -> Role | None: + return w.maker_roles.get(subject) + + async def find_active_grant(org: str, namespace: str, subject: str, **_: Any) -> Any: + held = [ + g for g, _ in w.grants if (g.org, g.namespace, g.subject) == (org, namespace, subject) + ] + if not held: + return None + return GrantState( + role=held[-1].role, + granted_by="", + status="active", + pending_role=None, + pending_since=None, + ) async def no_ceiling(*_a: Any, **_k: Any) -> None: return None @@ -103,6 +130,8 @@ async def send(to: str, **kw: Any) -> bool: monkeypatch.setattr(mod.namespaces_repo, "is_active", is_active) monkeypatch.setattr("server.auth.aliases.canonical_subject", canonical) monkeypatch.setattr(mod, "create_grant", create_grant) + monkeypatch.setattr(mod, "grant_role_for", grant_role_for) + monkeypatch.setattr(mod.grants_repo, "find_active_grant", find_active_grant) monkeypatch.setattr(mod, "_enforce_code_ceiling", no_ceiling) monkeypatch.setattr(mod, "invite_change", claimed) monkeypatch.setattr(mod.invite_mail, "send_invite", send) @@ -114,6 +143,7 @@ async def may_mail(*_a: Any) -> bool: signed_in("admin-ann") yield w set_current_auth(None) + fail_closed.reset() def signed_in(subject: str, *, org: str = "o", service: bool = False) -> None: @@ -229,6 +259,17 @@ async def allow(self, key: str) -> bool: assert asked == [("inviter", "o/ann"), ("address", "m@example.com")] +@pytest.mark.asyncio +async def test_mail_stops_at_twenty_an_hour_per_inviter_and_three_a_day_per_address( + auth_attempts: Any, monkeypatch: pytest.MonkeyPatch +) -> None: + monkeypatch.setattr(invite_mail, "can_send", lambda: True) + to_one = [await mod._may_mail("o", f"ann-{i}", "m@example.com") for i in range(4)] + assert to_one == [True, True, True, False] + by_one = [await mod._may_mail("o", "bea", f"p{i}@example.com") for i in range(21)] + assert by_one == [True] * 20 + [False] + + @pytest.mark.asyncio async def test_the_link_lets_one_person_in_once_as_granted_by_its_maker(world: World) -> None: secret = secret_of((await invite("michael@example.com")).link_path) @@ -267,6 +308,95 @@ async def test_a_failed_grant_leaves_the_link_open(world: World) -> None: assert (await accept(secret)).role == "writer" +@pytest.mark.asyncio +async def test_a_failure_after_the_grant_landed_leaves_the_link_used(world: World) -> None: + secret = secret_of((await invite("michael@example.com")).link_path) + world.grant_error, world.grant_lands = BackendUnavailableError("lost reply"), True + signed_in("mlex") + with pytest.raises(BackendUnavailableError): + await accept(secret) + iid = domain.invite_id(secret) + assert [w.state for w in world.writes if w.invite_id == iid] == ["open", "accepted"] + world.grant_error, world.grant_lands = None, False + signed_in("someone-else") + with pytest.raises(NotFoundError): + await accept(secret) + assert [g.subject for g, _ in world.grants] == ["mlex"] + + +@pytest.mark.asyncio +async def test_an_invitation_never_outlasts_its_makers_admin(world: World) -> None: + secret = secret_of((await invite("michael@example.com")).link_path) + assert world.invites[domain.invite_id(secret)].recheck_maker is True + world.maker_roles["admin-ann"] = Role.WRITER # lowered, or None when revoked + signed_in("mlex") + with pytest.raises(NotFoundError, match="no longer administers"): + await accept(secret) + assert world.invites[domain.invite_id(secret)].state == "open" + assert world.grants == [] + + +@pytest.mark.asyncio +async def test_a_maker_their_token_made_admin_is_not_read_again(world: World) -> None: + world.maker_roles = {} # no grant of their own: a platform admin or an operator's token + secret = secret_of((await invite("michael@example.com")).link_path) + assert world.invites[domain.invite_id(secret)].recheck_maker is False + signed_in("mlex") + assert (await accept(secret)).role == "writer" + + +@pytest.mark.asyncio +async def test_a_failed_read_of_the_makers_grant_is_read_again_and_refuses( + world: World, monkeypatch: pytest.MonkeyPatch +) -> None: + async def unreadable(*_a: Any) -> Role | None: + fail_closed.note_unreadable() + return None + + monkeypatch.setattr(mod, "grant_role_for", unreadable) + secret = secret_of((await invite("michael@example.com")).link_path) + assert world.invites[domain.invite_id(secret)].recheck_maker is True + signed_in("mlex") + with pytest.raises(NotFoundError): + await accept(secret) + assert world.grants == [] + + +@pytest.mark.asyncio +async def test_an_inactive_namespace_gets_no_invitation(world: World) -> None: + world.active = False + with pytest.raises(NotFoundError, match="not an active namespace"): + await invite("michael@example.com") + assert world.invites == {} + + +@pytest.mark.asyncio +async def test_where_sign_in_is_single_sign_on_only_an_email_is_granted_as_typed( + world: World, monkeypatch: pytest.MonkeyPatch +) -> None: + monkeypatch.setattr(settings, "oauth_login_provider", "oidc") + out = await invite("New@Example.com") + assert (out.outcome, out.subject, out.link_path) == ("granted", "New@Example.com", "") + assert [(g.subject, g.role) for g, _ in world.grants] == [("New@Example.com", "writer")] + assert world.invites == {} and world.mail == [] + + +def test_a_state_this_build_does_not_know_is_closed() -> None: + made = datetime(2026, 1, 1, tzinfo=UTC) + open_row = domain.Invite( + org="o", + namespace="ns", + invite_id="h", + email="m@example.com", + role="writer", + created_by="ann", + created_at=made, + expires_at=2**31, + ).row() + assert domain.Invite.from_row(open_row).is_open(0) + assert not domain.Invite.from_row({**open_row, "state": "revoked"}).is_open(0) + + @pytest.mark.asyncio async def test_an_expired_or_cancelled_link_admits_nobody(world: World) -> None: expired = secret_of((await invite("a@example.com")).link_path) @@ -277,6 +407,10 @@ async def test_an_expired_or_cancelled_link_admits_nobody(world: World) -> None: GrantsCancelInviteInput(org="o", namespace="ns", invite_id=cancelled) ) assert out.cancelled is True + assert (world.invites[cancelled].state, world.invites[cancelled].accepted_by) == ( + "cancelled", + "", + ) again = await mod.handle_grants_cancel_invite( GrantsCancelInviteInput(org="o", namespace="ns", invite_id=cancelled) ) @@ -413,7 +547,7 @@ async def test_every_write_of_an_invitation_carries_every_column() -> None: expires_at=1, ) await invites_repo.put(invite, ch=ch) # type: ignore[arg-type] - await invites_repo.put(invite.settled("accepted", "lee", made), ch=ch) # type: ignore[arg-type] + await invites_repo.put(invite.accepted("lee", made), ch=ch) # type: ignore[arg-type] assert [sorted(r) for r in ch.rows] == [sorted(column_names("namespace_invites"))] * 2 assert [(r["state"], r["accepted_by"], r["version"]) for r in ch.rows] == [ ("open", "", 1), From 9c6b8b6a8a7f4351cc67ff7acffa9278fa9678b5 Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Sat, 5 Dec 2026 04:18:05 +0530 Subject: [PATCH 17/28] docs, dashboard: invitations as they now work The sharing design, membership table, dashboard and agent guides name the single sign-on grant by email, the maker check, the spend-then-grant order and where self sign-up makes accounts; rolling-upgrade rule 76 covers the new ops and the in-use check; the open invitations show who made each; the add field's help covers both kinds of server. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Lareb Zafar --- docs/architecture/rolling-upgrades.md | 12 +++++++ docs/architecture/sharing.md | 34 +++++++++++++++---- docs/architecture/storage-layout.md | 2 +- docs/features/dashboard.md | 3 +- docs/features/namespaces-and-sharing.md | 33 +++++++++--------- .../getting-started/connect-a-coding-agent.md | 6 ++-- frontend/src/api/invites.ts | 2 +- frontend/src/components/Invitations.tsx | 2 +- frontend/src/components/SubjectHelp.tsx | 3 +- frontend/src/views/InvitationCard.test.tsx | 5 +-- 10 files changed, 70 insertions(+), 32 deletions(-) diff --git a/docs/architecture/rolling-upgrades.md b/docs/architecture/rolling-upgrades.md index 40defc23a0e..c512b3bccdf 100644 --- a/docs/architecture/rolling-upgrades.md +++ b/docs/architecture/rolling-upgrades.md @@ -1148,6 +1148,18 @@ See the [participant lifecycle baseline](cells.md#participant-lifecycle-baseline [rollback note](../operations/upgrades.md#rollback)). `tests/unit/test_read_receipts.py` checks the gate; the mixed-version gate does not. +76. **Namespace invitations** (`loom.namespace_invites`, migration + `123_namespace_invites.sql`): N-1 serves none of `grants.invite`, `grants.list_invites`, + `grants.cancel_invite` and `grants.accept_invite`, and answers one routed to it as an + unknown operation. N's dashboard sends a person's add to `grants.invite`, so while N-1 + serves, an add or an acceptance can fail on an N-1 replica and succeed on a retry that + reaches N. N-1's in-use check of a new name does not count an open invitation: a name + retired with one outstanding can be registered as new on an N-1 replica, and the link + would then grant on the new owner's namespace; cancel open invitations before retiring + a name during the rollout. After a rollback the table stays, its rows dropped by TTL a + week after they expire. No gate holds the rollout, and the mixed-version gate does not + check this rule. + ## What checks them `scripts/gates/mixed_version.py` (`make test-mixed-version`, the `mixed-version` CI job, diff --git a/docs/architecture/sharing.md b/docs/architecture/sharing.md index 041a09b0bbb..44ec935c85a 100644 --- a/docs/architecture/sharing.md +++ b/docs/architecture/sharing.md @@ -203,8 +203,14 @@ row), is granted at once through `grants.create`. Any other email gets an invita link is the credential. Only the secret's SHA-256 is stored, as the row's `invite_id`, and the link works once, for seven days by default (`invite_ttl_seconds`). The server emails it when `smtp_url`, `mail_from` and `public_base_url` are set; otherwise, or when the send fails, the answer carries the link -for the admin to pass on. A handle no account holds is refused with 404, so a typo is never -kept as a grant for whoever signs up under that handle later. +for the admin to pass on. An invitation is made only on an active namespace, where its link +can be accepted. A handle no account holds is refused with 404, so a typo is never kept as +a grant for whoever signs up under that handle later. + +Where sign-in is single sign-on only (`oauth_login_provider = "oidc"`), the identity +provider verifies every account's email, so an email no account holds is granted as typed +through `grants.create` instead, and reaches that person at their first sign-in. There is +no link to pass on. The server's mail is no relay for a namespace admin, whom any sign-up can make: it emails at most 20 invitations an hour per inviter and 3 a day per address, counted in @@ -214,15 +220,29 @@ the invitation is still made, and its link is the inviter's to pass on. `grants.accept_invite` gives the invitation's role to the signed-in caller, under the handle they sign in with, stamped `granted_by` the invitation's maker. Only a person's token accepts: a service account, a grant principal or a token of another org is refused. -It runs under a lease per invitation (`grant_claims.invite_change`) and marks the -invitation accepted before the grant, so one link never admits two people; a failed grant -puts it back open. A higher role the caller holds already stands. +Under a lease per invitation (`grant_claims.invite_change`) it checks that the link is +open, the namespace active and the maker still an admin, and marks the invitation +accepted. It grants after leaving the lease, so the grant's own claims, and an admin +grant's fan-out to a repository's branches, are never taken under it. One link never +admits two people: after a failed grant the link opens again only when no grant at or +above its role stands, so a failure after the grant row landed (a lost reply, a step after +the write) leaves it used. A higher role the caller holds already stands. + +An invitation never outlasts its maker's admin. When the maker held admin through their +own grant on the namespace (`recheck_maker`), accepting reads that grant again and +refuses unless it still reaches admin; a failed read refuses. A maker whose token made +them admin (a platform admin, an operator's token) holds no grant that a later read could +tell from a revoked one, so their invitations are not read again. The open invitations +name each maker. + +Self sign-up makes accounts in `self_signup_org` only. On a password server, a link to a +namespace of another org is accepted by an account an operator made there. A password account's email is never verified, which is why an email reaches one only through an invitation: the link went to that address, and opening it proves the reader got it. The whole link is a fragment, which a browser never sends to a server or puts in a -Referer; the dashboard moves it into the tab's session storage at boot, so a single -sign-on round trip keeps it. +Referer. The dashboard moves it into the tab's session storage when a single sign-on starts +and when Namespaces in your org shows it, so a single sign-on round trip keeps it. ## Consistency diff --git a/docs/architecture/storage-layout.md b/docs/architecture/storage-layout.md index bd294138118..17d49c075b7 100644 --- a/docs/architecture/storage-layout.md +++ b/docs/architecture/storage-layout.md @@ -934,7 +934,7 @@ copies of tables listed here, owned and removed by that run, and erasure reaches | `oauth_signin_state` | KeeperMap `claim_key` | Postgres `oauth_signin_state` | SoR | no content | 1 | strict compare-and-set per key with an expiry and optional verified sign-in email metadata: an `UPDATE … WHERE value = $old`; the KeeperMap expiry becomes `expires_at`, read by a sweep; named in `server/auth/claims.py`, `server/cli/secrets.py` | | `grant_claims` | KeeperMap `claim_key` | delete | Coord | no content | 1 | no code path writes it (its census entry says so); no module outside the census names the table (`server/auth/grant_claims.py` is the claim module, whose keys are in `_migration_lock`) | | `namespace_grants` | RMT(version) `(org, namespace, subject)`, by `org` | Postgres `namespace_grants` | SoR | step `grants.revoke` | 1 | every request's role check; a revoke takes effect within the grant cache's invalidation bound; named in `server/identity/store/grants.py`, `server/auth/self_signup.py` | -| `namespace_invites` | RMT(version) `(org, namespace, invite_id)`, TTL | Postgres `namespace_invites` | SoR | no content | 1 | an invitation read by `(org, namespace, invite_id)` when its link is accepted or cancelled, and the open ones when a namespace's members are shown; named in `server/identity/store/invites.py` | +| `namespace_invites` | RMT(version) `(org, namespace, invite_id)`, TTL | Postgres `namespace_invites` | SoR | no content | 1 | an invitation read by `(org, namespace, invite_id)` when its link is accepted or cancelled, the open ones when a namespace's members are shown, and the open, unexpired ones by a new name's in-use check; named in `server/identity/store/invites.py` | | `namespaces` | RMT(updated_at) `(org, namespace)`, by `org` | Postgres `namespaces` + ClickHouse mirror | SoR (head) | step `personal.retire`; step `collections.forget_owner` | 1 | the registry with its per-namespace settings, read by grants, sign-in and request paths through a cache; the mirror serves ClickHouse worker scans and the SQL surface views; named in `server/auth/self_signup.py`, `server/cli/hygiene.py` | | `collections` | RMT(version) `(org, namespace)` | Postgres `collections` | SoR | step `collections.forget_owner` | 1 | the collection tree grants inherit through; named in `server/identity/store/collections.py`, `server/identity/store/namespace_census.py` | | `acl_versions` | SMT(changes) `(org, kind)` | merge into Postgres `cache_generations` (kinds `grants`, `groups`, `collections`) | Coord | no content | 1 | a change counter caches poll; a generation row plus `NOTIFY` replaces it; named in `server/core/grant_cache.py` | diff --git a/docs/features/dashboard.md b/docs/features/dashboard.md index 2ecf0973dd1..231131323a5 100644 --- a/docs/features/dashboard.md +++ b/docs/features/dashboard.md @@ -125,7 +125,8 @@ email, or a service account `sa:`. A collection's **Share** also takes a g `group:`, an agent `agent:` or `everyone`. A login handle no account holds is refused. Any other email gets an [invitation](namespaces-and-sharing.md#membership-and-grants). The add shows its link to copy, and the server emails it when it sends mail. The members list it under -**Open invitations**, with **Cancel**, until it is accepted. Whoever opens the link signed in +**Invited**, with who made it and **Cancel**, until it is accepted. Where sign-in is single +sign-on only, the email is granted instead and reaches that person at their first sign-in. Whoever opens the link signed in accepts it on Namespaces in your org, which then switches to the namespace; a collection opens in the Library. With sign-in on, **Settings** › **Tokens** links to Namespaces in your org for giving a person access: a token is for a tool, diff --git a/docs/features/namespaces-and-sharing.md b/docs/features/namespaces-and-sharing.md index 4936f290de0..da258b655bb 100644 --- a/docs/features/namespaces-and-sharing.md +++ b/docs/features/namespaces-and-sharing.md @@ -71,26 +71,27 @@ account, or a service account `sa:`) a role on one namespace: `viewer` rea `writer` writes, `admin` manages grants and settings. The token carries the org and the namespaces it may reach; the grant table decides the role. -| Operation | Role | Does | -| -------------------------------------------------------------------- | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `grants.create` | admin | Grant a role. A create below the subject's current role is refused with 409 `GRANT_WOULD_DOWNGRADE` unless `replace=true`. | -| `grants.invite` | admin | Give a person a role by login handle or email. An account's handle, or an email verified for one, is granted at once; any other email gets a single-use invitation link, emailed when the server has mail settings. A handle no account holds is refused. | -| `grants.list_invites`, `grants.cancel_invite` | admin | The open invitations, and withdraw one. | -| `grants.accept_invite` | a signed-in person | Accept an invitation link: its role goes to the account the caller signs in as. | -| `grants.list` | viewer | Who has access, at which role, and any `pending_role`. | -| `grants.revoke` | admin | Remove a grant. | -| `grants.approve` | admin | Approve or reject a pending request, optionally with a different role. | -| `grants.pending_for_me` | viewer | Every pending request in the namespaces the caller administers, org-wide. | -| `namespace.browse` | viewer | Public namespaces in the org, never a collection (`closed` ones only with `include_closed`). | -| `namespace.join` | viewer | Self-join a public namespace. `viewer` is granted at once; a `writer` or `admin` request always lands pending, with no access until an admin approves. | -| `namespace.leave`, `namespace.cancel_request`, `namespace.mark_seen` | viewer | Drop one's own grant, withdraw a pending request, acknowledge an invitation. | -| `namespace.list_mine` | viewer | The namespaces the caller belongs to, each with its `kind` (`collection` for a collection) and `title`. | -| `namespace.list` | org admin | Every namespace in the org. | +| Operation | Role | Does | +| -------------------------------------------------------------------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `grants.create` | admin | Grant a role. A create below the subject's current role is refused with 409 `GRANT_WOULD_DOWNGRADE` unless `replace=true`. | +| `grants.invite` | admin | Give a person a role by login handle or email. An account's handle, or an email verified for one, is granted at once; any other email gets a single-use invitation link, emailed when the server has mail settings, or, where sign-in is single sign-on only, a grant that reaches that person at their first sign-in. A handle no account holds is refused. | +| `grants.list_invites`, `grants.cancel_invite` | admin | The open invitations, and withdraw one. | +| `grants.accept_invite` | a signed-in person | Accept an invitation link: its role goes to the account the caller signs in as. | +| `grants.list` | viewer | Who has access, at which role, and any `pending_role`. | +| `grants.revoke` | admin | Remove a grant. | +| `grants.approve` | admin | Approve or reject a pending request, optionally with a different role. | +| `grants.pending_for_me` | viewer | Every pending request in the namespaces the caller administers, org-wide. | +| `namespace.browse` | viewer | Public namespaces in the org, never a collection (`closed` ones only with `include_closed`). | +| `namespace.join` | viewer | Self-join a public namespace. `viewer` is granted at once; a `writer` or `admin` request always lands pending, with no access until an admin approves. | +| `namespace.leave`, `namespace.cancel_request`, `namespace.mark_seen` | viewer | Drop one's own grant, withdraw a pending request, record a visit (clears the namespace's new mark). | +| `namespace.list_mine` | viewer | The namespaces the caller belongs to, each with its `kind` (`collection` for a collection) and `title`. | +| `namespace.list` | org admin | Every namespace in the org. | A password account's email is never verified, so a grant by email reaches such an account only through an invitation. The link is `/spaces#invite=…` on the dashboard, works once, within seven days by default (`LOOM_INVITE_TTL_SECONDS`), and gives its role to whoever opens it signed in, under their own -login handle, as granted by the admin who made it. To have the server email it, set +login handle, as granted by the admin who made it, while that admin still administers the +namespace. To have the server email it, set `LOOM_SMTP_URL` (`smtps://user:password@host:465`, or `smtp://…:587` with STARTTLS), `LOOM_MAIL_FROM` and `LOOM_PUBLIC_BASE_URL`; without them, or when a send fails, the dashboard shows the link to copy. The design is in [sharing](../architecture/sharing.md#invitations). diff --git a/docs/getting-started/connect-a-coding-agent.md b/docs/getting-started/connect-a-coding-agent.md index 95d304b5923..b21eb91036d 100644 --- a/docs/getting-started/connect-a-coding-agent.md +++ b/docs/getting-started/connect-a-coding-agent.md @@ -10,8 +10,10 @@ tools connected to the same self-hosted server. Invite each teammate to the team namespace: **Invite people to this namespace** in the namespace picker, with that namespace picked, or **Invite** on Namespaces in your org. Each teammate makes their own token, and their agents find the facts others save. A teammate without an account is invited by email -and accepts once signed up. Where nobody can sign up, an operator makes their token -(`loom mint-token`). Install the plugin or MCP entry below; the next +and accepts once signed up; where sign-in is single sign-on only, the email is granted and +reaches them at their first sign-in. Self sign-up makes accounts in `LOOM_SELF_SIGNUP_ORG` +only, so for a namespace of another org, or where nobody can sign up, an operator makes +their token (`loom mint-token`). Install the plugin or MCP entry below; the next session can recall what an agent saved. What the Claude Code and Codex plugins send to Loom is in [data handling](../features/integrations/claude-code.md#data-handling). Conversation recording is off by default; the namespace owner turns it on with the **Record conversations** diff --git a/frontend/src/api/invites.ts b/frontend/src/api/invites.ts index ee6feef1808..07cecd6091f 100644 --- a/frontend/src/api/invites.ts +++ b/frontend/src/api/invites.ts @@ -12,7 +12,7 @@ export interface InviteResult { /** The subject granted, for `granted`. */ subject: string; invite_id: string; - /** `/invite?org=…&namespace=…#`, for `invited`: the link without the server's address. */ + /** `/spaces#invite=&org=…&namespace=…`, for `invited`: the link without the server's address. */ link_path: string; /** The whole link, when the server knows its public address. */ url: string; diff --git a/frontend/src/components/Invitations.tsx b/frontend/src/components/Invitations.tsx index e97793c82d1..fc7d8ccf84b 100644 --- a/frontend/src/components/Invitations.tsx +++ b/frontend/src/components/Invitations.tsx @@ -64,7 +64,7 @@ export function OpenInvitations({ scope, version }: { scope: Scope; version: num {rows.map((r) => (

  • {r.email} - {`${r.role}, until ${absoluteTime(r.expires_at)}`} + {`${r.role}, by ${r.created_by}, until ${absoluteTime(r.expires_at)}`} - {!refused && ( + {!refused && !elsewhere && ( diff --git a/server/erasure/store/census.py b/server/erasure/store/census.py index 85c458bea09..511065c7bfe 100644 --- a/server/erasure/store/census.py +++ b/server/erasure/store/census.py @@ -585,7 +585,7 @@ def owner(self, scope_type: str) -> str | None: "agent_runs.delete": ("loom.agent_run_claims",), # What a grant, a group and the collection tree say about a user as a # principal: identifiers, no memory content; rewritten, not counted. - "grants.revoke": ("loom.namespace_grants",), + "grants.revoke": ("loom.namespace_grants", "loom.namespace_invites"), "groups.remove_member": ("loom.principal_groups",), "personal.retire": ("loom.namespaces",), # Deactivates the namespace's sources and clears their credentials, and a crawl's @@ -747,11 +747,6 @@ def owner(self, scope_type: str) -> str | None: "loom.oauth_claims": "auth plane: no code path writes it; never holds memory content.", "loom.grant_claims": "auth plane: no code path writes it; never holds memory content.", "loom.service_accounts": "auth plane: service-account definitions.", - "loom.namespace_invites": ( - "auth plane: invitations to a namespace (the address invited, a role, who made and " - "who accepted it; the link's secret only as a SHA-256), dropped a week after the " - "link expires; no memory content." - ), "loom.user_state": "per-subject UI state (default namespace).", # -- ledgers of the erasure itself, kept by design ---------- "loom.erasure_requests": "the erasure ledger; scope_value names the scope, 90-day TTL.", diff --git a/server/identity/app/invite_mail.py b/server/identity/app/invite_mail.py index 97468ddcb42..f4b973c8e80 100644 --- a/server/identity/app/invite_mail.py +++ b/server/identity/app/invite_mail.py @@ -31,7 +31,7 @@ def _message( msg["To"] = to msg["Subject"] = f"{inviter} invited you to {namespace} on Loom" msg.set_content( - f"{inviter} invited you to the Loom namespace {namespace} as a {role}.\n\n" + f"{inviter} invited you to the Loom namespace {namespace}, with the role {role}.\n\n" f"Open this link, sign in, and accept:\n{url}\n\n" f"The link works once, until {until}. If you did not expect it, ignore this email.\n" ) @@ -54,12 +54,12 @@ def _send(msg: EmailMessage) -> None: with client: if u.scheme == "smtp": client.ehlo() - if client.has_extn("starttls"): - client.starttls(context=tls) - client.ehlo() - elif u.username: - # The password is never sent in the clear. - raise smtplib.SMTPNotSupportedError("the server offers no STARTTLS for the login") + # The link admits whoever reads it, and a login's password goes with it: neither + # is sent in the clear. + if not client.has_extn("starttls"): + raise smtplib.SMTPNotSupportedError("the server offers no STARTTLS") + client.starttls(context=tls) + client.ehlo() if u.username: client.login(unquote(u.username), unquote(u.password or "")) client.send_message(msg) diff --git a/server/identity/app/invites.py b/server/identity/app/invites.py index 0d8a9090f14..25a72bd4be9 100644 --- a/server/identity/app/invites.py +++ b/server/identity/app/invites.py @@ -19,15 +19,17 @@ from __future__ import annotations -import contextlib +import logging import time from datetime import UTC, datetime from typing import Any from server.auth.attempts import Attempts from server.auth.authz import subject_grant_role -from server.auth.fail_closed import unreadable +from server.auth.delegation import creator_account_active +from server.auth.fail_closed import reset, unreadable from server.auth.grant_claims import invite_change +from server.auth.revocation import is_revoked from server.auth.self_signup import valid_signup_email from server.core.errors import ( BackendUnavailableError, @@ -35,6 +37,7 @@ NotFoundError, ValidationError, ) +from server.core.logging_config import log_value from server.core.principals import has_aliases, is_reserved_subject from server.identity.api.models_grants import ( GrantsAcceptInviteInput, @@ -61,6 +64,8 @@ from server.operations.base import GRANT_ROLES, GrantRoleStr, Role, grant_rank from server.settings import settings +log = logging.getLogger(__name__) + # The open invitations a namespace lists. _LISTED = 200 # Invitation emails, so that the server's mail is no relay for a namespace admin (whom any @@ -153,21 +158,27 @@ async def _granted(input: GrantsInviteInput, person: str, subject: str) -> Grant return GrantsInviteOutput(outcome="granted", role=input.role, subject=subject) -async def _admin(org: str, namespace: str, maker: str) -> bool: - """Whether `maker`'s grants make them admin there (`authz.subject_grant_role`); a - read that fails answers 503, so a link is not given up for an outage.""" +async def _maker_stands(org: str, namespace: str, maker: str, made_at: int) -> bool: + """Whether `maker` still stands behind a link made at `made_at` (Unix seconds), as a + delegated token's creator stands behind it: their grants make them admin there + (`authz.subject_grant_role`), their account is active, and neither they nor tokens of + theirs that old are revoked. A read that fails answers 503, so a link is not given + up for an outage.""" + reset() # this decision's own reads, not an earlier one's in the request role = await subject_grant_role(org, namespace, maker) + active = await creator_account_active(org, maker) if unreadable(): raise BackendUnavailableError("the inviter's grants could not be read: try again") - return role is not None and role.value >= Role.ADMIN.value + admin = role is not None and role.value >= Role.ADMIN.value + return admin and active and not is_revoked(maker, issued_at=made_at) async def _invite(input: GrantsInviteInput, email: str, maker: str) -> GrantsInviteOutput: - if not await _admin(input.org, input.namespace, maker): + if not await _maker_stands(input.org, input.namespace, maker, int(time.time())): raise ValidationError( f"an invitation link stands on its maker's admin grant on {input.org}/" - f"{input.namespace}, and {maker!r} holds none there: an admin there through a " - "grant invites them" + f"{input.namespace}, and {maker!r} holds none there with an active account: an " + "admin there through a grant invites them" ) secret = domain.new_secret() now = datetime.now(UTC) @@ -265,7 +276,8 @@ async def handle_grants_accept_invite(input: GrantsAcceptInviteInput) -> GrantsA raise NotFoundError(_GONE) if not await namespaces_repo.is_active(input.org, input.namespace): raise NotFoundError(_GONE) - if not await _admin(invite.org, invite.namespace, invite.created_by): + made_at = int(invite.created_at.timestamp()) + if not await _maker_stands(invite.org, invite.namespace, invite.created_by, made_at): raise NotFoundError(_GONE) # Spent under the claim, before the grant: a link never lets two people in. The # grant takes its own claims after this one, as `grant_claims` orders them. @@ -273,19 +285,30 @@ async def handle_grants_accept_invite(input: GrantsAcceptInviteInput) -> GrantsA try: held = await _grant(invite, role, subject) except BaseException: - # A failed put-back leaves the link used, never open twice. - with contextlib.suppress(Exception): + try: await _reopen_unless_granted(invite, subject) + except Exception as e: # noqa: BLE001 — the grant's error is the answer; link stays used + log.warning( + "invitation %s on %s/%s stays used after a failed grant: %s", + log_value(invite.invite_id[:12]), + log_value(invite.org), + log_value(invite.namespace), + type(e).__name__, + ) raise return GrantsAcceptInviteOutput(namespace=input.namespace, role=held) async def _reopen_unless_granted(invite: domain.Invite, subject: str) -> None: """Open the link again after a failed grant, unless the grant landed before the - failure (a lost reply, a step after the write): then it stays used. A read that - fails raises, and the link stays used.""" + failure (a lost reply, a step after the write): then it stays used. The grant is read + under the subject `create_grant` writes it under. A read that fails raises, and the + link stays used.""" + from server.auth.aliases import canonical_subject + async with invite_change(invite.org, invite.namespace, invite.invite_id): - held = await grants_repo.find_active_grant(invite.org, invite.namespace, subject) + granted_to = await canonical_subject(invite.org, subject) + held = await grants_repo.find_active_grant(invite.org, invite.namespace, granted_to) if held is not None and grant_rank(held.role) >= grant_rank(invite.role): return current = await invites_repo.get(invite.org, invite.namespace, invite.invite_id) diff --git a/server/settings/catalog.py b/server/settings/catalog.py index ca04c2b9d69..4860a692756 100644 --- a/server/settings/catalog.py +++ b/server/settings/catalog.py @@ -461,8 +461,9 @@ def trusted_issuers(self) -> set[str]: self_signup_org: str = "dev" # The mail server an invitation is emailed through: `smtps://user:password@host:465` - # (TLS from the start) or `smtp://user:password@host:587` (STARTTLS, which a login - # requires). Empty: no email is sent, and whoever makes an invitation sends its link. + # (TLS from the start) or `smtp://user:password@host:587` (STARTTLS, which every send + # requires: the email carries the link). Empty: no email is sent, and whoever makes an + # invitation sends its link. smtp_url: str = "" # The From address of an invitation email, e.g. `Loom `. Empty # sends none, as does an empty smtp_url or public_base_url (the link needs it). diff --git a/server/transport/mcp_descriptions.py b/server/transport/mcp_descriptions.py index 177d07d0a09..27b42317335 100644 --- a/server/transport/mcp_descriptions.py +++ b/server/transport/mcp_descriptions.py @@ -403,10 +403,10 @@ def revision_policy(update: str) -> str: "default answer to 'what are my workspaces' / 'where can I save " "this'. Each row has an `is_new` flag — true when someone " "granted access and the caller hasn't visited yet; surface " - "those as fresh invitations." + "those as newly shared." ), "namespace.mark_seen": ( - "Acknowledge a new-invitation indicator on a namespace. Call " + "Record a visit to a namespace, clearing its new mark. Call " "after surfacing rows from namespace.list_mine that had " "is_new=true, so the badge clears on the next list." ), diff --git a/tests/unit/test_grants_invite.py b/tests/unit/test_grants_invite.py index 577e39f583a..0f15118741c 100644 --- a/tests/unit/test_grants_invite.py +++ b/tests/unit/test_grants_invite.py @@ -59,6 +59,9 @@ def __init__(self) -> None: self.grant_lands = False # What each maker's own grant on the namespace reads as. self.maker_roles: dict[str, Role | None] = {"admin-ann": Role.ADMIN} + # Makers whose account is disabled, and subjects revoked outright. + self.disabled: set[str] = set() + self.revoked: set[str] = set() self.active = True self.mail: list[dict[str, Any]] = [] self.may_mail = True @@ -98,6 +101,8 @@ async def canonical(org: str, subject: str, **_: Any) -> str: return w.verified.get(subject.lower(), subject) async def create_grant(input: GrantsCreateInput, *_a: Any, issuer: str | None = None) -> None: + # Written under the handle a verified email ties to, as the real one writes it. + input = input.model_copy(update={"subject": w.verified.get(input.subject, input.subject)}) if w.grant_lands: w.grants.append((input, issuer)) if w.grant_error is not None: @@ -108,6 +113,9 @@ async def create_grant(input: GrantsCreateInput, *_a: Any, issuer: str | None = async def subject_grant_role(org: str, namespace: str, subject: str) -> Role | None: return w.maker_roles.get(subject) + async def account_active(org: str, creator: str) -> bool: + return creator not in w.disabled + async def find_active_grant(org: str, namespace: str, subject: str, **_: Any) -> Any: held = [ g for g, _ in w.grants if (g.org, g.namespace, g.subject) == (org, namespace, subject) @@ -143,6 +151,8 @@ async def send(to: str, **kw: Any) -> bool: monkeypatch.setattr("server.auth.aliases.canonical_subject", canonical) monkeypatch.setattr(mod, "create_grant", create_grant) monkeypatch.setattr(mod, "subject_grant_role", subject_grant_role) + monkeypatch.setattr(mod, "creator_account_active", account_active) + monkeypatch.setattr(mod, "is_revoked", lambda subject, **_: subject in w.revoked) monkeypatch.setattr(mod.grants_repo, "find_active_grant", find_active_grant) monkeypatch.setattr(mod, "_enforce_code_ceiling", no_ceiling) monkeypatch.setattr(mod, "invite_change", claimed) @@ -451,6 +461,26 @@ async def unreadable(*_a: Any) -> Role | None: assert world.grants == [] and len(world.invites) == 1 +@pytest.mark.parametrize("ended", ["disabled", "revoked"]) +@pytest.mark.asyncio +async def test_a_link_stops_with_its_makers_account(world: World, ended: str) -> None: + """As a token delegated by the maker stops: a disabled account, or a revoked subject.""" + secret = secret_of((await invite("michael@example.com")).link_path) + getattr(world, ended).add("admin-ann") + signed_in("mlex") + with pytest.raises(NotFoundError, match="no longer administers"): + await accept(secret) + assert world.grants == [] and world.invites[domain.invite_id(secret)].state == "open" + + +@pytest.mark.asyncio +async def test_a_failed_read_earlier_in_the_request_does_not_refuse_the_maker( + world: World, +) -> None: + fail_closed.note_unreadable() # a read the gate made and survived + assert (await invite("michael@example.com")).outcome == "invited" + + @pytest.mark.asyncio async def test_a_role_this_build_does_not_know_is_unlisted_and_admits_nobody( world: World, @@ -610,7 +640,7 @@ def send_message(self, msg: Any) -> None: self.calls.append("send") -def test_smtp_is_reached_within_the_timeout_and_logs_in_only_over_tls( +def test_smtp_is_reached_within_the_timeout_and_sends_only_over_tls( monkeypatch: pytest.MonkeyPatch, ) -> None: monkeypatch.setattr(_SMTP, "opened", []) @@ -630,11 +660,13 @@ def test_smtp_is_reached_within_the_timeout_and_logs_in_only_over_tls( assert _SMTP.last.calls == ["ehlo", "starttls", "ehlo", ("login", "loom", "pw"), "send"] assert _SMTP.opened == [("mail.example.com", 465, 3.0), ("mail.example.com", 587, 3.0)] - # A server without STARTTLS never sees the password. + # A server without STARTTLS sees neither the password nor the link, login or not. monkeypatch.setattr(_SMTP, "starttls_offered", False) - with pytest.raises(smtplib.SMTPNotSupportedError): - invite_mail._send(msg) - assert _SMTP.last.calls == ["ehlo"] + for url in ("smtp://loom:pw@mail.example.com", "smtp://mail.example.com"): + monkeypatch.setattr(settings, "smtp_url", url) + with pytest.raises(smtplib.SMTPNotSupportedError): + invite_mail._send(msg) + assert _SMTP.last.calls == ["ehlo"] class _Rows: @@ -675,6 +707,20 @@ async def test_every_write_of_an_invitation_carries_every_column() -> None: ] +@pytest.mark.asyncio +async def test_a_grant_written_under_the_accepters_handle_keeps_the_link_used( + world: World, +) -> None: + """The accepter signs in as a verified email; the grant lands under its handle.""" + secret = secret_of((await invite("michael@example.com")).link_path) + world.grant_error, world.grant_lands = BackendUnavailableError("lost reply"), True + signed_in("sso@example.com") + with pytest.raises(BackendUnavailableError): + await accept(secret) + assert [g.subject for g, _ in world.grants] == ["sso-handle"] + assert world.invites[domain.invite_id(secret)].state == "accepted" + + @pytest.mark.asyncio async def test_a_link_its_maker_was_erased_from_during_a_failed_grant_stays_closed( world: World, monkeypatch: pytest.MonkeyPatch From b55e8cb109741923926aeed4beccd648021b93bb Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Sat, 5 Dec 2026 06:46:23 +0530 Subject: [PATCH 22/28] Read the reopen's grant with sequential consistency, and keep the link through a non-refusal After a failed grant, the reopen reads the grant just written: on a pool spread across replicas, a replica that has not seen it would reopen a used link. The accept card drops the link only on the server's refusals of it (404, 422): an ended session or a rate limit keeps it for a retry. A failed send's log line names its error, not the address. The store test's expiry follows the clock. Shorter settings comments, and the long doc lines are rewrapped. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Lareb Zafar --- docs/architecture/sharing.md | 49 +++++++++++----------- docs/features/dashboard.md | 14 +++---- docs/features/namespaces-and-sharing.md | 6 +-- docs/guides/tokens-and-grants.md | 13 +++--- docs/reference/configuration.md | 4 +- frontend/src/views/InvitationCard.test.tsx | 12 ++++++ frontend/src/views/InvitationCard.tsx | 6 ++- loom.example.yaml | 5 +-- schemas/loom-settings.schema.json | 2 +- server/identity/api/models_grants.py | 9 ++-- server/identity/app/invite_mail.py | 4 +- server/identity/app/invites.py | 5 ++- server/settings/catalog.py | 11 ++--- tests/unit/test_grants_invite.py | 3 ++ tests/unit/test_invites_store_sql.py | 2 +- 15 files changed, 82 insertions(+), 63 deletions(-) diff --git a/docs/architecture/sharing.md b/docs/architecture/sharing.md index 9c442b15d87..8f88afc49ba 100644 --- a/docs/architecture/sharing.md +++ b/docs/architecture/sharing.md @@ -207,12 +207,13 @@ token, which only a server with auth off serves, grants every person as typed: n signs in there to accept a link. Any other email, one plain address as sign-up checks it (a dot-atom local part and a domain IDNA encodes, so no list, display name or comment), gets an invitation: a `loom.namespace_invites` row and the link -`/spaces#invite=&org=…&namespace=…`. The link is the credential. Only the secret's SHA-256 is stored, as the row's `invite_id`, and -the link works once, for seven days by default (`invite_ttl_seconds`). The server emails it when `smtp_url`, `mail_from` and +`/spaces#invite=&org=…&namespace=…`. The link is the credential. Only the secret's +SHA-256 is stored, as the row's `invite_id`, and the link works once, for seven days by +default (`invite_ttl_seconds`). The server emails it when `smtp_url`, `mail_from` and `public_base_url` are set; otherwise, or when the send fails, the answer carries the link -for the admin to pass on. An invitation is made only on an active namespace, where its link -can be accepted. A handle no account holds is refused with 404, so a typo is never kept as -a grant for whoever signs up under that handle later. +for the admin to pass on. An invitation is made only on an active namespace, where its +link can be accepted. A handle no account holds is refused with 404, so a typo is never +kept as a grant for whoever signs up under that handle later. Where sign-in is single sign-on only (`oauth_login_provider = "oidc"`), the identity provider verifies every account's email, so an email no account holds is granted as typed @@ -243,10 +244,10 @@ everyone's, there or on a collection above; elsewhere its grant, or an inheritin account's creator's. The maker's account must also be active and their subject not revoked, as for a token they delegated (`delegation.creator_account_active`, `revocation.is_revoked` at the time the link was made). Short of any of these, the link is -not made, or admits nobody; a failed read answers 503, so the dashboard keeps the link. An admin whose token alone makes them one (a platform admin, an operator's -token) holds no grant that a later read could tell from a revoked one, so they cannot make -a link: an admin through a grant invites the person. The open invitations name each -maker. +not made, or admits nobody; a failed read answers 503, so the dashboard keeps the link. An +admin whose token alone makes them one (a platform admin, an operator's token) holds no +grant that a later read could tell from a revoked one, so they cannot make a link: an +admin through a grant invites the person. The open invitations name each maker. Self sign-up makes accounts in `self_signup_org` only. On a password server, a link to a namespace of another org is accepted by an account an operator made there. @@ -346,21 +347,21 @@ writer's live document shares (each upload by an end user is recorded in `loom.blob_uploads`, because the document version that named it may have been replaced and merged away since), revokes and then deletes every grant naming `user:`, blanks their id as the issuer of the grants they gave others (those grants stay) and as the maker of -their invitations, closing the open ones, removes them from every group, blanks their id as the creator of the collections they made (the collections -stay), and retires their personal collection's directory row (`namespace.delete` and -`collection.delete` refuse a personal collection: it goes only with its user's erasure). -The request ledger keeps the user's calls for cost with their `user:` subject -scrubbed, and the user's newest-call row is deleted. Deleting a SCIM group revokes the -grants that named it, so a group made later under the same id starts with none. -Collections that hold other writers' documents stay: Loom deletes only what its writer -asked to delete. `collection.delete` purges what its collection held (a namespace erasure -that takes the rows off disk) before the collection leaves the tree. A user-scope -`erasure.export` returns the chunks and the conversation rows (transcript turns, saved -messages and threads) that user owns in the collections its caller may read, and in the -user's own personal collection. An org admin may erase a collection's rows without -reading them; a platform admin sees every collection. Each section's read leaves out what -the caller may not see before its limit, so a hidden row never takes a visible row's place -on the page. +their invitations, closing the open ones, removes them from every group, blanks their id +as the creator of the collections they made (the collections stay), and retires their +personal collection's directory row (`namespace.delete` and `collection.delete` refuse a +personal collection: it goes only with its user's erasure). The request ledger keeps the +user's calls for cost with their `user:` subject scrubbed, and the user's newest-call +row is deleted. Deleting a SCIM group revokes the grants that named it, so a group made +later under the same id starts with none. Collections that hold other writers' documents +stay: Loom deletes only what its writer asked to delete. `collection.delete` purges what +its collection held (a namespace erasure that takes the rows off disk) before the +collection leaves the tree. A user-scope `erasure.export` returns the chunks and the +conversation rows (transcript turns, saved messages and threads) that user owns in the +collections its caller may read, and in the user's own personal collection. An org admin +may erase a collection's rows without reading them; a platform admin sees every +collection. Each section's read leaves out what the caller may not see before its limit, +so a hidden row never takes a visible row's place on the page. ## Namespace guides diff --git a/docs/features/dashboard.md b/docs/features/dashboard.md index 5c262730c54..b8bd8664623 100644 --- a/docs/features/dashboard.md +++ b/docs/features/dashboard.md @@ -124,13 +124,13 @@ login handle, which their account menu shows under **Signed in as** and which ma email, or a service account `sa:`. A collection's **Share** also takes a group `group:`, an agent `agent:` or `everyone`. A login handle no account holds is refused. Any other email gets an [invitation](namespaces-and-sharing.md#membership-and-grants). The add -shows its link to copy, and the server emails it when it sends mail. The members dialog and a repository's Access tab list it under -**Invited**, with who made it and **Cancel**, until it is accepted. Where sign-in is single -sign-on only, the email is granted instead and reaches that person at their first sign-in. Whoever opens the link signed in -accepts it on Namespaces in your org, which then switches to the namespace; a collection opens -in the Library. With sign-in on, **Settings** › -**Tokens** links to Namespaces in your org for giving a person access: a token is for a tool, -agent or script. +shows its link to copy, and the server emails it when it sends mail. The members dialog +and a repository's Access tab list it under **Invited**, with who made it and **Cancel**, +until it is accepted. Where sign-in is single sign-on only, the email is granted instead +and reaches that person at their first sign-in. Whoever opens the link signed in accepts +it on Namespaces in your org, which then switches to the namespace; a collection opens in +the Library. With sign-in on, **Settings** › **Tokens** links to Namespaces in your org +for giving a person access: a token is for a tool, agent or script. The dashboard's text follows the [copy rules](../development/dashboard-design.md#rules-a-change-is-checked-against): its diff --git a/docs/features/namespaces-and-sharing.md b/docs/features/namespaces-and-sharing.md index da258b655bb..14362bfd727 100644 --- a/docs/features/namespaces-and-sharing.md +++ b/docs/features/namespaces-and-sharing.md @@ -89,9 +89,9 @@ namespaces it may reach; the grant table decides the role. A password account's email is never verified, so a grant by email reaches such an account only through an invitation. The link is `/spaces#invite=…` on the dashboard, works -once, within seven days by default (`LOOM_INVITE_TTL_SECONDS`), and gives its role to whoever opens it signed in, under their own -login handle, as granted by the admin who made it, while that admin still administers the -namespace. To have the server email it, set +once, within seven days by default (`LOOM_INVITE_TTL_SECONDS`), and gives its role to +whoever opens it signed in, under their own login handle, as granted by the admin who made +it, while that admin still administers the namespace. To have the server email it, set `LOOM_SMTP_URL` (`smtps://user:password@host:465`, or `smtp://…:587` with STARTTLS), `LOOM_MAIL_FROM` and `LOOM_PUBLIC_BASE_URL`; without them, or when a send fails, the dashboard shows the link to copy. The design is in [sharing](../architecture/sharing.md#invitations). diff --git a/docs/guides/tokens-and-grants.md b/docs/guides/tokens-and-grants.md index 43e2af2bd60..6ba67281428 100644 --- a/docs/guides/tokens-and-grants.md +++ b/docs/guides/tokens-and-grants.md @@ -255,11 +255,14 @@ curl -s "$LOOM_BASE_URL/v1/grants.create" -H "Authorization: Bearer $ADMIN_TOKEN owner proving the password from an SSO sign-in). A self-signup email is not: whoever typed the address first does not hold the grants written under it, which still cap that account's claims. Grant a self-signup account under its login handle, the namespace - it signed up with, or invite its email with `grants.invite`, whose link the person accepts signed in ([invitations](../features/namespaces-and-sharing.md#membership-and-grants)). A `grants.revoke` of an address no verified account holds, and that - never held a row of its own on the namespace, takes the rows stored under each - unverified account naming it, and the grants there of the tokens those accounts made. - When the address held a row of its own there, its revoke also takes the grants of the - tokens those accounts made there, unless one still holds an active grant of its own. + it signed up with, or invite its email with `grants.invite`, whose link the person + accepts signed in + ([invitations](../features/namespaces-and-sharing.md#membership-and-grants)). A + `grants.revoke` of an address no verified account holds, and that never held a row of + its own on the namespace, takes the rows stored under each unverified account naming it, + and the grants there of the tokens those accounts made. When the address held a row of + its own there, its revoke also takes the grants of the tokens those accounts made there, + unless one still holds an active grant of its own. - **Registering is owning.** `namespace.register` makes the caller the namespace's `admin`. With self-signup (`LOOM_IDENTITY_PROVIDER=trust-network`) the first principal to claim a name owns it; `loom claim-release --org --namespace ` revokes its grants, diff --git a/docs/reference/configuration.md b/docs/reference/configuration.md index a1d4ca3506c..82976776793 100644 --- a/docs/reference/configuration.md +++ b/docs/reference/configuration.md @@ -136,9 +136,9 @@ Authentication, tokens and identity providers. | `LOOM_WORKLOAD_EXCHANGES_PER_AGENT` | `int` | `300` | | Workload-token exchanges one agent of a trust (a token with an agent claim) may make in 10 minutes, so one agent's loop cannot spend the trust's. A trust without agents has only `workload_exchanges_per_trust`. | | `LOOM_SELF_SIGNUP` | `'off' \| 'open'` | `'off'` | | Browser self-signup: "off" (endpoint 404s) or "open" (/v1/auth/self-signup mints JWTs scoped to the requested namespace). A non-loopback bind refuses "open" unless identity_provider is "trust-network", allow_insecure is set, or oauth_login_provider is "oidc" (which closes sign-up). | | `LOOM_SELF_SIGNUP_ORG` | `str` | `'dev'` | | Default org for self-signed tokens. | -| `LOOM_SMTP_URL` | `str` | *(unset)* | | The mail server an invitation is emailed through: `smtps://user:password@host:465` (TLS from the start) or `smtp://user:password@host:587` (STARTTLS, which every send requires: the email carries the link). Empty: no email is sent, and whoever makes an invitation sends its link. | +| `LOOM_SMTP_URL` | `str` | *(unset)* | | The mail server invitations go through: `smtps://user:password@host:465`, or `smtp://` on 587, which must offer STARTTLS. Empty: no email, and the inviter passes the link on. | | `LOOM_MAIL_FROM` | `str` | `''` | | The From address of an invitation email, e.g. `Loom `. Empty sends none, as does an empty smtp_url or public_base_url (the link needs it). | -| `LOOM_SMTP_TIMEOUT_SECONDS` | `float` | `10.0` | | Seconds each step of sending an invitation email (connecting, TLS, the login, each command) may wait on the mail server; past it the email is reported not sent, and the link is shown to pass on. grants.invite answers after the send. | +| `LOOM_SMTP_TIMEOUT_SECONDS` | `float` | `10.0` | | Seconds each step of an invitation email may wait on the mail server; past it the email is reported not sent and the link is shown to pass on. | | `LOOM_INVITE_TTL_SECONDS` | `int` | `604800` | | Seconds an invitation link stays valid, at most 30 days: it admits whoever opens it. | | `LOOM_IDENTITY_PROVIDER` | `'' \| 'single-user' \| 'trust-network' \| 'gateway'` | `''` | | How callers authenticate: "single-user" (no auth, one anonymous identity), "trust-network" (self-signup, first claim wins) or "gateway" (an upstream proxy mints short-lived Loom JWTs with the shared HS256 secret; Loom only validates). Empty = inferred from auth_required and self_signup at boot. | | `LOOM_DASHBOARD_REDIRECT_URL` | `str` | `''` | | When set, a dashboard page load redirects (302) here instead of serving the SPA (Loom behind an aggregator). Deployment-specific; never hardcode. | diff --git a/frontend/src/views/InvitationCard.test.tsx b/frontend/src/views/InvitationCard.test.tsx index 47a0d270cf2..9e1efb8ace1 100644 --- a/frontend/src/views/InvitationCard.test.tsx +++ b/frontend/src/views/InvitationCard.test.tsx @@ -112,6 +112,18 @@ describe("InvitationCard", () => { expect(sessionStorage.getItem(INVITE_LINK)).not.toBeNull(); }); + it("keeps the link through a sign-in the session ended for", async () => { + vi.mocked(acceptInvite).mockRejectedValueOnce( + new ApiError({ status: 401, code: "AUTH_REQUIRED", message: "sign in again" }), + ); + const user = userEvent.setup(); + opened(); + await user.click(screen.getByRole("button", { name: "Accept invitation" })); + expect(await screen.findByText(/sign in again/i)).toBeInTheDocument(); + expect(screen.getByRole("button", { name: "Accept invitation" })).toBeEnabled(); + expect(sessionStorage.getItem(INVITE_LINK)).not.toBeNull(); + }); + it("keeps the link for the next visit on Not now", async () => { const user = userEvent.setup(); opened(); diff --git a/frontend/src/views/InvitationCard.tsx b/frontend/src/views/InvitationCard.tsx index 67bb3ef0777..493d8301e57 100644 --- a/frontend/src/views/InvitationCard.tsx +++ b/frontend/src/views/InvitationCard.tsx @@ -39,7 +39,8 @@ export function InvitationCard() { const [link, setLink] = useState(stashed); const [busy, setBusy] = useState(false); const [error, setError] = useState(null); - // The server refused the link (used, cancelled, expired, or for another org): only Close is left. + // The server refused the link: 404 when it is used, cancelled or expired, 422 when this + // account cannot accept it. Only Close is left. const [refused, setRefused] = useState(false); const identity = useStore((s) => s.identity); const setIdentity = useStore((s) => s.setIdentity); @@ -67,7 +68,8 @@ export function InvitationCard() { setSavedNamespace(out.namespace); } } catch (e) { - if (e instanceof ApiError && e.status >= 400 && e.status < 500) { + // Any other refusal (an ended session, a rate limit) keeps the link for a retry. + if (e instanceof ApiError && (e.status === 404 || e.status === 422)) { drop(); setRefused(true); } diff --git a/loom.example.yaml b/loom.example.yaml index ea57bcd3ed2..1b116212698 100644 --- a/loom.example.yaml +++ b/loom.example.yaml @@ -887,9 +887,8 @@ settings: # none, as does an empty smtp_url or public_base_url (the link needs it). [restart] # mail_from: "" - # Seconds each step of sending an invitation email (connecting, TLS, the login, each - # command) may wait on the mail server; past it the email is reported not sent, and - # the link is shown to pass on. grants.invite answers after the send. [restart] + # Seconds each step of an invitation email may wait on the mail server; past it the + # email is reported not sent and the link is shown to pass on. [restart] # smtp_timeout_seconds: 10.0 # Seconds an invitation link stays valid, at most 30 days: it admits whoever opens it. diff --git a/schemas/loom-settings.schema.json b/schemas/loom-settings.schema.json index 309c447c1f8..87d781a5b37 100644 --- a/schemas/loom-settings.schema.json +++ b/schemas/loom-settings.schema.json @@ -6898,7 +6898,7 @@ "exclusiveMinimum": 0, "maximum": 60, "type": "number", - "description": "Seconds each step of sending an invitation email (connecting, TLS, the login, each command) may wait on the mail server; past it the email is reported not sent, and the link is shown to pass on. grants.invite answers after the send." + "description": "Seconds each step of an invitation email may wait on the mail server; past it the email is reported not sent and the link is shown to pass on." }, "storage_authority": { "default": "clickhouse", diff --git a/server/identity/api/models_grants.py b/server/identity/api/models_grants.py index 7d590530b63..608bd86b766 100644 --- a/server/identity/api/models_grants.py +++ b/server/identity/api/models_grants.py @@ -219,11 +219,10 @@ class GrantsInviteInput(BaseModel): namespace: str # The person to give `role`: a login handle or an email. An account that signs in # under it (by its handle or a verified email), or a handle a live grant in the org is - # stored under, is granted the role at once; an email - # no account holds, one plain address, gets an invitation link, or, where sign-in is - # single sign-on only, a grant that reaches that person at their first sign-in; a - # handle no account holds is refused. A request with no token (auth off) grants it as - # typed. + # stored under, is granted the role at once; an email no account holds, one plain + # address, gets an invitation link, or, where sign-in is single sign-on only, a grant + # that reaches that person at their first sign-in; a handle no account holds is + # refused. A request with no token (auth off) grants it as typed. to: str = Field(min_length=1, max_length=320) # `viewer`, `writer` or `admin`; a code namespace takes only `viewer` and `admin`. role: GrantRoleStr diff --git a/server/identity/app/invite_mail.py b/server/identity/app/invite_mail.py index f4b973c8e80..b9d2d856e35 100644 --- a/server/identity/app/invite_mail.py +++ b/server/identity/app/invite_mail.py @@ -12,7 +12,6 @@ from email.message import EmailMessage from urllib.parse import unquote, urlsplit -from server.core.logging_config import log_value from server.settings import settings log = logging.getLogger(__name__) @@ -78,6 +77,7 @@ async def send_invite( ) await asyncio.to_thread(_send, msg) except Exception as e: # noqa: BLE001 — a failed email leaves the link to copy - log.warning("invite mail: not sent to %s: %s", log_value(repr(to)), type(e).__name__) + # Not the address: the audit row leaves it out, and no erasure reaches the log. + log.warning("invite mail: not sent: %s", type(e).__name__) return False return True diff --git a/server/identity/app/invites.py b/server/identity/app/invites.py index 25a72bd4be9..8cf49176281 100644 --- a/server/identity/app/invites.py +++ b/server/identity/app/invites.py @@ -31,6 +31,7 @@ from server.auth.grant_claims import invite_change from server.auth.revocation import is_revoked from server.auth.self_signup import valid_signup_email +from server.core.ch import own_write_reads from server.core.errors import ( BackendUnavailableError, GrantWouldDowngradeError, @@ -308,7 +309,9 @@ async def _reopen_unless_granted(invite: domain.Invite, subject: str) -> None: async with invite_change(invite.org, invite.namespace, invite.invite_id): granted_to = await canonical_subject(invite.org, subject) - held = await grants_repo.find_active_grant(invite.org, invite.namespace, granted_to) + # Right after the grant's own write: another replica may not have it yet. + with own_write_reads(): + held = await grants_repo.find_active_grant(invite.org, invite.namespace, granted_to) if held is not None and grant_rank(held.role) >= grant_rank(invite.role): return current = await invites_repo.get(invite.org, invite.namespace, invite.invite_id) diff --git a/server/settings/catalog.py b/server/settings/catalog.py index 61e241eb4e9..062029dd2fd 100644 --- a/server/settings/catalog.py +++ b/server/settings/catalog.py @@ -460,17 +460,14 @@ def trusted_issuers(self) -> set[str]: # Default org for self-signed tokens. self_signup_org: str = "dev" - # The mail server an invitation is emailed through: `smtps://user:password@host:465` - # (TLS from the start) or `smtp://user:password@host:587` (STARTTLS, which every send - # requires: the email carries the link). Empty: no email is sent, and whoever makes an - # invitation sends its link. + # The mail server invitations go through: `smtps://user:password@host:465`, or `smtp://` + # on 587, which must offer STARTTLS. Empty: no email, and the inviter passes the link on. smtp_url: str = "" # The From address of an invitation email, e.g. `Loom `. Empty # sends none, as does an empty smtp_url or public_base_url (the link needs it). mail_from: str = "" - # Seconds each step of sending an invitation email (connecting, TLS, the login, each - # command) may wait on the mail server; past it the email is reported not sent, and - # the link is shown to pass on. grants.invite answers after the send. + # Seconds each step of an invitation email may wait on the mail server; past it the + # email is reported not sent and the link is shown to pass on. smtp_timeout_seconds: float = Field(default=10.0, gt=0, le=60) # Seconds an invitation link stays valid, at most 30 days: it admits whoever opens it. invite_ttl_seconds: int = Field(default=7 * 86400, ge=3600, le=30 * 86400) diff --git a/tests/unit/test_grants_invite.py b/tests/unit/test_grants_invite.py index 0f15118741c..de952120ad9 100644 --- a/tests/unit/test_grants_invite.py +++ b/tests/unit/test_grants_invite.py @@ -19,6 +19,7 @@ from server.auth import fail_closed from server.auth.context import set_current_auth from server.auth.jwt import AuthInfo +from server.core.ch import sequential_reads_active from server.core.errors import ( BackendUnavailableError, GrantWouldDowngradeError, @@ -117,6 +118,8 @@ async def account_active(org: str, creator: str) -> bool: return creator not in w.disabled async def find_active_grant(org: str, namespace: str, subject: str, **_: Any) -> Any: + if not sequential_reads_active(): + return None # a replica that has not seen the grant just written held = [ g for g, _ in w.grants if (g.org, g.namespace, g.subject) == (org, namespace, subject) ] diff --git a/tests/unit/test_invites_store_sql.py b/tests/unit/test_invites_store_sql.py index 54416e1a74b..189cba905f9 100644 --- a/tests/unit/test_invites_store_sql.py +++ b/tests/unit/test_invites_store_sql.py @@ -20,7 +20,7 @@ pytestmark = pytest.mark.skipif(CLICKHOUSE is None, reason="clickhouse binary not installed") MADE = datetime(2026, 1, 1, tzinfo=UTC) -LATER = 2**31 +LATER = int(time.time()) + 30 * 86400 def _invite( From 84ac002ffa0754ee3280a90fad0b1ee4d72bd67e Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Sat, 5 Dec 2026 07:30:10 +0530 Subject: [PATCH 23/28] Reopen a link after a cancelled or lost accept, and list only links that admit someone The reopen after a failed accept runs to its end through a cancellation (anyio repeats one at every await) and also follows a lost reply to the write that spends the link. The mail limits are read before the invitation is stored, so one that cannot be read leaves no link listed that nobody was given. The open invitations leave out a link whose maker no longer stands. A tokenless request answers under the subject the grant is written under. The help, the sent notice and the docs say an email is granted at once only when it is verified for an account. The store test reads the row back field for field, and the two alternatives the body names are in the sharing page. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Lareb Zafar --- docs/architecture/sharing.md | 4 + docs/features/dashboard.md | 9 +- docs/reference/operations/grants.md | 2 +- frontend/src/components/Invitations.test.tsx | 2 +- frontend/src/components/Invitations.tsx | 2 +- frontend/src/components/SubjectHelp.tsx | 8 +- server/identity/api/models_grants.py | 8 +- server/identity/app/invites.py | 91 ++++++++++++-------- server/transport/mcp_descriptions.py | 3 +- tests/unit/test_grants_invite.py | 65 ++++++++++++++ tests/unit/test_invites_store_sql.py | 2 +- 11 files changed, 143 insertions(+), 53 deletions(-) diff --git a/docs/architecture/sharing.md b/docs/architecture/sharing.md index 8f88afc49ba..5b5bc1bd090 100644 --- a/docs/architecture/sharing.md +++ b/docs/architecture/sharing.md @@ -442,6 +442,10 @@ One text serves agents and people, so there is no second copy to drift. the grant. - **The invitation's secret in the query string.** It would reach access logs and Referer headers. +- **Binding acceptance to the invited address.** A password account has no verified email + to compare, so only the link can prove the address was reached. +- **Cancelling a maker's invitations when their grant is revoked.** A best-effort cascade + would leave a link open when it fails; reading the grant at acceptance fails closed. - **Inheritance resolved at write time.** Moving a collection would rewrite the grants of every descendant; resolving at check time from a cached tree costs a walk of at most eight parents. diff --git a/docs/features/dashboard.md b/docs/features/dashboard.md index b8bd8664623..804961d2946 100644 --- a/docs/features/dashboard.md +++ b/docs/features/dashboard.md @@ -120,10 +120,11 @@ On Namespaces in your org, a search for the exact name of a namespace the list d show offers **Request access**, which is how a private namespace is asked for by name; a repository's or collection's name points to Repositories or the Library instead. **Invite** on a namespace you manage opens its members on the add field. The field takes a person's -login handle, which their account menu shows under **Signed in as** and which may be an -email, or a service account `sa:`. A collection's **Share** also takes a group -`group:`, an agent `agent:` or `everyone`. A login handle no account holds is refused. -Any other email gets an [invitation](namespaces-and-sharing.md#membership-and-grants). The add +login handle, which their account menu shows under **Signed in as**, an email, or a +service account `sa:`. A collection's **Share** also takes a group `group:`, an +agent `agent:` or `everyone`. A login handle no account holds is refused. An email is +granted at once only when it is verified for an account; any other email gets an +[invitation](namespaces-and-sharing.md#membership-and-grants). The add shows its link to copy, and the server emails it when it sends mail. The members dialog and a repository's Access tab list it under **Invited**, with who made it and **Cancel**, until it is accepted. Where sign-in is single sign-on only, the email is granted instead diff --git a/docs/reference/operations/grants.md b/docs/reference/operations/grants.md index bce91cfa71f..576cb7d387a 100644 --- a/docs/reference/operations/grants.md +++ b/docs/reference/operations/grants.md @@ -96,7 +96,7 @@ Give a person a role on a namespace by login handle or email. | --- | --- | --- | --- | | `org` | `str` | required | The tenant (first element of the identity tuple). | | `namespace` | `str` | required | The namespace the op reads or writes. | -| `to` | `str` | required | The person to give `role`: a login handle or an email. | +| `to` | `str` | required | The person to give `role`: a login handle, or an email, which is granted at once only when it is verified for an account and otherwise gets an invitation link. | | `role` | `Literal['viewer', 'writer', 'admin']` | required | `viewer`, `writer` or `admin`; a code namespace takes only `viewer` and `admin`. | | Output field | Type | Meaning | diff --git a/frontend/src/components/Invitations.test.tsx b/frontend/src/components/Invitations.test.tsx index 8f425353283..7cf155958b1 100644 --- a/frontend/src/components/Invitations.test.tsx +++ b/frontend/src/components/Invitations.test.tsx @@ -24,7 +24,7 @@ const sent = { describe("InviteSent", () => { it("hands over the link on this page's address when the server knows none", () => { render(); - expect(screen.getByRole("status")).toHaveTextContent("No account signs in as pat@example.com yet."); + expect(screen.getByRole("status")).toHaveTextContent("No account in this org has verified pat@example.com."); expect( screen.getByText(`${window.location.origin}/spaces#invite=s3cret&org=dev&namespace=team`), ).toBeInTheDocument(); diff --git a/frontend/src/components/Invitations.tsx b/frontend/src/components/Invitations.tsx index fc7d8ccf84b..4ed4b026fd4 100644 --- a/frontend/src/components/Invitations.tsx +++ b/frontend/src/components/Invitations.tsx @@ -15,7 +15,7 @@ export function InviteSent({ email, result }: { email: string; result: InviteRes

    {result.emailed ? `Emailed an invitation to ${email}. You can also send them this link:` - : `No account signs in as ${email} yet. Send them this link:`} + : `No account in this org has verified ${email}. Send them this link:`}

    {link} diff --git a/frontend/src/components/SubjectHelp.tsx b/frontend/src/components/SubjectHelp.tsx index 310f3d03509..9cb14525bcd 100644 --- a/frontend/src/components/SubjectHelp.tsx +++ b/frontend/src/components/SubjectHelp.tsx @@ -3,10 +3,10 @@ export function SubjectHelp({ id, collection = false }: { id: string; collection?: boolean }) { return (

    - A login handle is the name a person signs in with, shown in their account menu under Signed in as; it may be an - email. Any other email gets an invitation link, emailed too when this server sends mail; whoever opens it signed - in joins. Where sign-in is single sign-on only, the email is granted instead. A service account is{" "} - sa:<name> + A login handle is the name a person signs in with, shown in their account menu under Signed in as. An email is + granted at once only when it is verified for an account; any other email gets an invitation link, emailed too when + this server sends mail, and whoever opens it signed in joins. Where sign-in is single sign-on only, the email is + granted instead. A service account is sa:<name> {collection ? ( <> , a group group:<id>, an agent{" "} diff --git a/server/identity/api/models_grants.py b/server/identity/api/models_grants.py index 608bd86b766..590ed9879f9 100644 --- a/server/identity/api/models_grants.py +++ b/server/identity/api/models_grants.py @@ -217,12 +217,8 @@ class GrantsInviteInput(BaseModel): org: str namespace: str - # The person to give `role`: a login handle or an email. An account that signs in - # under it (by its handle or a verified email), or a handle a live grant in the org is - # stored under, is granted the role at once; an email no account holds, one plain - # address, gets an invitation link, or, where sign-in is single sign-on only, a grant - # that reaches that person at their first sign-in; a handle no account holds is - # refused. A request with no token (auth off) grants it as typed. + # The person to give `role`: a login handle, or an email, which is granted at once + # only when it is verified for an account and otherwise gets an invitation link. to: str = Field(min_length=1, max_length=320) # `viewer`, `writer` or `admin`; a code namespace takes only `viewer` and `admin`. role: GrantRoleStr diff --git a/server/identity/app/invites.py b/server/identity/app/invites.py index 8cf49176281..4bb4a58bb9d 100644 --- a/server/identity/app/invites.py +++ b/server/identity/app/invites.py @@ -40,6 +40,7 @@ ) from server.core.logging_config import log_value from server.core.principals import has_aliases, is_reserved_subject +from server.core.shielded import finish_cleanup from server.identity.api.models_grants import ( GrantsAcceptInviteInput, GrantsAcceptInviteOutput, @@ -124,13 +125,13 @@ async def _held(org: str, person: str) -> str | None: async def handle_grants_invite(input: GrantsInviteInput) -> GrantsInviteOutput: person = _person(input.to) _enforce_principal_target(input.namespace, person) + subject = await _held(input.org, person) + if subject is not None: + return await _granted(input, person, subject) maker = _maker() if not maker: # A request with no token, which only auth off serves: no one signs in to accept. return await _granted(input, person, person) - subject = await _held(input.org, person) - if subject is not None: - return await _granted(input, person, subject) if "@" not in person: raise NotFoundError( f"no account in {input.org} signs in as {person!r}: check the login handle, " @@ -161,17 +162,21 @@ async def _granted(input: GrantsInviteInput, person: str, subject: str) -> Grant async def _maker_stands(org: str, namespace: str, maker: str, made_at: int) -> bool: """Whether `maker` still stands behind a link made at `made_at` (Unix seconds), as a - delegated token's creator stands behind it: their grants make them admin there - (`authz.subject_grant_role`), their account is active, and neither they nor tokens of - theirs that old are revoked. A read that fails answers 503, so a link is not given - up for an outage.""" + delegated token's creator stands behind it: `_maker_admin`, and neither they nor + tokens of theirs that old are revoked.""" + return await _maker_admin(org, namespace, maker) and not is_revoked(maker, issued_at=made_at) + + +async def _maker_admin(org: str, namespace: str, maker: str) -> bool: + """Whether `maker`'s grants make them admin there (`authz.subject_grant_role`) and + their account is active. A read that fails answers 503, so a link is not given up + for an outage.""" reset() # this decision's own reads, not an earlier one's in the request role = await subject_grant_role(org, namespace, maker) active = await creator_account_active(org, maker) if unreadable(): raise BackendUnavailableError("the inviter's grants could not be read: try again") - admin = role is not None and role.value >= Role.ADMIN.value - return admin and active and not is_revoked(maker, issued_at=made_at) + return role is not None and role.value >= Role.ADMIN.value and active async def _invite(input: GrantsInviteInput, email: str, maker: str) -> GrantsInviteOutput: @@ -193,11 +198,14 @@ async def _invite(input: GrantsInviteInput, email: str, maker: str) -> GrantsInv created_at=now, expires_at=int(now.timestamp()) + settings.invite_ttl_seconds, ) + # Asked before the row: a limit that cannot be read fails the invitation, not a link + # left listed that nobody was given. + may_mail = await _may_mail(input.org, maker, email) await invites_repo.put(invite) path = domain.link_path(input.org, input.namespace, secret) base = settings.public_base_url.strip().rstrip("/") url = f"{base}{path}" if base else "" - emailed = await _may_mail(input.org, maker, email) and await invite_mail.send_invite( + emailed = may_mail and await invite_mail.send_invite( email, inviter=invite.created_by, namespace=input.namespace, @@ -226,6 +234,10 @@ async def _may_mail(org: str, inviter: str, email: str) -> bool: async def handle_grants_list_invites(input: GrantsListInvitesInput) -> GrantsListInvitesOutput: rows = await invites_repo.open_on(input.org, input.namespace, int(time.time()), _LISTED) + # A link whose maker no longer stands admits nobody, so it is not listed as open. + admin = { + m: await _maker_admin(input.org, input.namespace, m) for m in {r.created_by for r in rows} + } return GrantsListInvitesOutput( rows=[ _InviteEntry( @@ -237,7 +249,9 @@ async def handle_grants_list_invites(input: GrantsListInvitesInput) -> GrantsLis expires_at=datetime.fromtimestamp(r.expires_at, UTC), ) for r in rows - if (role := _role(r.role)) is not None + if admin[r.created_by] + and not is_revoked(r.created_by, issued_at=int(r.created_at.timestamp())) + and (role := _role(r.role)) is not None ] ) @@ -270,36 +284,45 @@ def _accepter(org: str) -> str: async def handle_grants_accept_invite(input: GrantsAcceptInviteInput) -> GrantsAcceptInviteOutput: subject = _accepter(input.org) invite_id = domain.invite_id(input.secret) - async with invite_change(input.org, input.namespace, invite_id): - invite = await invites_repo.get(input.org, input.namespace, invite_id) - role = None if invite is None else _role(invite.role) - if invite is None or role is None or not invite.is_open(int(time.time())): - raise NotFoundError(_GONE) - if not await namespaces_repo.is_active(input.org, input.namespace): - raise NotFoundError(_GONE) - made_at = int(invite.created_at.timestamp()) - if not await _maker_stands(invite.org, invite.namespace, invite.created_by, made_at): - raise NotFoundError(_GONE) - # Spent under the claim, before the grant: a link never lets two people in. The - # grant takes its own claims after this one, as `grant_claims` orders them. - await invites_repo.put(invite.accepted(subject, datetime.now(UTC))) + spent: domain.Invite | None = None try: + async with invite_change(input.org, input.namespace, invite_id): + invite = await invites_repo.get(input.org, input.namespace, invite_id) + role = None if invite is None else _role(invite.role) + if invite is None or role is None or not invite.is_open(int(time.time())): + raise NotFoundError(_GONE) + if not await namespaces_repo.is_active(input.org, input.namespace): + raise NotFoundError(_GONE) + made_at = int(invite.created_at.timestamp()) + if not await _maker_stands(invite.org, invite.namespace, invite.created_by, made_at): + raise NotFoundError(_GONE) + # Spent under the claim, before the grant: a link never lets two people in. The + # grant takes its own claims after this one, as `grant_claims` orders them. + spent = invite + await invites_repo.put(invite.accepted(subject, datetime.now(UTC))) held = await _grant(invite, role, subject) except BaseException: - try: - await _reopen_unless_granted(invite, subject) - except Exception as e: # noqa: BLE001 — the grant's error is the answer; link stays used - log.warning( - "invitation %s on %s/%s stays used after a failed grant: %s", - log_value(invite.invite_id[:12]), - log_value(invite.org), - log_value(invite.namespace), - type(e).__name__, - ) + if spent is not None: + await _reopen_after_failure(spent, subject) raise return GrantsAcceptInviteOutput(namespace=input.namespace, role=held) +async def _reopen_after_failure(invite: domain.Invite, subject: str) -> None: + """`_reopen_unless_granted`, run to its end through a cancellation (anyio repeats one + at every await); a reopen that fails leaves the link used.""" + try: + await finish_cleanup(_reopen_unless_granted(invite, subject), name="invite.reopen") + except Exception as e: # noqa: BLE001 — the failure's error is the answer; link stays used + log.warning( + "invitation %s on %s/%s stays used after a failed accept: %s", + log_value(invite.invite_id[:12]), + log_value(invite.org), + log_value(invite.namespace), + type(e).__name__, + ) + + async def _reopen_unless_granted(invite: domain.Invite, subject: str) -> None: """Open the link again after a failed grant, unless the grant landed before the failure (a lost reply, a step after the write): then it stays used. The grant is read diff --git a/server/transport/mcp_descriptions.py b/server/transport/mcp_descriptions.py index c2a62d424dc..c30e6ad6593 100644 --- a/server/transport/mcp_descriptions.py +++ b/server/transport/mcp_descriptions.py @@ -472,7 +472,8 @@ def revision_policy(update: str) -> str: "grants.invite": ( "Give a person a role on a namespace by login handle or email. Call when " 'an admin wants to add someone — "add bob@example.com as writer on X". ' - "An account that signs in under it is granted at once; any other email gets " + "A handle an account or a live grant holds, or an email verified for an " + "account, is granted at once; any other email gets " "a single-use invitation link (emailed when the server sends mail) to pass " "on, or, where sign-in is single sign-on only, a grant as typed; a handle no " "account holds is refused." diff --git a/tests/unit/test_grants_invite.py b/tests/unit/test_grants_invite.py index de952120ad9..1c0f0e3f8ae 100644 --- a/tests/unit/test_grants_invite.py +++ b/tests/unit/test_grants_invite.py @@ -14,6 +14,7 @@ from typing import Any, ClassVar from urllib.parse import parse_qs, urlsplit +import anyio import pytest from server.auth import fail_closed @@ -67,6 +68,11 @@ def __init__(self) -> None: self.mail: list[dict[str, Any]] = [] self.may_mail = True self.mail_asked: list[tuple[Any, ...]] = [] + self.mail_error: BaseException | None = None + # Raised by the write that spends a link, after it lands (a lost reply). + self.put_error: BaseException | None = None + # Cancelled from inside the grant, as a client gone mid-request cancels it. + self.cancel: anyio.CancelScope | None = None @pytest.fixture @@ -76,6 +82,8 @@ def world(monkeypatch: pytest.MonkeyPatch) -> Iterator[World]: async def put(invite: domain.Invite, **_: Any) -> None: w.invites[invite.invite_id] = invite w.writes.append(invite) + if w.put_error is not None and invite.state == "accepted": + raise w.put_error async def get(org: str, namespace: str, invite_id: str, **_: Any) -> domain.Invite | None: found = w.invites.get(invite_id) @@ -104,6 +112,9 @@ async def canonical(org: str, subject: str, **_: Any) -> str: async def create_grant(input: GrantsCreateInput, *_a: Any, issuer: str | None = None) -> None: # Written under the handle a verified email ties to, as the real one writes it. input = input.model_copy(update={"subject": w.verified.get(input.subject, input.subject)}) + if w.cancel is not None: + w.cancel.cancel() + await anyio.lowlevel.checkpoint() if w.grant_lands: w.grants.append((input, issuer)) if w.grant_error is not None: @@ -138,6 +149,7 @@ async def no_ceiling(*_a: Any, **_k: Any) -> None: @contextlib.asynccontextmanager async def claimed(*_a: Any) -> AsyncIterator[None]: + await anyio.lowlevel.checkpoint() # the lease's own round trip, where a cancel lands yield async def send(to: str, **kw: Any) -> bool: @@ -162,6 +174,8 @@ async def send(to: str, **kw: Any) -> bool: monkeypatch.setattr(mod.invite_mail, "send_invite", send) async def may_mail(*a: Any) -> bool: + if w.mail_error is not None: + raise w.mail_error w.mail_asked.append(a) return w.may_mail @@ -289,9 +303,19 @@ async def test_a_request_with_no_token_grants_a_person_as_typed(world: World) -> set_current_auth(None) out = await invite("new@example.com") assert (out.outcome, out.subject) == ("granted", "new@example.com") + # Answered under the subject the grant is written under. + assert (await invite("sso@example.com")).subject == "sso-handle" assert world.invites == {} +@pytest.mark.asyncio +async def test_a_mail_limit_that_cannot_be_read_leaves_no_link_listed(world: World) -> None: + world.mail_error = BackendUnavailableError("down") + with pytest.raises(BackendUnavailableError): + await invite("michael@example.com") + assert world.writes == [] + + @pytest.mark.asyncio async def test_an_email_no_account_holds_gets_a_link_kept_only_as_its_hash(world: World) -> None: out = await invite("Michael@Example.com") @@ -393,6 +417,33 @@ async def test_a_failed_grant_leaves_the_link_open(world: World) -> None: assert (await accept(secret)).role == "writer" +@pytest.mark.asyncio +async def test_a_lost_reply_to_the_spend_leaves_the_link_open(world: World) -> None: + secret = secret_of((await invite("michael@example.com")).link_path) + world.put_error = BackendUnavailableError("lost reply") + signed_in("mlex") + with pytest.raises(BackendUnavailableError): + await accept(secret) + iid = domain.invite_id(secret) + assert [w.state for w in world.writes if w.invite_id == iid] == ["open", "accepted", "open"] + assert world.grants == [] + + +@pytest.mark.asyncio +async def test_a_cancelled_accept_leaves_the_link_open(world: World) -> None: + """anyio raises a cancellation again at every await of its scope: the reopen still + runs to its end.""" + secret = secret_of((await invite("michael@example.com")).link_path) + signed_in("mlex") + with anyio.CancelScope() as scope: + world.cancel = scope + await accept(secret) + assert scope.cancelled_caught + iid = domain.invite_id(secret) + assert [w.state for w in world.writes if w.invite_id == iid] == ["open", "accepted", "open"] + assert world.grants == [] + + @pytest.mark.asyncio async def test_a_failure_after_the_grant_landed_leaves_the_link_used(world: World) -> None: secret = secret_of((await invite("michael@example.com")).link_path) @@ -476,6 +527,20 @@ async def test_a_link_stops_with_its_makers_account(world: World, ended: str) -> assert world.grants == [] and world.invites[domain.invite_id(secret)].state == "open" +@pytest.mark.parametrize("ended", ["lowered", "disabled", "revoked"]) +@pytest.mark.asyncio +async def test_a_link_whose_maker_no_longer_stands_is_not_listed(world: World, ended: str) -> None: + """It admits nobody, so the members dialog does not show it as open.""" + await invite("michael@example.com") + scope = GrantsListInvitesInput(org="o", namespace="ns") + assert len((await mod.handle_grants_list_invites(scope)).rows) == 1 + if ended == "lowered": + world.maker_roles["admin-ann"] = Role.WRITER + else: + getattr(world, ended).add("admin-ann") + assert (await mod.handle_grants_list_invites(scope)).rows == [] + + @pytest.mark.asyncio async def test_a_failed_read_earlier_in_the_request_does_not_refuse_the_maker( world: World, diff --git a/tests/unit/test_invites_store_sql.py b/tests/unit/test_invites_store_sql.py index 189cba905f9..617ffb83de1 100644 --- a/tests/unit/test_invites_store_sql.py +++ b/tests/unit/test_invites_store_sql.py @@ -51,7 +51,7 @@ async def test_the_newest_state_wins_and_each_read_finds_what_it_promises( await invites_repo.put(_invite("d", maker="bea", namespace="other"), ch=ch) # type: ignore[arg-type] got = await invites_repo.get("acme", "team", "a", ch=ch) # type: ignore[arg-type] - assert got is not None and (got.state, got.accepted_by) == ("accepted", "lee") + assert got == _invite("a").accepted("lee", MADE) assert await invites_repo.get("acme", "other", "a", ch=ch) is None # type: ignore[arg-type] listed = await invites_repo.open_on("acme", "team", soon + 1, 10, ch=ch) # type: ignore[arg-type] assert [i.invite_id for i in listed] == ["b"] From bfea13a91ff860746ec0360c827f676104956d3e Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Sat, 5 Dec 2026 08:14:11 +0530 Subject: [PATCH 24/28] Stop an end user's links with their revocation, and name the gateway case The maker check reads an end user's revocation under /user:, the subject their tokens are revoked by, so their links stop with it, at accept and in the open list. smtp_url takes only smtps:// or smtp:// and is refused at load otherwise. The erasure test runs the step and reads the invitation it leaves. The sharing page names what an add does for a person whose tokens Loom does not mint at sign-in, and why the gateway identity provider cannot mark that server. Fixture names are placeholders, and two docstrings say what their reads match. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Lareb Zafar --- docs/architecture/sharing.md | 7 + frontend/src/components/Invitations.test.tsx | 2 +- .../src/flows/MembersDialog.invite.test.tsx | 4 +- frontend/src/views/Code.accessInvite.test.tsx | 8 +- server/identity/app/invite_mail.py | 4 +- server/identity/app/invites.py | 33 +++-- server/identity/store/namespaces.py | 6 +- server/settings/catalog.py | 2 +- tests/integration/test_grants_invite.py | 24 +-- tests/unit/test_audit_subject_credentials.py | 4 +- tests/unit/test_grants_invite.py | 140 ++++++++++-------- tests/unit/test_invites_store_sql.py | 6 +- tests/unit/test_settings_env_contract.py | 1 + 13 files changed, 143 insertions(+), 98 deletions(-) diff --git a/docs/architecture/sharing.md b/docs/architecture/sharing.md index 5b5bc1bd090..1d6ecb7d13d 100644 --- a/docs/architecture/sharing.md +++ b/docs/architecture/sharing.md @@ -220,6 +220,13 @@ provider verifies every account's email, so an email no account holds is granted through `grants.create` instead, and reaches that person at their first sign-in. There is no link to pass on. +For a person whose tokens Loom does not mint at sign-in (an upstream gateway's, +`loom mint-token`'s, or a trusted caller's on their behalf), an email gets a link too, +accepted by whoever opens it signed in, and a handle Loom has not seen yet is refused. +`grants.create` grants either as typed, for a subject the token's minter names. The +`gateway` identity provider does not mark such a server: a password server with sign-up +off infers it too, and there a grant by email would reach nobody. + The server's mail is no relay for a namespace admin, whom any sign-up can make: it emails at most 20 invitations an hour per inviter and 3 a day per address, counted in `loom.auth_attempts` across the deployment (`server.auth.attempts`). Past either limit diff --git a/frontend/src/components/Invitations.test.tsx b/frontend/src/components/Invitations.test.tsx index 7cf155958b1..7a76164eb92 100644 --- a/frontend/src/components/Invitations.test.tsx +++ b/frontend/src/components/Invitations.test.tsx @@ -66,7 +66,7 @@ describe("OpenInvitations", () => { describe("isPersonSpelling", () => { it("tells a person from a principal", () => { - for (const s of ["mlex", "pat@example.com", "Pat"]) expect(isPersonSpelling(s)).toBe(true); + for (const s of ["robin", "pat@example.com", "Pat"]) expect(isPersonSpelling(s)).toBe(true); for (const s of ["sa:bot", "group:eng", "user:42", "agent:x", "everyone", "Everyone", "*", "acme/user:1"]) expect(isPersonSpelling(s)).toBe(false); }); diff --git a/frontend/src/flows/MembersDialog.invite.test.tsx b/frontend/src/flows/MembersDialog.invite.test.tsx index eec11011731..5a175a8b9bc 100644 --- a/frontend/src/flows/MembersDialog.invite.test.tsx +++ b/frontend/src/flows/MembersDialog.invite.test.tsx @@ -74,8 +74,8 @@ describe("MembersDialog invites a person", () => { }); it("grants an account's handle at once, under the subject the server names", async () => { - vi.mocked(invites.invite).mockResolvedValue({ ...invited, outcome: "granted", subject: "mlex", invite_id: "" }); - await add("MLex"); + vi.mocked(invites.invite).mockResolvedValue({ ...invited, outcome: "granted", subject: "robin", invite_id: "" }); + await add("Robin"); await waitFor(() => expect(invites.invite).toHaveBeenCalledTimes(1)); expect(screen.queryByRole("status")).toBeNull(); expect(screen.queryByRole("textbox", { name: /member to add/ })).toBeNull(); diff --git a/frontend/src/views/Code.accessInvite.test.tsx b/frontend/src/views/Code.accessInvite.test.tsx index f0e21d5bc0e..94820ad328e 100644 --- a/frontend/src/views/Code.accessInvite.test.tsx +++ b/frontend/src/views/Code.accessInvite.test.tsx @@ -38,7 +38,7 @@ it("names the handle the server granted, not what was typed", async () => { vi.mocked(invites.invite).mockResolvedValue({ outcome: "granted", role: "viewer", - subject: "mlex", + subject: "robin", invite_id: "", link_path: "", url: "", @@ -49,7 +49,7 @@ it("names the handle the server granted, not what was typed", async () => { render(); const field = await screen.findByRole("textbox", { name: "Login handle or email of the reader to add" }); await waitFor(() => expect(field).toBeEnabled()); - await user.type(field, "MLex{Enter}"); - await waitFor(() => expect(toast).toHaveBeenCalledWith(expect.stringMatching(/^mlex is now a /), "ok")); - expect(invites.invite).toHaveBeenCalledWith({ org: "dev", namespace: "code-app" }, "MLex", expect.any(String)); + await user.type(field, "Robin{Enter}"); + await waitFor(() => expect(toast).toHaveBeenCalledWith(expect.stringMatching(/^robin is now a /), "ok")); + expect(invites.invite).toHaveBeenCalledWith({ org: "dev", namespace: "code-app" }, "Robin", expect.any(String)); }); diff --git a/server/identity/app/invite_mail.py b/server/identity/app/invite_mail.py index b9d2d856e35..68e53fbc94f 100644 --- a/server/identity/app/invite_mail.py +++ b/server/identity/app/invite_mail.py @@ -46,10 +46,8 @@ def _send(msg: EmailMessage) -> None: client = smtplib.SMTP_SSL( host, u.port or 465, context=tls, timeout=settings.smtp_timeout_seconds ) - elif u.scheme == "smtp": + else: # smtp://, the only other scheme the setting takes client = smtplib.SMTP(host, u.port or 587, timeout=settings.smtp_timeout_seconds) - else: - raise ValueError("smtp_url must start with smtp:// or smtps://") with client: if u.scheme == "smtp": client.ehlo() diff --git a/server/identity/app/invites.py b/server/identity/app/invites.py index 4bb4a58bb9d..8af7e51b859 100644 --- a/server/identity/app/invites.py +++ b/server/identity/app/invites.py @@ -39,7 +39,13 @@ ValidationError, ) from server.core.logging_config import log_value -from server.core.principals import has_aliases, is_reserved_subject +from server.core.principals import ( + USER, + end_user_revocation_subject, + has_aliases, + is_reserved_subject, + principal_id, +) from server.core.shielded import finish_cleanup from server.identity.api.models_grants import ( GrantsAcceptInviteInput, @@ -109,8 +115,10 @@ async def _held(org: str, person: str) -> str | None: """The subject an account signs in as for `person`, as stored; None when there is none. An email counts only through the handle it is verified for: a row's `owner_email` and a grant's subject are whatever their writer typed. A handle counts - when an account's row is owned under it or a live grant in the org is stored under it - (a person whose tokens Loom did not mint at sign-in has no account row).""" + when an active row is owned under it or a live grant in the org is stored under it + (a person whose tokens Loom did not mint at sign-in has no account row): sign-up + refuses such a name (`self_signup._refuse_empowered`), so no later account takes + a grant meant for it.""" from server.auth.aliases import canonical_subject subject = await canonical_subject(org, person) @@ -127,11 +135,11 @@ async def handle_grants_invite(input: GrantsInviteInput) -> GrantsInviteOutput: _enforce_principal_target(input.namespace, person) subject = await _held(input.org, person) if subject is not None: - return await _granted(input, person, subject) + return await _granted(input, subject) maker = _maker() if not maker: # A request with no token, which only auth off serves: no one signs in to accept. - return await _granted(input, person, person) + return await _granted(input, person) if "@" not in person: raise NotFoundError( f"no account in {input.org} signs in as {person!r}: check the login handle, " @@ -141,7 +149,7 @@ async def handle_grants_invite(input: GrantsInviteInput) -> GrantsInviteOutput: # One plain address, so it names one recipient and keys its own mail limit. raise ValidationError(f"{person!r} is not an email address") if settings.oauth_login_provider == "oidc": - return await _granted(input, person, person) + return await _granted(input, person) await _enforce_code_ceiling(input.org, input.namespace, input.role) if not await namespaces_repo.is_active(input.org, input.namespace): raise NotFoundError( @@ -151,7 +159,7 @@ async def handle_grants_invite(input: GrantsInviteInput) -> GrantsInviteOutput: return await _invite(input, person.lower(), maker) -async def _granted(input: GrantsInviteInput, person: str, subject: str) -> GrantsInviteOutput: +async def _granted(input: GrantsInviteInput, subject: str) -> GrantsInviteOutput: await create_grant( GrantsCreateInput( org=input.org, namespace=input.namespace, subject=subject, role=input.role @@ -164,7 +172,14 @@ async def _maker_stands(org: str, namespace: str, maker: str, made_at: int) -> b """Whether `maker` still stands behind a link made at `made_at` (Unix seconds), as a delegated token's creator stands behind it: `_maker_admin`, and neither they nor tokens of theirs that old are revoked.""" - return await _maker_admin(org, namespace, maker) and not is_revoked(maker, issued_at=made_at) + return await _maker_admin(org, namespace, maker) and not _revoked(org, maker, made_at) + + +def _revoked(org: str, maker: str, made_at: int) -> bool: + """Whether `maker`'s tokens as old as `made_at` are revoked, under the subject the + token check reads: an end user's is `/user:`.""" + key = end_user_revocation_subject(org, maker) if principal_id(maker, USER) else maker + return is_revoked(key, issued_at=made_at) async def _maker_admin(org: str, namespace: str, maker: str) -> bool: @@ -250,7 +265,7 @@ async def handle_grants_list_invites(input: GrantsListInvitesInput) -> GrantsLis ) for r in rows if admin[r.created_by] - and not is_revoked(r.created_by, issued_at=int(r.created_at.timestamp())) + and not _revoked(input.org, r.created_by, int(r.created_at.timestamp())) and (role := _role(r.role)) is not None ] ) diff --git a/server/identity/store/namespaces.py b/server/identity/store/namespaces.py index cf47656bf9a..6a05a1d5524 100644 --- a/server/identity/store/namespaces.py +++ b/server/identity/store/namespaces.py @@ -94,9 +94,9 @@ async def is_active(org: str, namespace: str, *, ch: _CHClient | None = None) -> async def account_handle(org: str, subject: str, *, ch: _CHClient | None = None) -> str | None: - """The login handle, as stored, of the active account of `org` that signs in as - `subject` in any case; None when none does. Read past an account another replica - just made.""" + """The owner, as stored, of an active row of `org` owned under `subject` in any case + (an account's own row, or a namespace registered for that owner); None when none is. + Read past a row another replica just made.""" with own_write_reads(): row = await (ch or _default_client()).query_one( """ diff --git a/server/settings/catalog.py b/server/settings/catalog.py index 062029dd2fd..e8f0d03d1f8 100644 --- a/server/settings/catalog.py +++ b/server/settings/catalog.py @@ -462,7 +462,7 @@ def trusted_issuers(self) -> set[str]: # The mail server invitations go through: `smtps://user:password@host:465`, or `smtp://` # on 587, which must offer STARTTLS. Empty: no email, and the inviter passes the link on. - smtp_url: str = "" + smtp_url: Annotated[str, Field(pattern=r"^(?:smtps?://.+)?$")] = "" # The From address of an invitation email, e.g. `Loom `. Empty # sends none, as does an empty smtp_url or public_base_url (the link needs it). mail_from: str = "" diff --git a/tests/integration/test_grants_invite.py b/tests/integration/test_grants_invite.py index 420affee751..148c35b3836 100644 --- a/tests/integration/test_grants_invite.py +++ b/tests/integration/test_grants_invite.py @@ -49,24 +49,24 @@ def test_an_invited_email_is_accepted_once_under_the_accepters_handle( control_plane_url, admin, "grants.invite", - {"org": org, "namespace": ns, "to": "michael@example.com", "role": "writer"}, + {"org": org, "namespace": ns, "to": "robin@example.com", "role": "writer"}, ) assert r.status_code == 200, r.text made = r.json() assert made["outcome"] == "invited" secret = parse_qs(urlsplit(made["link_path"]).fragment)["invite"][0] listed = _post(control_plane_url, admin, "grants.list_invites", {"org": org, "namespace": ns}) - assert [row["email"] for row in listed.json()["rows"]] == ["michael@example.com"] + assert [row["email"] for row in listed.json()["rows"]] == ["robin@example.com"] # The person signs in under a handle that is not the email. - person = _person_token(org=org, subject="mlex", namespaces=[f"home-{ns}"], roles=["viewer"]) + person = _person_token(org=org, subject="robin", namespaces=[f"home-{ns}"], roles=["viewer"]) body = {"org": org, "namespace": ns, "secret": secret} r = _post(control_plane_url, person, "grants.accept_invite", body) assert r.status_code == 200, r.text assert r.json() == {"namespace": ns, "role": "writer"} grants = _post(control_plane_url, admin, "grants.list", {"org": org, "namespace": ns}) - mine = [g for g in grants.json()["rows"] if g["subject"] == "mlex"] + mine = [g for g in grants.json()["rows"] if g["subject"] == "robin"] assert [(g["role"], g["granted_by"]) for g in mine] == [("writer", "ann-admin")] # Spent: a second open of the link admits nobody, and it is no longer listed. @@ -97,20 +97,20 @@ def test_a_handle_an_account_signs_in_as_is_granted_at_once(control_plane_url: s org = unique_org("invite") ns = f"ns-{uuid.uuid4().hex[:8]}" home = f"home-{ns}" - person = _person_token(org=org, subject="mlex", namespaces=[home], roles=["admin"]) - _register(control_plane_url, person, org, home, "mlex") + person = _person_token(org=org, subject="robin", namespaces=[home], roles=["admin"]) + _register(control_plane_url, person, org, home, "robin") admin = _person_token(org=org, subject="ann-admin", namespaces=[ns], roles=["admin"]) _register(control_plane_url, admin, org, ns, "ann-admin") r = _post( control_plane_url, admin, "grants.invite", - {"org": org, "namespace": ns, "to": "MLex", "role": "viewer"}, + {"org": org, "namespace": ns, "to": "Robin", "role": "viewer"}, ) assert r.status_code == 200, r.text assert (r.json()["outcome"], r.json()["subject"], r.json()["link_path"]) == ( "granted", - "mlex", + "robin", "", ) @@ -153,14 +153,14 @@ def test_a_cancelled_link_is_unlisted_and_admits_nobody(control_plane_url: str) ns = f"ns-{uuid.uuid4().hex[:8]}" admin = _person_token(org=org, subject="ann-admin", namespaces=[ns], roles=["admin"]) _register(control_plane_url, admin, org, ns, "ann-admin") - invite_id, secret = _invite(control_plane_url, admin, org, ns, "michael@example.com") + invite_id, secret = _invite(control_plane_url, admin, org, ns, "robin@example.com") body = {"org": org, "namespace": ns, "invite_id": invite_id} r = _post(control_plane_url, admin, "grants.cancel_invite", body) assert (r.status_code, r.json()) == (200, {"cancelled": True}), r.text listed = _post(control_plane_url, admin, "grants.list_invites", {"org": org, "namespace": ns}) assert listed.json()["rows"] == [] - person = _person_token(org=org, subject="mlex", namespaces=[f"home-{ns}"], roles=["viewer"]) + person = _person_token(org=org, subject="robin", namespaces=[f"home-{ns}"], roles=["viewer"]) accept = {"org": org, "namespace": ns, "secret": secret} assert _post(control_plane_url, person, "grants.accept_invite", accept).status_code == 404 @@ -170,7 +170,7 @@ def test_a_link_stops_when_its_maker_loses_admin(control_plane_url: str) -> None ns = f"ns-{uuid.uuid4().hex[:8]}" ann = _person_token(org=org, subject="ann-admin", namespaces=[ns], roles=["admin"]) _register(control_plane_url, ann, org, ns, "ann-admin") # ann's admin is her own grant - _, secret = _invite(control_plane_url, ann, org, ns, "michael@example.com") + _, secret = _invite(control_plane_url, ann, org, ns, "robin@example.com") # Another admin stays, so ann's grant can go. grant = {"org": org, "namespace": ns, "subject": "bea-admin", "role": "admin"} @@ -180,7 +180,7 @@ def test_a_link_stops_when_its_maker_loses_admin(control_plane_url: str) -> None r = _post(control_plane_url, bea, "grants.revoke", revoke) assert r.status_code == 200 and r.json()["revoked"] is True, r.text - person = _person_token(org=org, subject="mlex", namespaces=[f"home-{ns}"], roles=["viewer"]) + person = _person_token(org=org, subject="robin", namespaces=[f"home-{ns}"], roles=["viewer"]) accept = {"org": org, "namespace": ns, "secret": secret} r = _post(control_plane_url, person, "grants.accept_invite", accept) assert r.status_code == 404, r.text diff --git a/tests/unit/test_audit_subject_credentials.py b/tests/unit/test_audit_subject_credentials.py index e1376f31b72..cc60a3e25d1 100644 --- a/tests/unit/test_audit_subject_credentials.py +++ b/tests/unit/test_audit_subject_credentials.py @@ -150,13 +150,13 @@ def test_grants_invite_audits_who_got_the_role_never_the_address() -> None: from server.identity.api.models_grants import GrantsInviteInput asked = GrantsInviteInput(org="acme", namespace="team", to="m@example.com", role="writer") - granted = {"outcome": "granted", "role": "writer", "subject": "mlex"} + granted = {"outcome": "granted", "role": "writer", "subject": "robin"} assert _subject("grants.invite", asked, granted) == { "org": "acme", "namespace": "team", "role": "writer", "outcome": "granted", - "subject": "mlex", + "subject": "robin", } invited = {"outcome": "invited", "role": "writer", "subject": "", "invite_id": "h"} subject = _subject("grants.invite", asked, invited) diff --git a/tests/unit/test_grants_invite.py b/tests/unit/test_grants_invite.py index 1c0f0e3f8ae..f90e2ef8d32 100644 --- a/tests/unit/test_grants_invite.py +++ b/tests/unit/test_grants_invite.py @@ -51,7 +51,7 @@ def __init__(self) -> None: self.invites: dict[str, domain.Invite] = {} self.writes: list[domain.Invite] = [] # Rows' owners: an account's handle, or whatever `namespace.register` was given. - self.accounts = {"mlex", "platform@acme.example"} + self.accounts = {"robin", "platform@acme.example"} # Handles a live grant in the org is stored under, as stored. self.granted = {"Carol", "bob@example.com"} self.verified = {"sso@example.com": "sso-handle"} @@ -221,9 +221,9 @@ async def accept(secret: str) -> Any: @pytest.mark.asyncio async def test_a_handle_an_account_signs_in_as_is_granted_at_once(world: World) -> None: - out = await invite("MLex") - assert (out.outcome, out.subject, out.link_path) == ("granted", "mlex", "") - assert [(g.subject, g.role) for g, _ in world.grants] == [("mlex", "writer")] + out = await invite("Robin") + assert (out.outcome, out.subject, out.link_path) == ("granted", "robin", "") + assert [(g.subject, g.role) for g, _ in world.grants] == [("robin", "writer")] assert world.invites == {} @@ -257,8 +257,8 @@ async def test_a_verified_email_is_granted_under_its_handle(world: World) -> Non @pytest.mark.asyncio async def test_a_handle_no_account_holds_is_refused_and_writes_nothing(world: World) -> None: - with pytest.raises(NotFoundError, match="no account in o signs in as 'mlexx'"): - await invite("mlexx") + with pytest.raises(NotFoundError, match="no account in o signs in as 'robinn'"): + await invite("robinn") assert world.grants == [] and world.invites == {} @@ -312,34 +312,34 @@ async def test_a_request_with_no_token_grants_a_person_as_typed(world: World) -> async def test_a_mail_limit_that_cannot_be_read_leaves_no_link_listed(world: World) -> None: world.mail_error = BackendUnavailableError("down") with pytest.raises(BackendUnavailableError): - await invite("michael@example.com") + await invite("robin@example.com") assert world.writes == [] @pytest.mark.asyncio async def test_an_email_no_account_holds_gets_a_link_kept_only_as_its_hash(world: World) -> None: - out = await invite("Michael@Example.com") + out = await invite("Robin@Example.com") assert out.outcome == "invited" and out.emailed is True secret = secret_of(out.link_path) stored = world.invites[out.invite_id] assert out.invite_id == domain.invite_id(secret) != secret assert secret not in repr(stored) assert (stored.email, stored.role, stored.created_by, stored.state) == ( - "michael@example.com", + "robin@example.com", "writer", "admin-ann", "open", ) assert stored.expires_at - time.time() == pytest.approx(settings.invite_ttl_seconds, abs=5) - assert world.mail[0]["to"] == "michael@example.com" + assert world.mail[0]["to"] == "robin@example.com" listed = await mod.handle_grants_list_invites(GrantsListInvitesInput(org="o", namespace="ns")) - assert [r.email for r in listed.rows] == ["michael@example.com"] + assert [r.email for r in listed.rows] == ["robin@example.com"] @pytest.mark.asyncio async def test_past_the_mail_limits_the_link_is_still_made_and_not_emailed(world: World) -> None: world.may_mail = False - out = await invite("michael@example.com") + out = await invite("robin@example.com") assert (out.outcome, out.emailed, world.mail) == ("invited", False, []) assert out.invite_id in world.invites @@ -381,14 +381,14 @@ async def test_mail_stops_at_twenty_an_hour_per_inviter_and_three_a_day_per_addr @pytest.mark.asyncio async def test_the_link_lets_one_person_in_once_as_granted_by_its_maker(world: World) -> None: - secret = secret_of((await invite("michael@example.com")).link_path) - signed_in("mlex") + secret = secret_of((await invite("robin@example.com")).link_path) + signed_in("robin") out = await accept(secret) assert (out.namespace, out.role) == ("ns", "writer") assert [(g.subject, g.role, issuer) for g, issuer in world.grants] == [ - ("mlex", "writer", "admin-ann") + ("robin", "writer", "admin-ann") ] - assert world.invites[domain.invite_id(secret)].accepted_by == "mlex" + assert world.invites[domain.invite_id(secret)].accepted_by == "robin" signed_in("someone-else") with pytest.raises(NotFoundError, match="used, cancelled or expired"): await accept(secret) @@ -397,18 +397,18 @@ async def test_the_link_lets_one_person_in_once_as_granted_by_its_maker(world: W @pytest.mark.asyncio async def test_a_higher_role_held_already_stands(world: World) -> None: - secret = secret_of((await invite("michael@example.com", "viewer")).link_path) + secret = secret_of((await invite("robin@example.com", "viewer")).link_path) world.grant_error = GrantWouldDowngradeError(current_role="admin", requested_role="viewer") - signed_in("mlex") + signed_in("robin") assert (await accept(secret)).role == "admin" assert world.invites[domain.invite_id(secret)].state == "accepted" @pytest.mark.asyncio async def test_a_failed_grant_leaves_the_link_open(world: World) -> None: - secret = secret_of((await invite("michael@example.com")).link_path) + secret = secret_of((await invite("robin@example.com")).link_path) world.grant_error = BackendUnavailableError("down") - signed_in("mlex") + signed_in("robin") with pytest.raises(BackendUnavailableError): await accept(secret) iid = domain.invite_id(secret) @@ -419,9 +419,9 @@ async def test_a_failed_grant_leaves_the_link_open(world: World) -> None: @pytest.mark.asyncio async def test_a_lost_reply_to_the_spend_leaves_the_link_open(world: World) -> None: - secret = secret_of((await invite("michael@example.com")).link_path) + secret = secret_of((await invite("robin@example.com")).link_path) world.put_error = BackendUnavailableError("lost reply") - signed_in("mlex") + signed_in("robin") with pytest.raises(BackendUnavailableError): await accept(secret) iid = domain.invite_id(secret) @@ -433,8 +433,8 @@ async def test_a_lost_reply_to_the_spend_leaves_the_link_open(world: World) -> N async def test_a_cancelled_accept_leaves_the_link_open(world: World) -> None: """anyio raises a cancellation again at every await of its scope: the reopen still runs to its end.""" - secret = secret_of((await invite("michael@example.com")).link_path) - signed_in("mlex") + secret = secret_of((await invite("robin@example.com")).link_path) + signed_in("robin") with anyio.CancelScope() as scope: world.cancel = scope await accept(secret) @@ -446,9 +446,9 @@ async def test_a_cancelled_accept_leaves_the_link_open(world: World) -> None: @pytest.mark.asyncio async def test_a_failure_after_the_grant_landed_leaves_the_link_used(world: World) -> None: - secret = secret_of((await invite("michael@example.com")).link_path) + secret = secret_of((await invite("robin@example.com")).link_path) world.grant_error, world.grant_lands = BackendUnavailableError("lost reply"), True - signed_in("mlex") + signed_in("robin") with pytest.raises(BackendUnavailableError): await accept(secret) iid = domain.invite_id(secret) @@ -457,14 +457,14 @@ async def test_a_failure_after_the_grant_landed_leaves_the_link_used(world: Worl signed_in("someone-else") with pytest.raises(NotFoundError): await accept(secret) - assert [g.subject for g, _ in world.grants] == ["mlex"] + assert [g.subject for g, _ in world.grants] == ["robin"] @pytest.mark.asyncio async def test_an_invitation_never_outlasts_its_makers_admin(world: World) -> None: - secret = secret_of((await invite("michael@example.com")).link_path) + secret = secret_of((await invite("robin@example.com")).link_path) world.maker_roles["admin-ann"] = Role.WRITER # lowered, or None when revoked - signed_in("mlex") + signed_in("robin") with pytest.raises(NotFoundError, match="no longer administers"): await accept(secret) assert world.invites[domain.invite_id(secret)].state == "open" @@ -477,18 +477,18 @@ async def test_an_admin_only_a_token_makes_makes_no_link(world: World) -> None: from a revoked one.""" world.maker_roles = {} with pytest.raises(ValidationError, match="'admin-ann' holds none there"): - await invite("michael@example.com") + await invite("robin@example.com") assert world.invites == {} and world.mail_asked == [] @pytest.mark.asyncio async def test_a_delegated_tokens_link_stands_on_its_creators_admin(world: World) -> None: signed_in("sa:helper-1a2b", service=True, creator="admin-ann") - out = await invite("michael@example.com") + out = await invite("robin@example.com") assert world.invites[out.invite_id].created_by == "admin-ann" - assert world.mail_asked == [("o", "admin-ann", "michael@example.com")] + assert world.mail_asked == [("o", "admin-ann", "robin@example.com")] world.maker_roles["admin-ann"] = None # the creator's admin revoked - signed_in("mlex") + signed_in("robin") with pytest.raises(NotFoundError, match="no longer administers"): await accept(secret_of(out.link_path)) assert world.grants == [] @@ -498,14 +498,14 @@ async def test_a_delegated_tokens_link_stands_on_its_creators_admin(world: World async def test_a_failed_read_of_the_makers_grants_refuses( world: World, monkeypatch: pytest.MonkeyPatch ) -> None: - secret = secret_of((await invite("michael@example.com")).link_path) + secret = secret_of((await invite("robin@example.com")).link_path) async def unreadable(*_a: Any) -> Role | None: fail_closed.note_unreadable() return None monkeypatch.setattr(mod, "subject_grant_role", unreadable) - signed_in("mlex") + signed_in("robin") with pytest.raises(BackendUnavailableError, match="could not be read"): await accept(secret) # a 503: the dashboard keeps the link assert world.invites[domain.invite_id(secret)].state == "open" @@ -519,9 +519,9 @@ async def unreadable(*_a: Any) -> Role | None: @pytest.mark.asyncio async def test_a_link_stops_with_its_makers_account(world: World, ended: str) -> None: """As a token delegated by the maker stops: a disabled account, or a revoked subject.""" - secret = secret_of((await invite("michael@example.com")).link_path) + secret = secret_of((await invite("robin@example.com")).link_path) getattr(world, ended).add("admin-ann") - signed_in("mlex") + signed_in("robin") with pytest.raises(NotFoundError, match="no longer administers"): await accept(secret) assert world.grants == [] and world.invites[domain.invite_id(secret)].state == "open" @@ -531,7 +531,7 @@ async def test_a_link_stops_with_its_makers_account(world: World, ended: str) -> @pytest.mark.asyncio async def test_a_link_whose_maker_no_longer_stands_is_not_listed(world: World, ended: str) -> None: """It admits nobody, so the members dialog does not show it as open.""" - await invite("michael@example.com") + await invite("robin@example.com") scope = GrantsListInvitesInput(org="o", namespace="ns") assert len((await mod.handle_grants_list_invites(scope)).rows) == 1 if ended == "lowered": @@ -541,23 +541,38 @@ async def test_a_link_whose_maker_no_longer_stands_is_not_listed(world: World, e assert (await mod.handle_grants_list_invites(scope)).rows == [] +@pytest.mark.asyncio +async def test_an_end_users_links_stop_with_their_revocation(world: World) -> None: + """An end user's tokens are revoked under `/user:`, and so are their links.""" + world.maker_roles["user:42"] = Role.ADMIN + signed_in("user:42") + secret = secret_of((await invite("robin@example.com")).link_path) + world.revoked.add("o/user:42") + listed = await mod.handle_grants_list_invites(GrantsListInvitesInput(org="o", namespace="ns")) + assert listed.rows == [] + signed_in("robin") + with pytest.raises(NotFoundError, match="no longer administers"): + await accept(secret) + assert world.grants == [] + + @pytest.mark.asyncio async def test_a_failed_read_earlier_in_the_request_does_not_refuse_the_maker( world: World, ) -> None: fail_closed.note_unreadable() # a read the gate made and survived - assert (await invite("michael@example.com")).outcome == "invited" + assert (await invite("robin@example.com")).outcome == "invited" @pytest.mark.asyncio async def test_a_role_this_build_does_not_know_is_unlisted_and_admits_nobody( world: World, ) -> None: - out = await invite("michael@example.com") + out = await invite("robin@example.com") world.invites[out.invite_id] = replace(world.invites[out.invite_id], role="owner") listed = await mod.handle_grants_list_invites(GrantsListInvitesInput(org="o", namespace="ns")) assert listed.rows == [] - signed_in("mlex") + signed_in("robin") with pytest.raises(NotFoundError): await accept(secret_of(out.link_path)) assert world.grants == [] @@ -567,7 +582,7 @@ async def test_a_role_this_build_does_not_know_is_unlisted_and_admits_nobody( async def test_an_erased_makers_links_close_and_lose_their_name(world: World) -> None: opened = await invite("a@example.com") used = await invite("b@example.com") - signed_in("mlex") + signed_in("robin") await accept(secret_of(used.link_path)) assert await mod.forget_maker("o", "admin-ann") == 2 assert [(i.state, i.created_by) for i in world.invites.values()] == [ @@ -582,7 +597,7 @@ async def test_an_erased_makers_links_close_and_lose_their_name(world: World) -> async def test_an_inactive_namespace_gets_no_invitation(world: World) -> None: world.active = False with pytest.raises(NotFoundError, match="not an active namespace"): - await invite("michael@example.com") + await invite("robin@example.com") assert world.invites == {} @@ -631,7 +646,7 @@ async def test_an_expired_or_cancelled_link_admits_nobody(world: World) -> None: GrantsCancelInviteInput(org="o", namespace="ns", invite_id=cancelled) ) assert again.cancelled is False - signed_in("mlex") + signed_in("robin") with pytest.raises(NotFoundError): await accept(expired) with pytest.raises(NotFoundError): @@ -644,14 +659,14 @@ async def test_an_expired_or_cancelled_link_admits_nobody(world: World) -> None: [ ("sa:bot", "o", True, "a person"), ("group:eng", "o", False, "a person"), - ("mlex", "other", False, "sign in to o"), + ("robin", "other", False, "sign in to o"), ], ) @pytest.mark.asyncio async def test_only_a_person_of_the_org_accepts( world: World, subject: str, org: str, service: bool, words: str ) -> None: - secret = secret_of((await invite("michael@example.com")).link_path) + secret = secret_of((await invite("robin@example.com")).link_path) signed_in(subject, org=org, service=service) with pytest.raises(ValidationError, match=words): await accept(secret) @@ -674,6 +689,18 @@ async def test_no_mail_settings_send_nothing(monkeypatch: pytest.MonkeyPatch) -> assert await invite_mail.send_invite("m@example.com\nBcc: x@y.z", **args) is False +def test_a_mail_server_url_of_another_scheme_is_refused_at_load() -> None: + from pydantic import ValidationError + + from server.settings import Settings + + for url in ("", "smtp://mail.example.com", "smtps://u:p@mail.example.com:465"): + assert Settings(_env_file=None, smtp_url=url).smtp_url == url # type: ignore[call-arg] + for url in ("smtp+starttls://mail.example.com", "mail://x", "smtp://"): + with pytest.raises(ValidationError, match="smtp_url"): + Settings(_env_file=None, smtp_url=url) # type: ignore[call-arg] + + class _SMTP: """smtplib's client as `_send` drives it, recording what it was asked.""" @@ -780,7 +807,7 @@ async def test_a_grant_written_under_the_accepters_handle_keeps_the_link_used( world: World, ) -> None: """The accepter signs in as a verified email; the grant lands under its handle.""" - secret = secret_of((await invite("michael@example.com")).link_path) + secret = secret_of((await invite("robin@example.com")).link_path) world.grant_error, world.grant_lands = BackendUnavailableError("lost reply"), True signed_in("sso@example.com") with pytest.raises(BackendUnavailableError): @@ -793,14 +820,14 @@ async def test_a_grant_written_under_the_accepters_handle_keeps_the_link_used( async def test_a_link_its_maker_was_erased_from_during_a_failed_grant_stays_closed( world: World, monkeypatch: pytest.MonkeyPatch ) -> None: - secret = secret_of((await invite("michael@example.com")).link_path) + secret = secret_of((await invite("robin@example.com")).link_path) async def erased_meanwhile(*_a: Any, **_k: Any) -> None: await mod.forget_maker("o", "admin-ann") raise BackendUnavailableError("down") monkeypatch.setattr(mod, "create_grant", erased_meanwhile) - signed_in("mlex") + signed_in("robin") with pytest.raises(BackendUnavailableError): await accept(secret) stored = world.invites[domain.invite_id(secret)] @@ -809,23 +836,20 @@ async def erased_meanwhile(*_a: Any, **_k: Any) -> None: @pytest.mark.asyncio async def test_a_users_erasure_takes_them_off_their_invitations( - monkeypatch: pytest.MonkeyPatch, + world: World, monkeypatch: pytest.MonkeyPatch ) -> None: from server.erasure.app import saga_steps from server.identity.app import grants - forgotten: list[tuple[str, str]] = [] - async def _zero(*_a: Any, **_k: Any) -> int: return 0 - async def _forget(org: str, maker: str) -> int: - forgotten.append((org, maker)) - return 0 - monkeypatch.setattr(grants, "revoke_subject", _zero) monkeypatch.setattr(grants, "forget_granter", _zero) - monkeypatch.setattr(mod, "forget_maker", _forget) monkeypatch.setattr(saga_steps.principal_steps, "delete_grant_rows_of_user", _zero) + world.maker_roles["user:42"] = Role.ADMIN + signed_in("user:42") + made = await invite("robin@example.com") await saga_steps._step_revoke_grants_by_user("o", "42") - assert forgotten == [("o", "user:42")] + left = world.invites[made.invite_id] + assert (left.state, left.created_by) == ("cancelled", "") diff --git a/tests/unit/test_invites_store_sql.py b/tests/unit/test_invites_store_sql.py index 617ffb83de1..4e68073a0d5 100644 --- a/tests/unit/test_invites_store_sql.py +++ b/tests/unit/test_invites_store_sql.py @@ -68,7 +68,7 @@ async def test_a_held_handle_comes_back_as_stored(tmp_path: Path) -> None: ddl("namespaces"), ddl("namespace_grants"), "INSERT INTO loom.namespaces (org, namespace, owner_email, active, created_at," - " updated_at) VALUES ('acme', 'mlex', 'MLex', 1, now(), now())," + " updated_at) VALUES ('acme', 'robin', 'Robin', 1, now(), now())," " ('acme', 'gone', 'Gone', 0, now(), now())", "INSERT INTO loom.namespace_grants (org, namespace, subject, role, status, granted_by," " version) VALUES ('acme', 'team', 'Carol', 'writer', 'active', 'op', 1)," @@ -77,9 +77,9 @@ async def test_a_held_handle_comes_back_as_stored(tmp_path: Path) -> None: " revoked_at, version) VALUES ('acme', 'team', 'eve', 'writer', 'active', 'op'," " now(), 1)", ) - assert await namespaces_repo.account_handle("acme", "mlex", ch=ch) == "MLex" # type: ignore[arg-type] + assert await namespaces_repo.account_handle("acme", "robin", ch=ch) == "Robin" # type: ignore[arg-type] assert await namespaces_repo.account_handle("acme", "gone", ch=ch) is None # type: ignore[arg-type] - assert await namespaces_repo.account_handle("other", "mlex", ch=ch) is None # type: ignore[arg-type] + assert await namespaces_repo.account_handle("other", "robin", ch=ch) is None # type: ignore[arg-type] assert await grants_repo.granted_spelling("acme", "carol", ch=ch) == "Carol" # type: ignore[arg-type] assert await grants_repo.granted_spelling("acme", "dan", ch=ch) is None # type: ignore[arg-type] assert await grants_repo.granted_spelling("acme", "eve", ch=ch) is None # type: ignore[arg-type] diff --git a/tests/unit/test_settings_env_contract.py b/tests/unit/test_settings_env_contract.py index a0d5e4d6d57..28347795c0a 100644 --- a/tests/unit/test_settings_env_contract.py +++ b/tests/unit/test_settings_env_contract.py @@ -103,6 +103,7 @@ def _bounded(f: FieldInfo, value: float) -> bool: "cell_router_token": "lcr_" + "0" * 128, "router_operator_sha256": "0" * 64, "router_operator_token": "lco_" + "0" * 128, + "smtp_url": "smtps://mail.example:465", # The four other code_git_proxy_* settings load only beside it, and the bundle for # the proxy's own certificate only beside an https one. "code_git_proxy_url": "https://proxy.example:8443", From 62c596f377586b109c59548ec6ba7ce64c8e3817 Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Sat, 5 Dec 2026 08:54:28 +0530 Subject: [PATCH 25/28] Close a link a cancel meets mid-accept, and test the accept's own guards A cancel also closes a link an accept is spending, so a grant that then fails does not reopen it after the admin cancelled it; the answer still says whether it was open. Tests cover two people opening one link at once under the real claim, an accept on a namespace retired since, and a service account's token with an unprefixed subject. The sign-in gate no longer stashes a link before single sign-on: a server that signs in that way makes no link. The docs say a handle a live grant holds is granted, and name the erasure's race with an accept in flight. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Lareb Zafar --- docs/architecture/sharing.md | 9 ++-- docs/features/dashboard.md | 6 +-- docs/features/namespaces-and-sharing.md | 30 ++++++------ docs/guides/tokens-and-grants.md | 18 ++++---- frontend/src/flows/TokenGate.test.tsx | 15 ------ frontend/src/flows/TokenGate.tsx | 3 -- frontend/src/lib/inviteLink.ts | 5 +- server/identity/app/invites.py | 10 ++-- server/transport/mcp_descriptions.py | 2 +- tests/unit/test_grants_invite.py | 61 ++++++++++++++++++++++++- 10 files changed, 103 insertions(+), 56 deletions(-) diff --git a/docs/architecture/sharing.md b/docs/architecture/sharing.md index 1d6ecb7d13d..946f869543d 100644 --- a/docs/architecture/sharing.md +++ b/docs/architecture/sharing.md @@ -262,8 +262,8 @@ namespace of another org is accepted by an account an operator made there. A password account's email is never verified, which is why an email reaches one only through an invitation: the link went to that address, and opening it proves the reader got it. The whole link is a fragment, which a browser never sends to a server or puts in a -Referer. The dashboard moves it into the tab's session storage when a single sign-on starts -and when Namespaces in your org shows it, so a single sign-on round trip keeps it. +Referer. Namespaces in your org moves it out of the address into the tab's session +storage, where it waits until the person accepts it or closes the card. ## Consistency @@ -357,7 +357,10 @@ id as the issuer of the grants they gave others (those grants stay) and as the m their invitations, closing the open ones, removes them from every group, blanks their id as the creator of the collections they made (the collections stay), and retires their personal collection's directory row (`namespace.delete` and `collection.delete` refuse a -personal collection: it goes only with its user's erasure). The request ledger keeps the +personal collection: it goes only with its user's erasure). An accept or an invitation +already past its maker check as that step runs can still write their id, as a grant's +issuer or an invitation's maker, as a `grants.create` in flight can; such a link admits +nobody, since the step revokes the user's grants first. The request ledger keeps the user's calls for cost with their `user:` subject scrubbed, and the user's newest-call row is deleted. Deleting a SCIM group revokes the grants that named it, so a group made later under the same id starts with none. Collections that hold other writers' documents diff --git a/docs/features/dashboard.md b/docs/features/dashboard.md index aac189c760d..fefe98cb3f0 100644 --- a/docs/features/dashboard.md +++ b/docs/features/dashboard.md @@ -122,9 +122,9 @@ repository's or collection's name points to Repositories or the Library instead. on a namespace you manage opens its members on the add field. The field takes a person's login handle, which their account menu shows under **Signed in as**, an email, or a service account `sa:`. A collection's **Share** also takes a group `group:`, an -agent `agent:` or `everyone`. A login handle no account holds is refused. An email is -granted at once only when it is verified for an account; any other email gets an -[invitation](namespaces-and-sharing.md#membership-and-grants). The add +agent `agent:` or `everyone`. A login handle no account or live grant holds is +refused. An email is granted at once only when it is verified for an account; any other +email gets an [invitation](namespaces-and-sharing.md#membership-and-grants). The add shows its link to copy, and the server emails it when it sends mail. The members dialog and a repository's Access tab list it under **Invited**, with who made it and **Cancel**, until it is accepted. Where sign-in is single sign-on only, the email is granted instead diff --git a/docs/features/namespaces-and-sharing.md b/docs/features/namespaces-and-sharing.md index 14362bfd727..f8a4c8116e1 100644 --- a/docs/features/namespaces-and-sharing.md +++ b/docs/features/namespaces-and-sharing.md @@ -71,21 +71,21 @@ account, or a service account `sa:`) a role on one namespace: `viewer` rea `writer` writes, `admin` manages grants and settings. The token carries the org and the namespaces it may reach; the grant table decides the role. -| Operation | Role | Does | -| -------------------------------------------------------------------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `grants.create` | admin | Grant a role. A create below the subject's current role is refused with 409 `GRANT_WOULD_DOWNGRADE` unless `replace=true`. | -| `grants.invite` | admin | Give a person a role by login handle or email. An account's handle, or an email verified for one, is granted at once; any other email gets a single-use invitation link, emailed when the server has mail settings, or, where sign-in is single sign-on only, a grant that reaches that person at their first sign-in. A handle no account holds is refused. | -| `grants.list_invites`, `grants.cancel_invite` | admin | The open invitations, and withdraw one. | -| `grants.accept_invite` | a signed-in person | Accept an invitation link: its role goes to the account the caller signs in as. | -| `grants.list` | viewer | Who has access, at which role, and any `pending_role`. | -| `grants.revoke` | admin | Remove a grant. | -| `grants.approve` | admin | Approve or reject a pending request, optionally with a different role. | -| `grants.pending_for_me` | viewer | Every pending request in the namespaces the caller administers, org-wide. | -| `namespace.browse` | viewer | Public namespaces in the org, never a collection (`closed` ones only with `include_closed`). | -| `namespace.join` | viewer | Self-join a public namespace. `viewer` is granted at once; a `writer` or `admin` request always lands pending, with no access until an admin approves. | -| `namespace.leave`, `namespace.cancel_request`, `namespace.mark_seen` | viewer | Drop one's own grant, withdraw a pending request, record a visit (clears the namespace's new mark). | -| `namespace.list_mine` | viewer | The namespaces the caller belongs to, each with its `kind` (`collection` for a collection) and `title`. | -| `namespace.list` | org admin | Every namespace in the org. | +| Operation | Role | Does | +| -------------------------------------------------------------------- | ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `grants.create` | admin | Grant a role. A create below the subject's current role is refused with 409 `GRANT_WOULD_DOWNGRADE` unless `replace=true`. | +| `grants.invite` | admin | Give a person a role by login handle or email. An account's handle, or an email verified for one, is granted at once; any other email gets a single-use invitation link, emailed when the server has mail settings, or, where sign-in is single sign-on only, a grant that reaches that person at their first sign-in. A handle no account or live grant holds is refused. | +| `grants.list_invites`, `grants.cancel_invite` | admin | The open invitations, and withdraw one. | +| `grants.accept_invite` | a signed-in person | Accept an invitation link: its role goes to the account the caller signs in as. | +| `grants.list` | viewer | Who has access, at which role, and any `pending_role`. | +| `grants.revoke` | admin | Remove a grant. | +| `grants.approve` | admin | Approve or reject a pending request, optionally with a different role. | +| `grants.pending_for_me` | viewer | Every pending request in the namespaces the caller administers, org-wide. | +| `namespace.browse` | viewer | Public namespaces in the org, never a collection (`closed` ones only with `include_closed`). | +| `namespace.join` | viewer | Self-join a public namespace. `viewer` is granted at once; a `writer` or `admin` request always lands pending, with no access until an admin approves. | +| `namespace.leave`, `namespace.cancel_request`, `namespace.mark_seen` | viewer | Drop one's own grant, withdraw a pending request, record a visit (clears the namespace's new mark). | +| `namespace.list_mine` | viewer | The namespaces the caller belongs to, each with its `kind` (`collection` for a collection) and `title`. | +| `namespace.list` | org admin | Every namespace in the org. | A password account's email is never verified, so a grant by email reaches such an account only through an invitation. The link is `/spaces#invite=…` on the dashboard, works diff --git a/docs/guides/tokens-and-grants.md b/docs/guides/tokens-and-grants.md index 6ba67281428..61ebc6758ea 100644 --- a/docs/guides/tokens-and-grants.md +++ b/docs/guides/tokens-and-grants.md @@ -225,15 +225,15 @@ answer to the user (the entity graph, conversation reads, exports, admin ops) is namespace above what the token carries. Grants add; where the subject holds one, a token's claim goes no further than it. -| Op | Role | Does | -| ----------------------- | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `grants.create` | admin | Give `subject` a `role`. Below the subject's current role it answers 409 `GRANT_WOULD_DOWNGRADE` unless `replace: true`. | -| `grants.invite` | admin | Give a person a `role` by login handle or email: an account's handle or verified email is granted at once, any other email gets a single-use invitation link. A handle no account holds is refused (404). | -| `grants.accept_invite` | a signed-in person | Accept an invitation link; its role goes to the account the caller signs in as. | -| `grants.revoke` | admin | Remove it; on a restricted namespace the grants of tokens the subject minted there go too. | -| `grants.list` | viewer | The namespace's grants. | -| `grants.approve` | admin | Activate a pending join request. Below the subject's current grant it answers 409: an approval never asks to lower one. | -| `grants.pending_for_me` | viewer | Requests waiting on the caller's approval. | +| Op | Role | Does | +| ----------------------- | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `grants.create` | admin | Give `subject` a `role`. Below the subject's current role it answers 409 `GRANT_WOULD_DOWNGRADE` unless `replace: true`. | +| `grants.invite` | admin | Give a person a `role` by login handle or email: an account's handle or verified email is granted at once, any other email gets a single-use invitation link. A handle no account or live grant holds is refused (404). | +| `grants.accept_invite` | a signed-in person | Accept an invitation link; its role goes to the account the caller signs in as. | +| `grants.revoke` | admin | Remove it; on a restricted namespace the grants of tokens the subject minted there go too. | +| `grants.list` | viewer | The namespace's grants. | +| `grants.approve` | admin | Activate a pending join request. Below the subject's current grant it answers 409: an approval never asks to lower one. | +| `grants.pending_for_me` | viewer | Requests waiting on the caller's approval. | ```bash curl -s "$LOOM_BASE_URL/v1/grants.create" -H "Authorization: Bearer $ADMIN_TOKEN" \ diff --git a/frontend/src/flows/TokenGate.test.tsx b/frontend/src/flows/TokenGate.test.tsx index a6874e8c21d..e707bd2a327 100644 --- a/frontend/src/flows/TokenGate.test.tsx +++ b/frontend/src/flows/TokenGate.test.tsx @@ -2,7 +2,6 @@ import { fireEvent, render, screen } from "../test/rtl"; import userEvent from "@testing-library/user-event"; import { afterEach, describe, expect, it, vi } from "vitest"; import { SIGN_IN_FROM, SIGN_IN_PENDING } from "../lib/boot"; -import { INVITE_LINK } from "../lib/inviteLink"; import { ApiError } from "../lib/errors"; import { axeViolations } from "../test/axe"; import { LinkTokenConfirm, TokenGate, resumeSsoOnce } from "./TokenGate"; @@ -193,20 +192,6 @@ describe("TokenGate", () => { history.replaceState(null, "", "/"); }); - it("keeps an invitation link through the identity provider's round trip", () => { - window.__LOOM_SSO = true; - history.replaceState(null, "", "/spaces#invite=s3cret&org=acme&namespace=team"); - render( undefined} reason="expired" />); - expect(goToSso).toHaveBeenCalledTimes(1); - expect(JSON.parse(sessionStorage.getItem(INVITE_LINK) ?? "{}")).toEqual({ - secret: "s3cret", - org: "acme", - namespace: "team", - }); - expect(window.location.hash).toBe(""); - history.replaceState(null, "", "/"); - }); - it("says a sign-in link's token was refused, and waits for a click", () => { window.__LOOM_SSO = true; render( undefined} reason="refused" />); diff --git a/frontend/src/flows/TokenGate.tsx b/frontend/src/flows/TokenGate.tsx index 9383dc81023..c53fa039d71 100644 --- a/frontend/src/flows/TokenGate.tsx +++ b/frontend/src/flows/TokenGate.tsx @@ -9,7 +9,6 @@ import { Panel } from "../components/ui/Panel"; import { TabTrigger } from "../components/ui/TabTrigger"; import { selfSignup, setToken, loginWithPassword } from "../api"; import { SIGN_IN_FROM, markSignInStarted, type TokenClaims } from "../lib/boot"; -import { takeInviteLink } from "../lib/inviteLink"; import { goToSso } from "../lib/navigation"; import { errorRequestId } from "../lib/format"; import { humanizeError } from "../lib/errorWords"; @@ -51,8 +50,6 @@ export function TokenGate({ onLogin, reason = null, ssoAsked = false }: TokenGat * landing (`/me`, where a restart begins) the page saved by the first start stays. */ function rememberSignInStart(): string { const nonce = markSignInStarted(); - // The identity provider's round trip drops the fragment, and an invitation link with it. - takeInviteLink(); const path = window.location.pathname + window.location.search; try { // A restart from the landing keeps the page the sign-in started on. diff --git a/frontend/src/lib/inviteLink.ts b/frontend/src/lib/inviteLink.ts index cce53e0b387..c0976e9c84a 100644 --- a/frontend/src/lib/inviteLink.ts +++ b/frontend/src/lib/inviteLink.ts @@ -1,7 +1,6 @@ // An invitation link (`/spaces#invite=&org=…&namespace=…`), taken out of the address -// into this tab's session: by the sign-in gate as a single sign-on starts (the identity -// provider's round trip drops the fragment), else by Namespaces in your org, which offers to -// accept it. A password sign-in reloads the page, fragment and all. +// into this tab's session by Namespaces in your org, which offers to accept it. A password +// sign-in reloads the page, fragment and all; single sign-on makes no link. /** The session key for an invitation link's `{ secret, org, namespace }`. */ export const INVITE_LINK = "loom_invite_v1"; diff --git a/server/identity/app/invites.py b/server/identity/app/invites.py index 8af7e51b859..5c9fe633448 100644 --- a/server/identity/app/invites.py +++ b/server/identity/app/invites.py @@ -274,10 +274,14 @@ async def handle_grants_list_invites(input: GrantsListInvitesInput) -> GrantsLis async def handle_grants_cancel_invite(input: GrantsCancelInviteInput) -> GrantsCancelInviteOutput: async with invite_change(input.org, input.namespace, input.invite_id): invite = await invites_repo.get(input.org, input.namespace, input.invite_id) - if invite is None or not invite.is_open(int(time.time())): + if invite is None: return GrantsCancelInviteOutput(cancelled=False) - await invites_repo.put(invite.cancelled(datetime.now(UTC))) - return GrantsCancelInviteOutput(cancelled=True) + was_open = invite.is_open(int(time.time())) + # An accepted one is closed too, so an accept whose grant then fails leaves it + # closed rather than open again after the cancel. + if was_open or invite.state == "accepted": + await invites_repo.put(invite.cancelled(datetime.now(UTC))) + return GrantsCancelInviteOutput(cancelled=was_open) def _accepter(org: str) -> str: diff --git a/server/transport/mcp_descriptions.py b/server/transport/mcp_descriptions.py index c30e6ad6593..51b6aafe8ac 100644 --- a/server/transport/mcp_descriptions.py +++ b/server/transport/mcp_descriptions.py @@ -464,7 +464,7 @@ def revision_policy(update: str) -> str: "grants.create": ( "Grant another subject (user or service-account) viewer / writer " "/ admin role on a namespace. Call to grant a service account, a group " - 'or everyone, or to change a role — "give Carol admin on Y"; to add a ' + 'or everyone, or to change the role of a member — "make Carol an admin of Y"; to add a ' "person by login handle or email, call grants.invite. The caller must " "already be admin on the target namespace. Lowering someone's current " "role is refused (409 GRANT_WOULD_DOWNGRADE) unless replace=true is passed." diff --git a/tests/unit/test_grants_invite.py b/tests/unit/test_grants_invite.py index f90e2ef8d32..b26a66962a9 100644 --- a/tests/unit/test_grants_invite.py +++ b/tests/unit/test_grants_invite.py @@ -5,10 +5,11 @@ from __future__ import annotations +import asyncio import contextlib import smtplib import time -from collections.abc import AsyncIterator, Iterator +from collections.abc import AsyncIterator, Awaitable, Callable, Iterator from dataclasses import replace from datetime import UTC, datetime from typing import Any, ClassVar @@ -73,6 +74,8 @@ def __init__(self) -> None: self.put_error: BaseException | None = None # Cancelled from inside the grant, as a client gone mid-request cancels it. self.cancel: anyio.CancelScope | None = None + # Run while the grant is in flight, before it lands or fails. + self.during_grant: Callable[[], Awaitable[Any]] | None = None @pytest.fixture @@ -87,6 +90,7 @@ async def put(invite: domain.Invite, **_: Any) -> None: async def get(org: str, namespace: str, invite_id: str, **_: Any) -> domain.Invite | None: found = w.invites.get(invite_id) + await anyio.lowlevel.checkpoint() # answered as of the read, before another write return found if found and (found.org, found.namespace) == (org, namespace) else None async def open_on( @@ -115,6 +119,8 @@ async def create_grant(input: GrantsCreateInput, *_a: Any, issuer: str | None = if w.cancel is not None: w.cancel.cancel() await anyio.lowlevel.checkpoint() + if w.during_grant is not None: + await w.during_grant() if w.grant_lands: w.grants.append((input, issuer)) if w.grant_error is not None: @@ -444,6 +450,58 @@ async def test_a_cancelled_accept_leaves_the_link_open(world: World) -> None: assert world.grants == [] +@pytest.mark.asyncio +async def test_two_people_opening_one_link_at_once_let_in_one( + world: World, monkeypatch: pytest.MonkeyPatch +) -> None: + from server.auth import grant_claims + from tests.unit.claims_fake import memory_claims + + claims = memory_claims(monkeypatch) + monkeypatch.setattr(grant_claims, "take", claims.take) + monkeypatch.setattr(mod, "invite_change", grant_claims.invite_change) + secret = secret_of((await invite("robin@example.com")).link_path) + + async def as_(subject: str) -> Any: + signed_in(subject) + return await accept(secret) + + got = await asyncio.gather(as_("robin"), as_("carol"), return_exceptions=True) + assert sorted(type(g).__name__ for g in got) == ["GrantsAcceptInviteOutput", "NotFoundError"] + assert len(world.grants) == 1 + + +@pytest.mark.asyncio +async def test_a_namespace_retired_since_the_invitation_admits_nobody(world: World) -> None: + secret = secret_of((await invite("robin@example.com")).link_path) + world.active = False + signed_in("robin") + with pytest.raises(NotFoundError): + await accept(secret) + assert world.grants == [] and world.invites[domain.invite_id(secret)].state == "open" + + +@pytest.mark.asyncio +async def test_a_cancel_while_a_failing_accept_is_in_flight_keeps_the_link_closed( + world: World, +) -> None: + out = await invite("robin@example.com") + answers: list[bool] = [] + + async def cancel() -> None: + signed_in("admin-ann") + scope = GrantsCancelInviteInput(org="o", namespace="ns", invite_id=out.invite_id) + answers.append((await mod.handle_grants_cancel_invite(scope)).cancelled) + signed_in("robin") + + world.during_grant, world.grant_error = cancel, BackendUnavailableError("down") + signed_in("robin") + with pytest.raises(BackendUnavailableError): + await accept(secret_of(out.link_path)) + # Not open when the cancel came, so not cancelled by it; and not reopened after it. + assert answers == [False] and world.invites[out.invite_id].state == "cancelled" + + @pytest.mark.asyncio async def test_a_failure_after_the_grant_landed_leaves_the_link_used(world: World) -> None: secret = secret_of((await invite("robin@example.com")).link_path) @@ -658,6 +716,7 @@ async def test_an_expired_or_cancelled_link_admits_nobody(world: World) -> None: ("subject", "org", "service", "words"), [ ("sa:bot", "o", True, "a person"), + ("bot", "o", True, "a person"), # a service account's token, its subject unprefixed ("group:eng", "o", False, "a person"), ("robin", "other", False, "sign in to o"), ], From 8d6d9e84716d05905c3a765c6eaefd2bf922bb0b Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Sat, 5 Dec 2026 09:37:09 +0530 Subject: [PATCH 26/28] grants.invite: keep pasted and storage-refused links; cover invites in the analyzer The accept card picks up a link pasted into a tab already on the page, holds the link itself when session storage is refused, and drops it only on the server's own refusal codes, not on any 404. The code-ceiling and principal-target checks are public, since invites call them. The reopen after a failed accept drops a redundant consistency wrapper: every read under the claim is already sequentially consistent. The analyzer corpus covers the invite handlers, the integration tests mint person tokens, and the op descriptions and guides say when a handle or email is granted at once. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Lareb Zafar --- docs/guides/tokens-and-grants.md | 20 ++-- docs/reference/operations/grants.md | 2 +- .../src/flows/MembersDialog.invite.test.tsx | 8 +- frontend/src/lib/inviteLink.ts | 15 +-- frontend/src/views/InvitationCard.test.tsx | 49 ++++++++- frontend/src/views/InvitationCard.tsx | 32 ++++-- server/identity/api/models_grants.py | 4 +- server/identity/app/grants.py | 12 +-- server/identity/app/invites.py | 15 ++- server/transport/mcp_descriptions.py | 6 +- tests/analyzer/cases/planes.py | 2 + tests/analyzer/shapes.txt | 4 + tests/conftest.py | 8 +- tests/integration/test_grants_invite.py | 100 ++++++++++++------ tests/unit/test_agent_shares.py | 2 +- tests/unit/test_auth_aliases.py | 2 +- tests/unit/test_grant_claims.py | 4 +- tests/unit/test_grants_create_downgrade.py | 2 +- .../unit/test_grants_create_stamps_granter.py | 2 +- tests/unit/test_grants_invite.py | 7 +- tests/unit/test_repo_maintainers.py | 2 +- tests/unit/test_sharing.py | 10 +- 22 files changed, 208 insertions(+), 100 deletions(-) diff --git a/docs/guides/tokens-and-grants.md b/docs/guides/tokens-and-grants.md index 8e4445d2d1a..d0b0cfec18e 100644 --- a/docs/guides/tokens-and-grants.md +++ b/docs/guides/tokens-and-grants.md @@ -225,15 +225,17 @@ answer to the user (the entity graph, conversation reads, exports, admin ops) is namespace above what the token carries. Grants add; where the subject holds one, a token's claim goes no further than it. -| Op | Role | Does | -| ----------------------- | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `grants.create` | admin | Give `subject` a `role`. Below the subject's current role it answers 409 `GRANT_WOULD_DOWNGRADE` unless `replace: true`. | -| `grants.invite` | admin | Give a person a `role` by login handle or email: an account's handle or verified email is granted at once, any other email gets a single-use invitation link. A handle no account or live grant holds is refused (404). | -| `grants.accept_invite` | a signed-in person | Accept an invitation link; its role goes to the account the caller signs in as. | -| `grants.revoke` | admin | Remove it; on a restricted namespace the grants of tokens the subject minted there go too. | -| `grants.list` | viewer | The namespace's grants. | -| `grants.approve` | admin | Activate a pending join request. Below the subject's current grant it answers 409: an approval never asks to lower one. | -| `grants.pending_for_me` | viewer | Requests waiting on the caller's approval. | +| Op | Role | Does | +| ----------------------- | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `grants.create` | admin | Give `subject` a `role`. Below the subject's current role it answers 409 `GRANT_WOULD_DOWNGRADE` unless `replace: true`. | +| `grants.invite` | admin | Give a person a `role` by login handle or email: an account's handle or verified email is granted at once, any other email gets a single-use invitation link, or, where sign-in is single sign-on only, a grant as typed. A handle no account or live grant holds is refused (404). | +| `grants.accept_invite` | a signed-in person | Accept an invitation link; its role goes to the account the caller signs in as. | +| `grants.list_invites` | admin | The open invitations: each link that still admits someone. | +| `grants.cancel_invite` | admin | Withdraw an open invitation. | +| `grants.revoke` | admin | Remove it; on a restricted namespace the grants of tokens the subject minted there go too. | +| `grants.list` | viewer | The namespace's grants. | +| `grants.approve` | admin | Activate a pending join request. Below the subject's current grant it answers 409: an approval never asks to lower one. | +| `grants.pending_for_me` | viewer | Requests waiting on the caller's approval. | ```bash curl -s "$LOOM_BASE_URL/v1/grants.create" -H "Authorization: Bearer $ADMIN_TOKEN" \ diff --git a/docs/reference/operations/grants.md b/docs/reference/operations/grants.md index 576cb7d387a..c84b99cbf4d 100644 --- a/docs/reference/operations/grants.md +++ b/docs/reference/operations/grants.md @@ -143,7 +143,7 @@ List a namespace's open invitations. | Output field | Type | Meaning | | --- | --- | --- | -| `rows` | `list[_InviteEntry]` | The namespace's invitations not yet accepted, cancelled or expired, newest first; at most 200. | +| `rows` | `list[_InviteEntry]` | The namespace's open links that still admit someone (not accepted, cancelled or expired, and with a maker who still stands), newest first; at most 200. | ## `grants.pending_for_me` diff --git a/frontend/src/flows/MembersDialog.invite.test.tsx b/frontend/src/flows/MembersDialog.invite.test.tsx index 5a175a8b9bc..b7fca49c849 100644 --- a/frontend/src/flows/MembersDialog.invite.test.tsx +++ b/frontend/src/flows/MembersDialog.invite.test.tsx @@ -3,6 +3,7 @@ import userEvent from "@testing-library/user-event"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import * as api from "../api"; import * as invites from "../api/invites"; +import { toast } from "../components/Toast"; import { useStore } from "../lib/state"; import { MembersDialog } from "./MembersDialog"; @@ -15,6 +16,10 @@ vi.mock("../api", async (importOriginal) => ({ listGrants: vi.fn(async () => ({ rows: [] })), createGrant: vi.fn(async () => ({})), })); +vi.mock("../components/Toast", async (importOriginal) => ({ + ...(await importOriginal()), + toast: vi.fn(), +})); vi.mock("../api/invites", async (importOriginal) => ({ ...(await importOriginal()), invite: vi.fn(), @@ -76,7 +81,8 @@ describe("MembersDialog invites a person", () => { it("grants an account's handle at once, under the subject the server names", async () => { vi.mocked(invites.invite).mockResolvedValue({ ...invited, outcome: "granted", subject: "robin", invite_id: "" }); await add("Robin"); - await waitFor(() => expect(invites.invite).toHaveBeenCalledTimes(1)); + await waitFor(() => expect(toast).toHaveBeenCalledWith("Added robin as writer", "ok")); + expect(invites.invite).toHaveBeenCalledTimes(1); expect(screen.queryByRole("status")).toBeNull(); expect(screen.queryByRole("textbox", { name: /member to add/ })).toBeNull(); }); diff --git a/frontend/src/lib/inviteLink.ts b/frontend/src/lib/inviteLink.ts index c0976e9c84a..5932b3f0648 100644 --- a/frontend/src/lib/inviteLink.ts +++ b/frontend/src/lib/inviteLink.ts @@ -11,16 +11,19 @@ export interface InviteLink { namespace: string; } -/** Take an invitation link out of the address into this tab's session. */ -export function takeInviteLink(): void { +/** Take an invitation link out of the address into this tab's session, and return it. */ +export function takeInviteLink(): InviteLink | null { const { hash, pathname, search } = window.location; - if (!hash.startsWith("#invite=")) return; + if (!hash.startsWith("#invite=")) return null; history.replaceState(history.state, "", pathname + search); const p = new URLSearchParams(hash.slice(1)); - const link = { secret: p.get("invite"), org: p.get("org"), namespace: p.get("namespace") }; + const [secret, org, namespace] = [p.get("invite"), p.get("org"), p.get("namespace")]; + if (!secret || !org || !namespace) return null; + const link = { secret, org, namespace }; try { - if (link.secret && link.org && link.namespace) sessionStorage.setItem(INVITE_LINK, JSON.stringify(link)); + sessionStorage.setItem(INVITE_LINK, JSON.stringify(link)); } catch { - /* no session storage: the link is opened again once signed in */ + /* no session storage: the card holds it until the page goes */ } + return link; } diff --git a/frontend/src/views/InvitationCard.test.tsx b/frontend/src/views/InvitationCard.test.tsx index 9e1efb8ace1..ac304bb04bc 100644 --- a/frontend/src/views/InvitationCard.test.tsx +++ b/frontend/src/views/InvitationCard.test.tsx @@ -1,4 +1,4 @@ -import { cleanup, render, screen } from "../test/rtl"; +import { act, cleanup, render, screen, waitFor } from "../test/rtl"; import userEvent from "@testing-library/user-event"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { listMine } from "../api"; @@ -9,9 +9,8 @@ import { invalidateShared, sharedMine } from "../lib/sharedReads"; import { useStore } from "../lib/state"; import { InvitationCard } from "./InvitationCard"; -// An invitation link's secret rides in the fragment; the card (or a single sign-on as it starts) -// moves it into the tab's session so a sign-in keeps it, and the card accepts it as the -// signed-in person. +// An invitation link's secret rides in the fragment; the card moves it into the tab's session +// and accepts it as the signed-in person. vi.mock("../api/invites", () => ({ acceptInvite: vi.fn() })); vi.mock("../api", async (importOriginal) => ({ @@ -87,7 +86,7 @@ describe("InvitationCard", () => { vi.mocked(acceptInvite).mockRejectedValue( new ApiError({ status: 404, - code: "NOT_FOUND", + code: "RESOURCE_NOT_FOUND", message: "this invitation link is used, cancelled or expired: ask for a new one", }), ); @@ -100,6 +99,46 @@ describe("InvitationCard", () => { expect(useStore.getState().identity?.namespace).toBe("home"); }); + it("keeps the link when the 404 is not the server's refusal of it", async () => { + // A replica of the previous build answers an op it does not serve with a bare 404. + vi.mocked(acceptInvite).mockRejectedValueOnce(new ApiError({ status: 404, message: "Not Found" })); + const user = userEvent.setup(); + opened(); + await user.click(screen.getByRole("button", { name: "Accept invitation" })); + await waitFor(() => expect(screen.getByRole("button", { name: "Accept invitation" })).toBeEnabled()); + expect(acceptInvite).toHaveBeenCalledTimes(1); + expect(sessionStorage.getItem(INVITE_LINK)).not.toBeNull(); + }); + + it("shows a link pasted into a tab already on the page", async () => { + render(); + expect(screen.queryByRole("region", { name: "Invitation" })).toBeNull(); + history.replaceState(null, "", "/spaces#invite=s3cret&org=dev&namespace=alerts"); + act(() => { + window.dispatchEvent(new HashChangeEvent("hashchange")); + }); + try { + expect(await screen.findByRole("button", { name: "Accept invitation" })).toBeEnabled(); + } finally { + history.replaceState(null, "", "/"); + } + }); + + it("holds the link itself where session storage is refused", () => { + const refuse = vi.spyOn(Storage.prototype, "setItem").mockImplementation(() => { + throw new DOMException("blocked", "SecurityError"); + }); + try { + history.replaceState(null, "", "/spaces#invite=s3cret&org=dev&namespace=alerts"); + render(); + expect(screen.getByRole("button", { name: "Accept invitation" })).toBeEnabled(); + expect(window.location.hash).toBe(""); + } finally { + refuse.mockRestore(); + history.replaceState(null, "", "/"); + } + }); + it("keeps the link and Accept through an outage", async () => { vi.mocked(acceptInvite).mockRejectedValueOnce( new ApiError({ status: 503, code: "BACKEND_UNAVAILABLE", message: "grants could not be read" }), diff --git a/frontend/src/views/InvitationCard.tsx b/frontend/src/views/InvitationCard.tsx index 493d8301e57..6d241738bf7 100644 --- a/frontend/src/views/InvitationCard.tsx +++ b/frontend/src/views/InvitationCard.tsx @@ -1,4 +1,4 @@ -import { useState } from "react"; +import { useEffect, useState } from "react"; import { Button } from "@clickhouse/click-ui/Button"; import { setSavedNamespace } from "../api"; import { acceptInvite } from "../api/invites"; @@ -13,16 +13,16 @@ import { useStore } from "../lib/state"; function stashed(): InviteLink | null { // An address opened signed in, or after a password sign-in, still carries it. - takeInviteLink(); + const taken = takeInviteLink(); try { const v = JSON.parse(sessionStorage.getItem(INVITE_LINK) ?? "null") as Partial | null; if (v && typeof v.secret === "string" && typeof v.org === "string" && typeof v.namespace === "string") { return { secret: v.secret, org: v.org, namespace: v.namespace }; } } catch { - /* unreadable: no invitation */ + /* unreadable: only the link the address carried */ } - return null; + return taken; } function drop(): void { @@ -33,18 +33,29 @@ function drop(): void { } } -/** The invitation link this tab opened (`lib/inviteLink.ts` keeps it through a single sign-on), for the - * signed-in person to accept. */ +/** The invitation link this tab opened, for the signed-in person to accept. */ export function InvitationCard() { const [link, setLink] = useState(stashed); const [busy, setBusy] = useState(false); const [error, setError] = useState(null); - // The server refused the link: 404 when it is used, cancelled or expired, 422 when this - // account cannot accept it. Only Close is left. + // The server refused the link: RESOURCE_NOT_FOUND when it is used, cancelled or expired, + // VALIDATION_FAILED when this account cannot accept it. Only Close is left. const [refused, setRefused] = useState(false); const identity = useStore((s) => s.identity); const setIdentity = useStore((s) => s.setIdentity); const navigate = useStore((s) => s.navigate); + // A link pasted into a tab already on this page changes only the fragment. + useEffect(() => { + const opened = () => { + const next = stashed(); + if (!next) return; + setLink(next); + setRefused(false); + setError(null); + }; + window.addEventListener("hashchange", opened); + return () => window.removeEventListener("hashchange", opened); + }, []); if (!link) return null; // A link to another org is accepted only signed in there: the server refuses it here. @@ -68,8 +79,9 @@ export function InvitationCard() { setSavedNamespace(out.namespace); } } catch (e) { - // Any other refusal (an ended session, a rate limit) keeps the link for a retry. - if (e instanceof ApiError && (e.status === 404 || e.status === 422)) { + // Only the server's refusal of the link drops it: an ended session, a rate limit or a + // replica that does not serve the op yet keeps it for a retry. + if (e instanceof ApiError && (e.code === "RESOURCE_NOT_FOUND" || e.code === "VALIDATION_FAILED")) { drop(); setRefused(true); } diff --git a/server/identity/api/models_grants.py b/server/identity/api/models_grants.py index 590ed9879f9..896305e5dc2 100644 --- a/server/identity/api/models_grants.py +++ b/server/identity/api/models_grants.py @@ -265,8 +265,8 @@ class _InviteEntry(BaseModel): class GrantsListInvitesOutput(BaseModel): - # The namespace's invitations not yet accepted, cancelled or expired, newest first; - # at most 200. + # The namespace's open links that still admit someone (not accepted, cancelled or + # expired, and with a maker who still stands), newest first; at most 200. rows: list[_InviteEntry] diff --git a/server/identity/app/grants.py b/server/identity/app/grants.py index 09b038babd3..3dc12ecfa26 100644 --- a/server/identity/app/grants.py +++ b/server/identity/app/grants.py @@ -78,7 +78,7 @@ async def adopt_namespace( return now -async def _enforce_code_ceiling(org: str, namespace: str, role: str) -> None: +async def enforce_code_ceiling(org: str, namespace: str, role: str) -> None: """On a code namespace `writer` does not exist; a reader (viewer) or maintainer (admin) may be granted or approved by anyone the transport's ADMIN gate let through: an org admin or a current maintainer of that repository.""" @@ -147,7 +147,7 @@ def _refuse_approval_below(current: str, target: str, input: GrantsApproveInput) ) -def _enforce_principal_target(namespace: str, subject: str) -> None: +def enforce_principal_target(namespace: str, subject: str) -> None: """A personal collection keeps its one grant; a group, an agent or `everyone` holds grants only on collections; a `user:`/`group:`/`agent:` subject needs a well-formed id.""" @@ -199,8 +199,8 @@ async def create_grant( not write over, checked on the row read under the grant's claim. `issuer` is stamped as `granted_by` in place of the caller: the maker of an invitation the caller accepts.""" - await _enforce_code_ceiling(input.org, input.namespace, input.role) - _enforce_principal_target(input.namespace, input.subject) + await enforce_code_ceiling(input.org, input.namespace, input.role) + enforce_principal_target(input.namespace, input.subject) async with _group_held(input.org, input.subject): now = await _create_grant(input, may_replace, issuer) return GrantsCreateOutput( @@ -613,7 +613,7 @@ async def _write_revoke( async def handle_grants_approve(input: GrantsApproveInput) -> GrantsApproveOutput: """Approve or reject a pending grant. No-op if it doesn't exist.""" - _enforce_principal_target(input.namespace, input.subject) + enforce_principal_target(input.namespace, input.subject) async with grant_change(input.org, input.namespace, input.subject): out = await _decide_request(input) if out.decision == "approve" and out.role == "admin": @@ -659,7 +659,7 @@ async def _decide_request(input: GrantsApproveInput) -> GrantsApproveOutput: target_role = input.role or pending_role or row.role if input.decision == "approve" and not no_base_access: _refuse_approval_below(row.role, str(target_role), input) - await _enforce_code_ceiling(input.org, input.namespace, str(target_role)) + await enforce_code_ceiling(input.org, input.namespace, str(target_role)) # granted_by on the new row is the approver, not the requester — the # audit trail and the "approved by …" notification need the right person. from server.auth.context import current_auth diff --git a/server/identity/app/invites.py b/server/identity/app/invites.py index 5c9fe633448..bc56d94b4ac 100644 --- a/server/identity/app/invites.py +++ b/server/identity/app/invites.py @@ -31,7 +31,6 @@ from server.auth.grant_claims import invite_change from server.auth.revocation import is_revoked from server.auth.self_signup import valid_signup_email -from server.core.ch import own_write_reads from server.core.errors import ( BackendUnavailableError, GrantWouldDowngradeError, @@ -61,9 +60,9 @@ ) from server.identity.app import invite_mail from server.identity.app.grants import ( - _enforce_code_ceiling, - _enforce_principal_target, create_grant, + enforce_code_ceiling, + enforce_principal_target, ) from server.identity.domain import invites as domain from server.identity.store import grants as grants_repo @@ -132,7 +131,7 @@ async def _held(org: str, person: str) -> str | None: async def handle_grants_invite(input: GrantsInviteInput) -> GrantsInviteOutput: person = _person(input.to) - _enforce_principal_target(input.namespace, person) + enforce_principal_target(input.namespace, person) subject = await _held(input.org, person) if subject is not None: return await _granted(input, subject) @@ -150,7 +149,7 @@ async def handle_grants_invite(input: GrantsInviteInput) -> GrantsInviteOutput: raise ValidationError(f"{person!r} is not an email address") if settings.oauth_login_provider == "oidc": return await _granted(input, person) - await _enforce_code_ceiling(input.org, input.namespace, input.role) + await enforce_code_ceiling(input.org, input.namespace, input.role) if not await namespaces_repo.is_active(input.org, input.namespace): raise NotFoundError( f"{input.org}/{input.namespace} is not an active namespace: register or restore it " @@ -351,9 +350,9 @@ async def _reopen_unless_granted(invite: domain.Invite, subject: str) -> None: async with invite_change(invite.org, invite.namespace, invite.invite_id): granted_to = await canonical_subject(invite.org, subject) - # Right after the grant's own write: another replica may not have it yet. - with own_write_reads(): - held = await grants_repo.find_active_grant(invite.org, invite.namespace, granted_to) + # Read with sequential consistency, as every read under the claim is: right after + # the grant's own write, another replica may not have it yet. + held = await grants_repo.find_active_grant(invite.org, invite.namespace, granted_to) if held is not None and grant_rank(held.role) >= grant_rank(invite.role): return current = await invites_repo.get(invite.org, invite.namespace, invite.invite_id) diff --git a/server/transport/mcp_descriptions.py b/server/transport/mcp_descriptions.py index de258c7ade8..a2621eaf974 100644 --- a/server/transport/mcp_descriptions.py +++ b/server/transport/mcp_descriptions.py @@ -475,12 +475,12 @@ def revision_policy(update: str) -> str: "A handle an account or a live grant holds, or an email verified for an " "account, is granted at once; any other email gets " "a single-use invitation link (emailed when the server sends mail) to pass " - "on, or, where sign-in is single sign-on only, a grant as typed; a handle no " - "account holds is refused." + "on, or, where sign-in is single sign-on only, a grant as typed; any other " + "handle is refused." ), "grants.list_invites": ( "List a namespace's open invitations: the address, role, maker and expiry " - "of each link not yet accepted, cancelled or expired. Caller must be admin." + "of each link that still admits someone. Caller must be admin." ), "grants.cancel_invite": ( "Cancel an open invitation by its invite_id, so its link admits nobody. " diff --git a/tests/analyzer/cases/planes.py b/tests/analyzer/cases/planes.py index a5f020b0674..e40a01f90e2 100644 --- a/tests/analyzer/cases/planes.py +++ b/tests/analyzer/cases/planes.py @@ -178,6 +178,7 @@ { "namespace_validate", "grants", + "_grants_invites", "context_offload", "knowledge", "_memory_consolidate", @@ -240,6 +241,7 @@ ("_knowledge_reads", "server.knowledge.app.document_reads"), ("_knowledge_dedup", "server.knowledge.app.dedup"), ("grants", "server.identity.app.grants"), + ("_grants_invites", "server.identity.app.invites"), ("policy", "server.identity.app.history_policy_ops"), ("learnings", "server.memory.app.learnings"), ("blacklist", "server.memory.app.blacklist"), diff --git a/tests/analyzer/shapes.txt b/tests/analyzer/shapes.txt index 4e33b12d03f..7c7f4cd9635 100644 --- a/tests/analyzer/shapes.txt +++ b/tests/analyzer/shapes.txt @@ -508,6 +508,7 @@ 39db945a8f03 ALTER TABLE loom.conversation_embeddings UPDATE tombstoned_at = {now:DateTime} WHERE (org = {org:String} AND tombstoned_at IS NULL AND user_id = {uid:String}) AND ({erasure_mutation_tag:String} = {era 39f9fbc2c519 SELECT count() AS n FROM loom.session_brief_revisions WHERE org = {org:String} AND user_id = {uid:String} 3a315e2ef1be ALTER TABLE loom.entity_canonical_map UPDATE tombstoned_at = {now:DateTime} WHERE (org = {org:String} AND tombstoned_at IS NULL AND namespace IN {ns:Array(String)}) AND ({erasure_mutation_tag:String} +3a57d058ba83 SELECT org, namespace, invite_id, email, role, created_by, created_at, expires_at, state, accepted_by, changed_at FROM loom.namespace_invites FINAL WHERE org = {org:String} AND namespace = {ns:String} 3a6169b72b54 SELECT count() AS n FROM loom.derived_facts WHERE org = {org:String} AND user_id = {uid:String} 3a8471ec9ffe SELECT pr_number, any(title) AS title, any(author) AS author, min(merged_at) AS merged_at, max(opened_at) AS opened_at, any(files) AS files, any(linked_issues) AS linked_issues FROM loom.code_pr_histo 3a88608e1703 SELECT count() AS n FROM loom.entity_triples WHERE org = {org:String} AND namespace IN {ns:Array(String)} AND ? @@ -1822,6 +1823,7 @@ c4fb2b7ac3e8 ALTER TABLE loom.tasks DELETE WHERE (org = {org:String} AND namespa c529ba815261 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, -- The content hash, for the read receipt of a hit this c53355b3cf3a SELECT c.session_id AS session_id, c.chunk_index AS chunk_index, c.parent_memory_key AS parent_memory_key, cosineDistance(c.embedding, {q:Array(Float32)}) AS distance FROM loom.memory_chunks AS c WHER c562da6b7b7f SELECT count() AS n FROM loom.entity_communities WHERE org = {org:String} AND namespace IN {ns:Array(String)} +c5e951112035 SELECT org, namespace, invite_id, email, role, created_by, created_at, expires_at, state, accepted_by, changed_at FROM loom.namespace_invites FINAL WHERE org = {org:String} AND namespace = {ns:String} c5f2a81cdd02 SELECT count() AS n FROM loom.consolidation_runs WHERE org = {org:String} AND user_id = {uid:String} c6056fca9bec ALTER TABLE loom.conflict_allowlist UPDATE tombstoned_at = {now:DateTime} WHERE (org = {org:String} AND tombstoned_at IS NULL AND namespace = {ns:String}) AND ({erasure_mutation_tag:String} = {erasure c6278079e133 SELECT namespace, agent, user_id, session_id, memory_key, toString(memory_id) AS mid, value, tags, files, toString(content_sha256) AS sha, version FROM loom.memory FINAL WHERE org = {org:String} AND n @@ -2104,6 +2106,7 @@ df5c577c685a SELECT sid, argMin(content_hash, start_line) AS h FROM ( SELECT arr df62986ef9b7 SELECT concat(?, toString(c.session_id), ?, toString(c.chunk_index)) AS memory_key, ? AS memory_type, substring(c.content, ?, ?) AS content_excerpt, c.content AS content_full, c.agent AS agent, c.user df875c426404 SELECT count() AS n FROM loom.memory_ask_precedents WHERE org = {org:String} AND namespace IN {ns:Array(String)} df886269fbb5 SELECT org, namespace FROM loom.namespace_grants FINAL WHERE role = ? AND revoked_at IS NULL AND status = ? AND (org, namespace) IN {keys:Array(Tuple(String, String))} GROUP BY org, namespace +df95e8727da8 SELECT subject FROM loom.namespace_grants FINAL WHERE org = {org:String} AND lower(subject) = lower({sub:String}) AND revoked_at IS NULL AND status = ? ORDER BY subject LIMIT ? df9a592b3176 SELECT min(version) AS v FROM loom.memory_versions WHERE org = {org:String} AND namespace = {ns:String} dfab46389b75 SELECT count() AS n FROM loom.memory_record_versions WHERE org = {org:String} AND namespace = {ns:String} AND ? dfb389c3eaaa SELECT count() AS n FROM loom.memory_records FINAL WHERE org = {org:String} AND namespace = {ns:String} AND tombstoned_at IS NULL @@ -2187,6 +2190,7 @@ e77b590b9f54 SELECT org, namespace, name, source_id, provider, generation, finge e77c1e05f3c4 SELECT count() AS n FROM loom.blob_uploads WHERE org = {org:String} AND namespace IN {ns:Array(String)} AND ? e7b42de1321e SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, -- The content hash, for the read receipt of a hit this e7d4c583cc0e ALTER TABLE loom.procedure_runs DELETE WHERE (org = {org:String} AND namespace = {ns:String}) AND ({erasure_mutation_tag:String} = {erasure_mutation_tag:String}) SETTINGS mutations_sync = ? +e7eec9ffed80 SELECT owner_email FROM loom.namespaces FINAL WHERE org = {org:String} AND ifNull(active, true) = true AND owner_email != ? AND lower(owner_email) = lower({sub:String}) ORDER BY owner_email LIMIT ? e7ef19d41a90 SELECT agent, user_id, session_id, embedding_model, summary_text, key_facts, derived_from, valid_at, created_at, version, length(key_facts) AS kf, length(derived_from) AS df, coalesce(valid_at, create e7f1d693d5b1 SELECT count() AS n FROM loom.entity_vectors WHERE org = {org:String} AND (user_id = {uid:String} OR (namespace, memory_key) IN {keys:Array(Tuple(String, String))}) e8009bd53bc4 SELECT number, head_sha FROM loom.code_gh_items FINAL WHERE org = {org:String} AND namespace = {ns:String} AND tombstoned_at IS NULL AND is_pr AND state = ? AND head_sha != ? ORDER BY updated_at DESC, diff --git a/tests/conftest.py b/tests/conftest.py index c74aba61ab6..e21099f07b7 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -225,8 +225,9 @@ def pytest_sessionstart(session: pytest.Session) -> None: @pytest.fixture def mint_test_token(): - """A callable minting a service-account JWT for the test's own org, for - tests that construct `Agent(...)` with their own identity: + """A callable minting a JWT for the test's own org (a service account's unless + `is_service_account=False`, a person's), for tests that construct `Agent(...)` + with their own identity: tok = mint_test_token(org="my-test-org", namespaces=["*"]) async with Agent(org="my-test-org", ..., api_key=tok) as a: ... @@ -242,6 +243,7 @@ def _mint( subject: str = "test-suite", read_user_id: str | None = None, read_scope: str | None = None, + is_service_account: bool = True, ) -> str: return mint_token( subject=subject, @@ -249,7 +251,7 @@ def _mint( namespaces=namespaces or ["*"], roles=roles or ["writer"], ttl_seconds=ttl_seconds, - is_service_account=True, + is_service_account=is_service_account, read_user_id=read_user_id, read_scope=read_scope, ) diff --git a/tests/integration/test_grants_invite.py b/tests/integration/test_grants_invite.py index 148c35b3836..d7e2099fab3 100644 --- a/tests/integration/test_grants_invite.py +++ b/tests/integration/test_grants_invite.py @@ -6,6 +6,7 @@ from __future__ import annotations import uuid +from typing import Any from urllib.parse import parse_qs, urlsplit import httpx @@ -13,19 +14,6 @@ from tests.integration._resources import unique_org -def _person_token(*, org: str, subject: str, namespaces: list[str], roles: list[str]) -> str: - from server.auth.jwt import mint_token - - return mint_token( - subject=subject, - org=org, - namespaces=namespaces, - roles=roles, - ttl_seconds=600, - is_service_account=False, - ) - - def _post(base: str, token: str, op: str, payload: dict) -> httpx.Response: with httpx.Client(base_url=base, timeout=30.0) as c: return c.post(f"/v1/{op}", json=payload, headers={"Authorization": f"Bearer {token}"}) @@ -38,11 +26,13 @@ def _register(base: str, token: str, org: str, namespace: str, owner: str) -> No def test_an_invited_email_is_accepted_once_under_the_accepters_handle( - control_plane_url: str, + control_plane_url: str, mint_test_token: Any ) -> None: org = unique_org("invite") ns = f"ns-{uuid.uuid4().hex[:8]}" - admin = _person_token(org=org, subject="ann-admin", namespaces=[ns], roles=["admin"]) + admin = mint_test_token( + is_service_account=False, org=org, subject="ann-admin", namespaces=[ns], roles=["admin"] + ) _register(control_plane_url, admin, org, ns, "ann-admin") r = _post( @@ -59,7 +49,13 @@ def test_an_invited_email_is_accepted_once_under_the_accepters_handle( assert [row["email"] for row in listed.json()["rows"]] == ["robin@example.com"] # The person signs in under a handle that is not the email. - person = _person_token(org=org, subject="robin", namespaces=[f"home-{ns}"], roles=["viewer"]) + person = mint_test_token( + is_service_account=False, + org=org, + subject="robin", + namespaces=[f"home-{ns}"], + roles=["viewer"], + ) body = {"org": org, "namespace": ns, "secret": secret} r = _post(control_plane_url, person, "grants.accept_invite", body) assert r.status_code == 200, r.text @@ -70,17 +66,25 @@ def test_an_invited_email_is_accepted_once_under_the_accepters_handle( assert [(g["role"], g["granted_by"]) for g in mine] == [("writer", "ann-admin")] # Spent: a second open of the link admits nobody, and it is no longer listed. - other = _person_token(org=org, subject="someone", namespaces=[f"x-{ns}"], roles=["viewer"]) + other = mint_test_token( + is_service_account=False, + org=org, + subject="someone", + namespaces=[f"x-{ns}"], + roles=["viewer"], + ) again = _post(control_plane_url, other, "grants.accept_invite", body) assert again.status_code == 404, again.text listed = _post(control_plane_url, admin, "grants.list_invites", {"org": org, "namespace": ns}) assert listed.json()["rows"] == [] -def test_a_handle_no_account_holds_is_refused(control_plane_url: str) -> None: +def test_a_handle_no_account_holds_is_refused(control_plane_url: str, mint_test_token: Any) -> None: org = unique_org("invite") ns = f"ns-{uuid.uuid4().hex[:8]}" - admin = _person_token(org=org, subject="ann-admin", namespaces=[ns], roles=["admin"]) + admin = mint_test_token( + is_service_account=False, org=org, subject="ann-admin", namespaces=[ns], roles=["admin"] + ) _register(control_plane_url, admin, org, ns, "ann-admin") r = _post( control_plane_url, @@ -93,13 +97,19 @@ def test_a_handle_no_account_holds_is_refused(control_plane_url: str) -> None: assert all(g["subject"] != "no-such-handle" for g in grants.json()["rows"]) -def test_a_handle_an_account_signs_in_as_is_granted_at_once(control_plane_url: str) -> None: +def test_a_handle_an_account_signs_in_as_is_granted_at_once( + control_plane_url: str, mint_test_token: Any +) -> None: org = unique_org("invite") ns = f"ns-{uuid.uuid4().hex[:8]}" home = f"home-{ns}" - person = _person_token(org=org, subject="robin", namespaces=[home], roles=["admin"]) + person = mint_test_token( + is_service_account=False, org=org, subject="robin", namespaces=[home], roles=["admin"] + ) _register(control_plane_url, person, org, home, "robin") - admin = _person_token(org=org, subject="ann-admin", namespaces=[ns], roles=["admin"]) + admin = mint_test_token( + is_service_account=False, org=org, subject="ann-admin", namespaces=[ns], roles=["admin"] + ) _register(control_plane_url, admin, org, ns, "ann-admin") r = _post( control_plane_url, @@ -116,13 +126,19 @@ def test_a_handle_an_account_signs_in_as_is_granted_at_once(control_plane_url: s def test_a_handle_a_grant_names_is_held_and_an_email_a_row_names_is_not( - control_plane_url: str, + control_plane_url: str, mint_test_token: Any ) -> None: """A grant under a handle is a person the org knows; an email a row's owner or a grant names is whatever its writer typed, so it still gets a link.""" org = unique_org("invite") ns, other = f"ns-{uuid.uuid4().hex[:8]}", f"ops-{uuid.uuid4().hex[:8]}" - admin = _person_token(org=org, subject="ann-admin", namespaces=[ns, other], roles=["admin"]) + admin = mint_test_token( + is_service_account=False, + org=org, + subject="ann-admin", + namespaces=[ns, other], + roles=["admin"], + ) _register(control_plane_url, admin, org, ns, "ann-admin") _register(control_plane_url, admin, org, other, "platform@acme.example") body = {"org": org, "namespace": other, "subject": "Dana-Ext", "role": "viewer"} @@ -148,10 +164,14 @@ def _invite(base: str, token: str, org: str, ns: str, to: str) -> tuple[str, str return made["invite_id"], parse_qs(urlsplit(made["link_path"]).fragment)["invite"][0] -def test_a_cancelled_link_is_unlisted_and_admits_nobody(control_plane_url: str) -> None: +def test_a_cancelled_link_is_unlisted_and_admits_nobody( + control_plane_url: str, mint_test_token: Any +) -> None: org = unique_org("invite") ns = f"ns-{uuid.uuid4().hex[:8]}" - admin = _person_token(org=org, subject="ann-admin", namespaces=[ns], roles=["admin"]) + admin = mint_test_token( + is_service_account=False, org=org, subject="ann-admin", namespaces=[ns], roles=["admin"] + ) _register(control_plane_url, admin, org, ns, "ann-admin") invite_id, secret = _invite(control_plane_url, admin, org, ns, "robin@example.com") @@ -160,27 +180,45 @@ def test_a_cancelled_link_is_unlisted_and_admits_nobody(control_plane_url: str) assert (r.status_code, r.json()) == (200, {"cancelled": True}), r.text listed = _post(control_plane_url, admin, "grants.list_invites", {"org": org, "namespace": ns}) assert listed.json()["rows"] == [] - person = _person_token(org=org, subject="robin", namespaces=[f"home-{ns}"], roles=["viewer"]) + person = mint_test_token( + is_service_account=False, + org=org, + subject="robin", + namespaces=[f"home-{ns}"], + roles=["viewer"], + ) accept = {"org": org, "namespace": ns, "secret": secret} assert _post(control_plane_url, person, "grants.accept_invite", accept).status_code == 404 -def test_a_link_stops_when_its_maker_loses_admin(control_plane_url: str) -> None: +def test_a_link_stops_when_its_maker_loses_admin( + control_plane_url: str, mint_test_token: Any +) -> None: org = unique_org("invite") ns = f"ns-{uuid.uuid4().hex[:8]}" - ann = _person_token(org=org, subject="ann-admin", namespaces=[ns], roles=["admin"]) + ann = mint_test_token( + is_service_account=False, org=org, subject="ann-admin", namespaces=[ns], roles=["admin"] + ) _register(control_plane_url, ann, org, ns, "ann-admin") # ann's admin is her own grant _, secret = _invite(control_plane_url, ann, org, ns, "robin@example.com") # Another admin stays, so ann's grant can go. grant = {"org": org, "namespace": ns, "subject": "bea-admin", "role": "admin"} assert _post(control_plane_url, ann, "grants.create", grant).status_code == 200 - bea = _person_token(org=org, subject="bea-admin", namespaces=[ns], roles=["admin"]) + bea = mint_test_token( + is_service_account=False, org=org, subject="bea-admin", namespaces=[ns], roles=["admin"] + ) revoke = {"org": org, "namespace": ns, "subject": "ann-admin"} r = _post(control_plane_url, bea, "grants.revoke", revoke) assert r.status_code == 200 and r.json()["revoked"] is True, r.text - person = _person_token(org=org, subject="robin", namespaces=[f"home-{ns}"], roles=["viewer"]) + person = mint_test_token( + is_service_account=False, + org=org, + subject="robin", + namespaces=[f"home-{ns}"], + roles=["viewer"], + ) accept = {"org": org, "namespace": ns, "secret": secret} r = _post(control_plane_url, person, "grants.accept_invite", accept) assert r.status_code == 404, r.text diff --git a/tests/unit/test_agent_shares.py b/tests/unit/test_agent_shares.py index 8e4944d8314..8e4851df2c4 100644 --- a/tests/unit/test_agent_shares.py +++ b/tests/unit/test_agent_shares.py @@ -365,7 +365,7 @@ async def insert_row(row: Any, **kw: Any) -> None: monkeypatch.setattr(grants_app.grants_repo, "find_active_grant", find_active_grant) monkeypatch.setattr(grants_app.grants_repo, "insert_row", insert_row) monkeypatch.setattr(grants_app, "grant_change", lambda *a: _Claim()) - monkeypatch.setattr(grants_app, "_enforce_code_ceiling", no_ceiling) + monkeypatch.setattr(grants_app, "enforce_code_ceiling", no_ceiling) monkeypatch.setattr(aliases, "canonical_subject", canonical) check = agent_shares._made_by("sa:fleet:a", "sa:fleet:b", "fleet-a") body = GrantsCreateInput(org="acme", namespace="fleet-a", subject="sa:fleet:b", role=role) diff --git a/tests/unit/test_auth_aliases.py b/tests/unit/test_auth_aliases.py index b3eaa4f7bde..383f2d94474 100644 --- a/tests/unit/test_auth_aliases.py +++ b/tests/unit/test_auth_aliases.py @@ -93,7 +93,7 @@ async def _insert(row: dict, **_k) -> None: monkeypatch.setattr(grants_repo, "find_active_grant", _none) monkeypatch.setattr(grants_repo, "insert_row", _insert) - monkeypatch.setattr(grants_mod, "_enforce_code_ceiling", _none) + monkeypatch.setattr(grants_mod, "enforce_code_ceiling", _none) monkeypatch.setattr("server.core.ch.get_client", lambda: _ch([])) # released: nothing tied al._CACHE[("acme", "alice@acme.io")] = (time.monotonic(), ("alice@acme.io", "alice")) await grants_mod.handle_grants_create( diff --git a/tests/unit/test_grant_claims.py b/tests/unit/test_grant_claims.py index d24e3c90ecf..6512c955dab 100644 --- a/tests/unit/test_grant_claims.py +++ b/tests/unit/test_grant_claims.py @@ -180,7 +180,7 @@ async def _nothing(*_a: Any, **_k: Any) -> None: monkeypatch.setattr(grants_repo, "find_active_grant", _active) monkeypatch.setattr(grants_repo, "insert_row", _insert) monkeypatch.setattr("server.auth.aliases.canonical_subject", _same) - monkeypatch.setattr(grants_app, "_enforce_code_ceiling", _nothing) + monkeypatch.setattr(grants_app, "enforce_code_ceiling", _nothing) monkeypatch.setattr("server.code.app.index.maintainers.sync_quietly", _nothing) async def _promote() -> None: @@ -280,7 +280,7 @@ async def _nothing(*_a: Any, **_k: Any) -> None: ): monkeypatch.setattr(grants_repo, name, fake) monkeypatch.setattr("server.auth.aliases.canonical_subject", _same) - monkeypatch.setattr(grants_app, "_enforce_code_ceiling", _nothing) + monkeypatch.setattr(grants_app, "enforce_code_ceiling", _nothing) return gone diff --git a/tests/unit/test_grants_create_downgrade.py b/tests/unit/test_grants_create_downgrade.py index 541a8e64db2..dee8287b3d6 100644 --- a/tests/unit/test_grants_create_downgrade.py +++ b/tests/unit/test_grants_create_downgrade.py @@ -44,7 +44,7 @@ async def _no_ceiling(*_a: Any, **_k: Any) -> None: monkeypatch.setattr(grants_repo, "find_active_grant", _find) monkeypatch.setattr(grants_repo, "find_any_grant", _find) monkeypatch.setattr(grants_repo, "insert_row", _insert) - monkeypatch.setattr(grants_mod, "_enforce_code_ceiling", _no_ceiling) + monkeypatch.setattr(grants_mod, "enforce_code_ceiling", _no_ceiling) return inserted, looked_up diff --git a/tests/unit/test_grants_create_stamps_granter.py b/tests/unit/test_grants_create_stamps_granter.py index d04fda0da41..9e54c34436c 100644 --- a/tests/unit/test_grants_create_stamps_granter.py +++ b/tests/unit/test_grants_create_stamps_granter.py @@ -36,7 +36,7 @@ async def _canonical(org: str, subject: str) -> str: monkeypatch.setattr(grants_repo, "find_active_grant", _find) monkeypatch.setattr(grants_repo, "insert_row", _insert) - monkeypatch.setattr(grants_mod, "_enforce_code_ceiling", _no_ceiling) + monkeypatch.setattr(grants_mod, "enforce_code_ceiling", _no_ceiling) monkeypatch.setattr("server.auth.aliases.canonical_subject", _canonical) yield rows set_current_auth(None) diff --git a/tests/unit/test_grants_invite.py b/tests/unit/test_grants_invite.py index b26a66962a9..0d7278f0f3a 100644 --- a/tests/unit/test_grants_invite.py +++ b/tests/unit/test_grants_invite.py @@ -21,7 +21,7 @@ from server.auth import fail_closed from server.auth.context import set_current_auth from server.auth.jwt import AuthInfo -from server.core.ch import sequential_reads_active +from server.core.ch import own_write_reads, sequential_reads_active from server.core.errors import ( BackendUnavailableError, GrantWouldDowngradeError, @@ -156,7 +156,8 @@ async def no_ceiling(*_a: Any, **_k: Any) -> None: @contextlib.asynccontextmanager async def claimed(*_a: Any) -> AsyncIterator[None]: await anyio.lowlevel.checkpoint() # the lease's own round trip, where a cancel lands - yield + with own_write_reads(): # as the real claim reads under it + yield async def send(to: str, **kw: Any) -> bool: w.mail.append({"to": to, **kw}) @@ -175,7 +176,7 @@ async def send(to: str, **kw: Any) -> bool: monkeypatch.setattr(mod, "creator_account_active", account_active) monkeypatch.setattr(mod, "is_revoked", lambda subject, **_: subject in w.revoked) monkeypatch.setattr(mod.grants_repo, "find_active_grant", find_active_grant) - monkeypatch.setattr(mod, "_enforce_code_ceiling", no_ceiling) + monkeypatch.setattr(mod, "enforce_code_ceiling", no_ceiling) monkeypatch.setattr(mod, "invite_change", claimed) monkeypatch.setattr(mod.invite_mail, "send_invite", send) diff --git a/tests/unit/test_repo_maintainers.py b/tests/unit/test_repo_maintainers.py index 33b33ba8294..6d4ab0c9224 100644 --- a/tests/unit/test_repo_maintainers.py +++ b/tests/unit/test_repo_maintainers.py @@ -1234,7 +1234,7 @@ async def _revoke(org: str, ns: str, subject: str, **_k: Any) -> None: monkeypatch.setattr(grants_repo, "find_active_grant", _find) monkeypatch.setattr(grants_repo, "insert_row", _insert) - monkeypatch.setattr(grants_mod, "_enforce_code_ceiling", _no_ceiling) + monkeypatch.setattr(grants_mod, "enforce_code_ceiling", _no_ceiling) monkeypatch.setattr(maintainers, "sync_quietly", _sync) monkeypatch.setattr(maintainers, "revoke_repo_maintainer", _revoke) return calls diff --git a/tests/unit/test_sharing.py b/tests/unit/test_sharing.py index e889bf9d207..e496e3eb2bc 100644 --- a/tests/unit/test_sharing.py +++ b/tests/unit/test_sharing.py @@ -648,10 +648,10 @@ def test_a_grant_to_a_principal_in_another_case_is_refused(subject: str) -> None """In another case, or after a `/` (the shape of an end user's revocation key): no token carries such a subject, so no grant names one.""" from server.core.errors import ValidationError - from server.identity.app.grants import _enforce_principal_target + from server.identity.app.grants import enforce_principal_target with pytest.raises(ValidationError, match="well-formed principal"): - _enforce_principal_target("col-hr", subject) + enforce_principal_target("col-hr", subject) @pytest.mark.parametrize( @@ -1221,11 +1221,11 @@ def test_a_grant_to_everyone_reaches_every_member_of_the_org(org_state: dict[str def test_everyone_holds_grants_on_collections_only_and_no_token_is_it() -> None: from server.core.errors import ValidationError from server.core.principals import is_reserved_subject - from server.identity.app.grants import _enforce_principal_target + from server.identity.app.grants import enforce_principal_target - _enforce_principal_target("col-hr", "everyone") + enforce_principal_target("col-hr", "everyone") with pytest.raises(ValidationError, match="collections only"): - _enforce_principal_target("team", "everyone") + enforce_principal_target("team", "everyone") assert is_reserved_subject("Everyone"), "no token, in any case, is everyone" From f2dd8afea6b5b3670c7d4336e83532e6d07e8a5e Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Sat, 5 Dec 2026 10:04:22 +0530 Subject: [PATCH 27/28] grants.invite: let a second pasted link be accepted; leave a set-aside link aside After an accept the card stays mounted, and its busy state was reset only on failure, so a link pasted next showed with Accept disabled. Busy now resets in a finally. The fragment listener takes only a link the address carries now, so a link set aside by Not now no longer returns on any fragment change. The send path drops a check its one caller already made, the `to` description names all its outcomes, and the docs give the link's full lifetime in the tab and in the Invited list. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Lareb Zafar --- docs/architecture/sharing.md | 3 +- docs/features/dashboard.md | 11 ++--- docs/reference/operations/grants.md | 2 +- frontend/src/views/InvitationCard.test.tsx | 47 +++++++++++++++++----- frontend/src/views/InvitationCard.tsx | 7 +++- server/identity/api/models_grants.py | 5 ++- server/identity/app/invite_mail.py | 5 +-- tests/unit/test_grants_invite.py | 4 +- 8 files changed, 58 insertions(+), 26 deletions(-) diff --git a/docs/architecture/sharing.md b/docs/architecture/sharing.md index 946f869543d..5cfbbac7988 100644 --- a/docs/architecture/sharing.md +++ b/docs/architecture/sharing.md @@ -263,7 +263,8 @@ A password account's email is never verified, which is why an email reaches one through an invitation: the link went to that address, and opening it proves the reader got it. The whole link is a fragment, which a browser never sends to a server or puts in a Referer. Namespaces in your org moves it out of the address into the tab's session -storage, where it waits until the person accepts it or closes the card. +storage, where it waits until the person accepts it or closes the card, or the server +refuses it; where the browser refuses that storage, the card holds it until the page goes. ## Consistency diff --git a/docs/features/dashboard.md b/docs/features/dashboard.md index fefe98cb3f0..b7121ee7507 100644 --- a/docs/features/dashboard.md +++ b/docs/features/dashboard.md @@ -127,11 +127,12 @@ refused. An email is granted at once only when it is verified for an account; an email gets an [invitation](namespaces-and-sharing.md#membership-and-grants). The add shows its link to copy, and the server emails it when it sends mail. The members dialog and a repository's Access tab list it under **Invited**, with who made it and **Cancel**, -until it is accepted. Where sign-in is single sign-on only, the email is granted instead -and reaches that person at their first sign-in. Whoever opens the link signed in accepts -it on Namespaces in your org, which then switches to the namespace; a collection opens in -the Library. With sign-in on, **Settings** › **Tokens** links to Namespaces in your org -for giving a person access: a token is for a tool, agent or script. +while it still admits someone: until it is accepted, cancelled or expired, or its maker no +longer administers the namespace. Where sign-in is single sign-on only, the email is +granted instead and reaches that person at their first sign-in. Whoever opens the link +signed in accepts it on Namespaces in your org, which then switches to the namespace; a +collection opens in the Library. With sign-in on, **Settings** › **Tokens** links to +Namespaces in your org for giving a person access: a token is for a tool, agent or script. The dashboard's text follows the [copy rules](../development/dashboard-design.md#rules-a-change-is-checked-against): its diff --git a/docs/reference/operations/grants.md b/docs/reference/operations/grants.md index c84b99cbf4d..c1f16219444 100644 --- a/docs/reference/operations/grants.md +++ b/docs/reference/operations/grants.md @@ -96,7 +96,7 @@ Give a person a role on a namespace by login handle or email. | --- | --- | --- | --- | | `org` | `str` | required | The tenant (first element of the identity tuple). | | `namespace` | `str` | required | The namespace the op reads or writes. | -| `to` | `str` | required | The person to give `role`: a login handle, or an email, which is granted at once only when it is verified for an account and otherwise gets an invitation link. | +| `to` | `str` | required | The person to give `role`: a login handle, granted at once when an account or a live grant holds it and refused otherwise, or an email, granted at once when it is verified for an account or sign-in is single sign-on only, and otherwise… | | `role` | `Literal['viewer', 'writer', 'admin']` | required | `viewer`, `writer` or `admin`; a code namespace takes only `viewer` and `admin`. | | Output field | Type | Meaning | diff --git a/frontend/src/views/InvitationCard.test.tsx b/frontend/src/views/InvitationCard.test.tsx index ac304bb04bc..d205d499000 100644 --- a/frontend/src/views/InvitationCard.test.tsx +++ b/frontend/src/views/InvitationCard.test.tsx @@ -82,18 +82,15 @@ describe("InvitationCard", () => { useStore.setState({ navigate: real }); }); - it("says why a spent link is refused and offers only Close", async () => { - vi.mocked(acceptInvite).mockRejectedValue( - new ApiError({ - status: 404, - code: "RESOURCE_NOT_FOUND", - message: "this invitation link is used, cancelled or expired: ask for a new one", - }), - ); + it.each([ + [404, "RESOURCE_NOT_FOUND", "this invitation link is used, cancelled or expired: ask for a new one"], + [422, "VALIDATION_FAILED", "an invitation is accepted by a person, signed in as themselves"], + ])("says why a refused link is refused and offers only Close (%i %s)", async (status, code, message) => { + vi.mocked(acceptInvite).mockRejectedValue(new ApiError({ status, code, message })); const user = userEvent.setup(); opened(); await user.click(screen.getByRole("button", { name: "Accept invitation" })); - expect(await screen.findByText(/used, cancelled or expired/)).toBeInTheDocument(); + expect(await screen.findByText(message, { exact: false })).toBeInTheDocument(); expect(screen.queryByRole("button", { name: "Accept invitation" })).toBeNull(); expect(sessionStorage.getItem(INVITE_LINK)).toBeNull(); expect(useStore.getState().identity?.namespace).toBe("home"); @@ -124,6 +121,38 @@ describe("InvitationCard", () => { } }); + it("offers Accept for a link pasted after one was accepted", async () => { + vi.mocked(acceptInvite).mockResolvedValue({ namespace: "alerts", role: "writer" }); + const user = userEvent.setup(); + opened(); + await user.click(screen.getByRole("button", { name: "Accept invitation" })); + expect(screen.queryByRole("region", { name: "Invitation" })).toBeNull(); + history.replaceState(null, "", "/spaces#invite=other&org=dev&namespace=ops"); + act(() => { + window.dispatchEvent(new HashChangeEvent("hashchange")); + }); + try { + expect(await screen.findByRole("button", { name: "Accept invitation" })).toBeEnabled(); + } finally { + history.replaceState(null, "", "/"); + } + }); + + it("leaves a link set aside by Not now aside when the fragment changes", async () => { + const user = userEvent.setup(); + opened(); + await user.click(screen.getByRole("button", { name: "Not now" })); + history.replaceState(null, "", "/spaces#token=x"); + act(() => { + window.dispatchEvent(new HashChangeEvent("hashchange")); + }); + try { + expect(screen.queryByRole("region", { name: "Invitation" })).toBeNull(); + } finally { + history.replaceState(null, "", "/"); + } + }); + it("holds the link itself where session storage is refused", () => { const refuse = vi.spyOn(Storage.prototype, "setItem").mockImplementation(() => { throw new DOMException("blocked", "SecurityError"); diff --git a/frontend/src/views/InvitationCard.tsx b/frontend/src/views/InvitationCard.tsx index 6d241738bf7..c6700e72e78 100644 --- a/frontend/src/views/InvitationCard.tsx +++ b/frontend/src/views/InvitationCard.tsx @@ -44,10 +44,11 @@ export function InvitationCard() { const identity = useStore((s) => s.identity); const setIdentity = useStore((s) => s.setIdentity); const navigate = useStore((s) => s.navigate); - // A link pasted into a tab already on this page changes only the fragment. + // A link pasted into a tab already on this page changes only the fragment. Only a link + // the address carries now: one Not now set aside stays aside. useEffect(() => { const opened = () => { - const next = stashed(); + const next = takeInviteLink(); if (!next) return; setLink(next); setRefused(false); @@ -86,6 +87,8 @@ export function InvitationCard() { setRefused(true); } setError(humanizeError(e)); + } finally { + // The card stays mounted after an accept, and the next pasted link reuses it. setBusy(false); } }; diff --git a/server/identity/api/models_grants.py b/server/identity/api/models_grants.py index 896305e5dc2..624292a5007 100644 --- a/server/identity/api/models_grants.py +++ b/server/identity/api/models_grants.py @@ -217,8 +217,9 @@ class GrantsInviteInput(BaseModel): org: str namespace: str - # The person to give `role`: a login handle, or an email, which is granted at once - # only when it is verified for an account and otherwise gets an invitation link. + # The person to give `role`: a login handle, granted at once when an account or a live + # grant holds it and refused otherwise, or an email, granted at once when it is verified + # for an account or sign-in is single sign-on only, and otherwise sent an invitation link. to: str = Field(min_length=1, max_length=320) # `viewer`, `writer` or `admin`; a code namespace takes only `viewer` and `admin`. role: GrantRoleStr diff --git a/server/identity/app/invite_mail.py b/server/identity/app/invite_mail.py index 68e53fbc94f..d5443e9b995 100644 --- a/server/identity/app/invite_mail.py +++ b/server/identity/app/invite_mail.py @@ -65,9 +65,8 @@ def _send(msg: EmailMessage) -> None: async def send_invite( to: str, *, inviter: str, namespace: str, role: str, url: str, expires_at: int ) -> bool: - """Email the link to `to`; True when the mail server took it.""" - if not (to and can_send()): - return False + """Email the link to `to`, which the caller has checked may be mailed; True when the + mail server took it.""" try: # Inside: the email library refuses a header with a line break in it. msg = _message( diff --git a/tests/unit/test_grants_invite.py b/tests/unit/test_grants_invite.py index 0d7278f0f3a..c8fa1d5092c 100644 --- a/tests/unit/test_grants_invite.py +++ b/tests/unit/test_grants_invite.py @@ -734,12 +734,10 @@ async def test_only_a_person_of_the_org_accepts( @pytest.mark.asyncio -async def test_no_mail_settings_send_nothing(monkeypatch: pytest.MonkeyPatch) -> None: +async def test_the_mail_carries_the_link(monkeypatch: pytest.MonkeyPatch) -> None: sent: list[Any] = [] monkeypatch.setattr(invite_mail, "_send", sent.append) - monkeypatch.setattr(settings, "smtp_url", "") args = {"inviter": "ann", "namespace": "ns", "role": "writer", "url": "u", "expires_at": 0} - assert await invite_mail.send_invite("m@example.com", **args) is False monkeypatch.setattr(settings, "smtp_url", "smtp://mail.example.com") monkeypatch.setattr(settings, "mail_from", "Loom ") monkeypatch.setattr(settings, "public_base_url", "https://loom.example.com") From 3a957c42bc1226e26743d81eed2f1343a3ec0c20 Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Sat, 5 Dec 2026 10:29:55 +0530 Subject: [PATCH 28/28] grants.invite: keep a link pasted during another's accept; say when the list fails An accept answered after another link was pasted dropped the new link, or marked it refused with the old link's error. The card now keys its refusal and error to a link's secret, and an answer forgets only the link it was about. A failed read of the open invitations showed none; it now says it failed, with Retry. The `to` description fits the reference's cell, a comment names what grants.create takes on the Access tab, and the mail test sets only the setting the message reads. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Lareb Zafar --- docs/reference/operations/grants.md | 2 +- frontend/src/components/Invitations.test.tsx | 34 +++++++++----- frontend/src/components/Invitations.tsx | 33 ++++++++++++-- frontend/src/views/Code.tsx | 2 +- frontend/src/views/InvitationCard.test.tsx | 28 ++++++++++++ frontend/src/views/InvitationCard.tsx | 48 ++++++++++++-------- server/identity/api/models_grants.py | 6 +-- tests/unit/test_grants_invite.py | 2 - 8 files changed, 111 insertions(+), 44 deletions(-) diff --git a/docs/reference/operations/grants.md b/docs/reference/operations/grants.md index c1f16219444..9bb2c4b5cf5 100644 --- a/docs/reference/operations/grants.md +++ b/docs/reference/operations/grants.md @@ -96,7 +96,7 @@ Give a person a role on a namespace by login handle or email. | --- | --- | --- | --- | | `org` | `str` | required | The tenant (first element of the identity tuple). | | `namespace` | `str` | required | The namespace the op reads or writes. | -| `to` | `str` | required | The person to give `role`: a login handle, granted at once when an account or a live grant holds it and refused otherwise, or an email, granted at once when it is verified for an account or sign-in is single sign-on only, and otherwise… | +| `to` | `str` | required | The person to give `role`: a login handle an account or live grant holds (any other is refused), or an email, granted at once when verified for an account or under single sign-on only, and otherwise sent an invitation link. | | `role` | `Literal['viewer', 'writer', 'admin']` | required | `viewer`, `writer` or `admin`; a code namespace takes only `viewer` and `admin`. | | Output field | Type | Meaning | diff --git a/frontend/src/components/Invitations.test.tsx b/frontend/src/components/Invitations.test.tsx index 7a76164eb92..659d6899f17 100644 --- a/frontend/src/components/Invitations.test.tsx +++ b/frontend/src/components/Invitations.test.tsx @@ -2,6 +2,7 @@ import { cleanup, render, screen, waitFor } from "../test/rtl"; import userEvent from "@testing-library/user-event"; import { afterEach, describe, expect, it, vi } from "vitest"; import { cancelInvite, isPersonSpelling, listInvites } from "../api/invites"; +import { ApiError } from "../lib/errors"; import { InviteSent, OpenInvitations } from "./Invitations"; vi.mock("../api/invites", async (importOriginal) => { @@ -42,26 +43,35 @@ describe("InviteSent", () => { }); }); +const open = { + invite_id: "abc", + email: "pat@example.com", + role: "writer" as const, + created_by: "ann", + created_at: "2026-12-04T12:00:00Z", + expires_at: "2026-12-11T12:00:00Z", +}; + describe("OpenInvitations", () => { it("lists the open invitations and cancels one", async () => { - vi.mocked(listInvites).mockResolvedValue({ - rows: [ - { - invite_id: "abc", - email: "pat@example.com", - role: "writer", - created_by: "ann", - created_at: "2026-12-04T12:00:00Z", - expires_at: "2026-12-11T12:00:00Z", - }, - ], - }); + vi.mocked(listInvites).mockResolvedValue({ rows: [open] }); const user = userEvent.setup(); render(); await user.click(await screen.findByRole("button", { name: "Cancel the invitation to pat@example.com" })); expect(cancelInvite).toHaveBeenCalledWith({ org: "dev", namespace: "team" }, "abc"); await waitFor(() => expect(screen.queryByRole("region", { name: "Open invitations" })).toBeNull()); }); + + it("says a failed read failed, not that there are none, and reads again on Retry", async () => { + vi.mocked(listInvites) + .mockRejectedValueOnce(new ApiError({ status: 503, code: "BACKEND_UNAVAILABLE", message: "grants unreadable" })) + .mockResolvedValueOnce({ rows: [{ ...open, email: "lee@example.com" }] }); + const user = userEvent.setup(); + render(); + expect(await screen.findByRole("alert")).toHaveTextContent("Couldn't load the invitations: grants unreadable"); + await user.click(screen.getByRole("button", { name: "Retry loading the invitations" })); + expect(await screen.findByText("lee@example.com")).toBeInTheDocument(); + }); }); describe("isPersonSpelling", () => { diff --git a/frontend/src/components/Invitations.tsx b/frontend/src/components/Invitations.tsx index 4ed4b026fd4..42bdf7b2eaf 100644 --- a/frontend/src/components/Invitations.tsx +++ b/frontend/src/components/Invitations.tsx @@ -1,6 +1,7 @@ import { useEffect, useState } from "react"; import { Button } from "@clickhouse/click-ui/Button"; import { cancelInvite, inviteLink, listInvites, type InviteResult, type OpenInvite } from "../api/invites"; +import { errorLine } from "../lib/errorWords"; import { absoluteTime, fmtInt } from "../lib/format"; import { CopyButton } from "./CopyButton"; import { toastError } from "./Toast"; @@ -29,20 +30,42 @@ export function InviteSent({ email, result }: { email: string; result: InviteRes ); } -/** The namespace's open invitations, each with Cancel; nothing while there are none. `version` - * changes to read them again after an invitation is made. */ +/** The namespace's open invitations, each with Cancel; nothing while there are none, and a + * failed read with Retry. `version` changes to read them again after an invitation is made. */ export function OpenInvitations({ scope, version }: { scope: Scope; version: number }) { const [rows, setRows] = useState([]); + const [error, setError] = useState(null); + const [reads, setReads] = useState(0); const [busy, setBusy] = useState(null); useEffect(() => { let live = true; listInvites(scope) - .then((r) => live && setRows(r.rows)) - .catch(() => live && setRows([])); + .then((r) => { + if (!live) return; + setRows(r.rows); + setError(null); + }) + .catch((e: unknown) => live && setError(errorLine(e, { read: true }))); return () => { live = false; }; - }, [scope.org, scope.namespace, version]); + }, [scope.org, scope.namespace, version, reads]); + // A line, not a second error state: the dialog's own list says it failed too in an outage. + if (error !== null && rows.length === 0) { + return ( +

    + Couldn't load the invitations: {error} + +
    + ); + } if (rows.length === 0) return null; const cancel = async (row: OpenInvite) => { diff --git a/frontend/src/views/Code.tsx b/frontend/src/views/Code.tsx index d37f1eaeace..b6b09cdc962 100644 --- a/frontend/src/views/Code.tsx +++ b/frontend/src/views/Code.tsx @@ -3195,7 +3195,7 @@ export function AccessTab({ setBusy("add"); try { // A person by handle or email is invited: an account is granted at once, any other - // email gets a link to copy. A service account or a group is granted as typed. + // email gets a link to copy. Any other principal goes to grants.create as typed. let granted = s; if (isPersonSpelling(s)) { const out = await invite(id, s, role); diff --git a/frontend/src/views/InvitationCard.test.tsx b/frontend/src/views/InvitationCard.test.tsx index d205d499000..af2ff0d3a81 100644 --- a/frontend/src/views/InvitationCard.test.tsx +++ b/frontend/src/views/InvitationCard.test.tsx @@ -138,6 +138,34 @@ describe("InvitationCard", () => { } }); + it.each([ + ["accepted", () => Promise.resolve({ namespace: "alerts", role: "writer" as const })], + ["refused", () => Promise.reject(new ApiError({ status: 404, code: "RESOURCE_NOT_FOUND", message: "used" }))], + ])("keeps a link pasted while another's accept is in flight, once that one is %s", async (_, answer) => { + let settle: () => void = () => {}; + vi.mocked(acceptInvite).mockReturnValueOnce( + new Promise((resolve, reject) => { + settle = () => void answer().then(resolve, reject); + }), + ); + const user = userEvent.setup(); + opened(); + await user.click(screen.getByRole("button", { name: "Accept invitation" })); + history.replaceState(null, "", "/spaces#invite=other&org=dev&namespace=ops"); + act(() => { + window.dispatchEvent(new HashChangeEvent("hashchange")); + }); + try { + await act(async () => settle()); + expect(screen.getByRole("region", { name: "Invitation" })).toHaveTextContent("You're invited to ops."); + await waitFor(() => expect(screen.getByRole("button", { name: "Accept invitation" })).toBeEnabled()); + expect(screen.queryByText(/used/)).toBeNull(); + expect(JSON.parse(sessionStorage.getItem(INVITE_LINK) ?? "null")?.secret).toBe("other"); + } finally { + history.replaceState(null, "", "/"); + } + }); + it("leaves a link set aside by Not now aside when the fragment changes", async () => { const user = userEvent.setup(); opened(); diff --git a/frontend/src/views/InvitationCard.tsx b/frontend/src/views/InvitationCard.tsx index c6700e72e78..26ba0c3a664 100644 --- a/frontend/src/views/InvitationCard.tsx +++ b/frontend/src/views/InvitationCard.tsx @@ -11,21 +11,27 @@ import { isCollectionName } from "../lib/namespace"; import { invalidateShared } from "../lib/sharedReads"; import { useStore } from "../lib/state"; -function stashed(): InviteLink | null { - // An address opened signed in, or after a password sign-in, still carries it. - const taken = takeInviteLink(); +function kept(): InviteLink | null { try { const v = JSON.parse(sessionStorage.getItem(INVITE_LINK) ?? "null") as Partial | null; if (v && typeof v.secret === "string" && typeof v.org === "string" && typeof v.namespace === "string") { return { secret: v.secret, org: v.org, namespace: v.namespace }; } } catch { - /* unreadable: only the link the address carried */ + /* unreadable or no session storage */ } - return taken; + return null; +} + +function stashed(): InviteLink | null { + // An address opened signed in, or after a password sign-in, still carries it. + const taken = takeInviteLink(); + return kept() ?? taken; } -function drop(): void { +/** Forget `secret`'s link, and not one pasted since. */ +function drop(secret: string): void { + if (kept()?.secret !== secret) return; try { sessionStorage.removeItem(INVITE_LINK); } catch { @@ -37,10 +43,11 @@ function drop(): void { export function InvitationCard() { const [link, setLink] = useState(stashed); const [busy, setBusy] = useState(false); - const [error, setError] = useState(null); + // Each keyed by the link's secret: an answer about one link says nothing of one pasted since. + const [error, setError] = useState<{ secret: string; text: string } | null>(null); // The server refused the link: RESOURCE_NOT_FOUND when it is used, cancelled or expired, // VALIDATION_FAILED when this account cannot accept it. Only Close is left. - const [refused, setRefused] = useState(false); + const [refusedSecret, setRefusedSecret] = useState(null); const identity = useStore((s) => s.identity); const setIdentity = useStore((s) => s.setIdentity); const navigate = useStore((s) => s.navigate); @@ -49,33 +56,34 @@ export function InvitationCard() { useEffect(() => { const opened = () => { const next = takeInviteLink(); - if (!next) return; - setLink(next); - setRefused(false); - setError(null); + if (next) setLink(next); }; window.addEventListener("hashchange", opened); return () => window.removeEventListener("hashchange", opened); }, []); if (!link) return null; + const refused = refusedSecret === link.secret; + const shownError = error?.secret === link.secret ? error.text : null; // A link to another org is accepted only signed in there: the server refuses it here. const elsewhere = Boolean(identity && identity.org !== link.org); const close = () => { - drop(); + drop(link.secret); setLink(null); }; const accept = async () => { + const current = link; setBusy(true); setError(null); try { - const out = await acceptInvite(link, link.secret); - close(); + const out = await acceptInvite(current, current.secret); + drop(current.secret); + setLink((shown) => (shown?.secret === current.secret ? null : shown)); toast(`Joined ${out.namespace} as ${out.role}`, "ok"); invalidateShared("mine:"); // A collection opens in the Library; a namespace becomes the one in use. if (isCollectionName(out.namespace)) navigate("knowledge", { query: { collection: out.namespace } }); - else if (identity && identity.org === link.org) { + else if (identity && identity.org === current.org) { setIdentity({ ...identity, namespace: out.namespace }); setSavedNamespace(out.namespace); } @@ -83,10 +91,10 @@ export function InvitationCard() { // Only the server's refusal of the link drops it: an ended session, a rate limit or a // replica that does not serve the op yet keeps it for a retry. if (e instanceof ApiError && (e.code === "RESOURCE_NOT_FOUND" || e.code === "VALIDATION_FAILED")) { - drop(); - setRefused(true); + drop(current.secret); + setRefusedSecret(current.secret); } - setError(humanizeError(e)); + setError({ secret: current.secret, text: humanizeError(e) }); } finally { // The card stays mounted after an accept, and the next pasted link reuses it. setBusy(false); @@ -100,7 +108,7 @@ export function InvitationCard() { {elsewhere ? ` in ${link.org}. Sign in to ${link.org} to accept it.` : "."} {elsewhere ? "" : " Accepting gives the account you're signed in as the role the invitation names."}

    - {error && } + {shownError && }
    {/* Not now keeps the link in this tab, so the card is back on the next visit. */}